manifest_loader.load_for(id) reads <install>/modules/<id>/
manifest.launcher.md via engine.module.read_file, runs the JSON
frontmatter through frontmatter.parse, and pre-parses the body via
markdown.parse. Cached on the shared ctx so the detail-panel render
loop does not pay the parse cost per frame. Missing files degrade to
{_missing=true} and the list falls back to the module's name/id.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
32 lines
967 B
Lua
32 lines
967 B
Lua
local M = {}
|
|
|
|
local fm
|
|
|
|
local function ensure_deps()
|
|
if not fm then
|
|
fm = dofile(engine.module.dir_of("lib-management.launcher") .. "/frontmatter.lua")
|
|
end
|
|
end
|
|
|
|
-- Returns:
|
|
-- meta = { summary, description_md, author, tags, teaser_images,
|
|
-- carousel_interval_seconds, ... }
|
|
-- body_blocks = output of markdown.parse(body) — pre-parsed for cache reuse
|
|
-- On any failure (file missing, parse error): meta = {}, body_blocks = {}.
|
|
function M.load_for(module_id)
|
|
ensure_deps()
|
|
local content, err = engine.module.read_file(module_id, "manifest.launcher.md")
|
|
if not content then
|
|
return { _missing = true, _err = err }, {}
|
|
end
|
|
local meta, body, perr = fm.parse(content)
|
|
if not meta then
|
|
return { _missing = false, _err = perr }, {}
|
|
end
|
|
local md = dofile(engine.module.dir_of("lib-management.launcher") .. "/markdown.lua")
|
|
local blocks = md.parse(body)
|
|
return meta, blocks
|
|
end
|
|
|
|
return M
|