Refactor the 'for' loop that adds all the post files

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 20:18:05 -07:00
parent 111d3ea0a3
commit d8d50c234a
2 changed files with 8 additions and 4 deletions

View File

@ -62,9 +62,13 @@ sitegen.create =>
add "index.html" add "index.html"
add "blog.html", target: "posts/index", template: "blog" add "blog.html", target: "posts/index", template: "blog"
add path, target: out, template: "post", is_a: "post", post: { for path, target in pairs posts "docs"
add path,
target: target
template: "post"
is_a: "post"
publish_date: publish_date(path) publish_date: publish_date(path)
}, id: extract_id(path) for path, out in pairs posts "docs" id: extract_id(path)
-- replace post markdown yaml headers with moonscript headers -- replace post markdown yaml headers with moonscript headers
filter "docs", (body) => filter "docs", (body) =>

View File

@ -4,7 +4,7 @@ $wrap{"blog"}
<header> <header>
<div> <div>
<h2>$(title or id)</h2> <h2>$(title or id)</h2>
<time>$(post.publish_date)</time> <time>$publish_date</time>
</div> </div>
</header> </header>