Yet another way to do it

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 20:18:05 -07:00
parent a48b79c7c7
commit a793669c57

View File

@ -63,7 +63,7 @@ titleize_slug = (slug="") ->
template = [[
<section>
<h3><a href="$target">$post_title</a></h3>
<h3><a href="$target">$title</a></h3>
<time>$publish_date</time> — $blurb
<a class="read-post-link" href="$target">Read post →</a>
</section>
@ -77,12 +77,17 @@ list_posts = (args={}) =>
posts = @site\query_pages { is_a: "post" }
table.sort posts, (a, b) -> a.source > b.source
return for { meta: meta, source: source } in *posts[1, args.limit or #posts]
common.fill_ignoring_pre template,
target: meta.target
post_title: meta.title or titleize_slug meta.id
publish_date: publish_date source
blurb: meta.blurb
return for page in *posts[1, args.limit or #posts]
page.tpl_scope = page\get_tpl_scope!
page.meta.title = page.meta.title or titleize_slug page.meta.id
page.template_stack = common.Stack!
page.template_stack\push @site.config.default_template
@renderer\render page, template
-- common.fill_ignoring_pre template,
-- target: meta.target
-- post_title: meta.title or titleize_slug meta.id
-- publish_date: publish_date source
-- blurb: meta.blurb
-- call like this from a template: $(get_posts())[[<p>$target</p>]]
-- or like this: $(get_posts({limit = 5}))[[<p>$target</p>]]