Inline posts list template

This commit is contained in:
Catalin Constantin Mititiuc 2025-05-20 17:58:17 -07:00
parent 540ad25e5e
commit 630fa60191

View File

@ -79,19 +79,17 @@ titleize_slug = (slug) ->
words = [{ titleize word } for word in *common.split slug, "-"] words = [{ titleize word } for word in *common.split slug, "-"]
table.concat [head .. tail for { head, tail } in *words], " " table.concat [head .. tail for { head, tail } in *words], " "
template = [[
<section>
<h3><a href="$target">$post_title</a></h3>
<time>$publish_date</time> — $blurb
<a class="read-post-link" href="$target">Read post →</a>
</section>
]]
list_posts = (page, args={}) -> list_posts = (page, args={}) ->
posts = page.site\query_pages { is_a: "post" } posts = page.site\query_pages { is_a: "post" }
table.sort posts, (a, b) -> a.source > b.source table.sort posts, (a, b) -> a.source > b.source
table.concat [common.fill_ignoring_pre template, { table.concat [common.fill_ignoring_pre [[
<section>
<h3><a href="$target">$post_title</a></h3>
<time>$publish_date</time> — $blurb
<a class="read-post-link" href="$target">Read post →</a>
</section>
]], {
target: meta.target target: meta.target
post_title: meta.title or titleize_slug meta.id post_title: meta.title or titleize_slug meta.id
publish_date: publish_date source publish_date: publish_date source