Allow implicit cover images

This commit is contained in:
Talia 2025-06-30 15:35:39 +02:00
parent 8686fd9bae
commit 63c38e3fec

View file

@ -27,11 +27,18 @@ end
local function read_post(file) local function read_post(file)
local content = io.open(file):read("*a") local content = io.open(file):read("*a")
local head, body = restia.utils.frontmatter(content) local head_text, body_text = restia.utils.frontmatter(content)
return {
head = head and yaml.load(head) or {}; local head = head_text and yaml.load(head_text) or {}
body = cmark.render_html(cmark.parse_document(body, #body, cmark.OPT_DEFAULT), cmark.OPT_DEFAULT + cmark.OPT_UNSAFE); local body = cmark.render_html(cmark.parse_document(body_text, #body_text, cmark.OPT_DEFAULT), cmark.OPT_DEFAULT + cmark.OPT_UNSAFE)
}
local cover_image = file:gsub("md$", "jpg")
if io.open(cover_image) then
head.cover_image = "/images/" .. cover_image:match("[^/]+$")
print(head.cover_image)
end
return { head = head, body = body }
end end
local posts = {} local posts = {}