Yet another way to do it
This commit is contained in:
parent
0369d5bb56
commit
832ed344ca
19
site.moon
19
site.moon
@ -63,7 +63,7 @@ titleize_slug = (slug="") ->
|
|||||||
|
|
||||||
template = [[
|
template = [[
|
||||||
<section>
|
<section>
|
||||||
<h3><a href="$target">$post_title</a></h3>
|
<h3><a href="$target">$title</a></h3>
|
||||||
<time>$publish_date</time> — $blurb
|
<time>$publish_date</time> — $blurb
|
||||||
<a class="read-post-link" href="$target">Read post →</a>
|
<a class="read-post-link" href="$target">Read post →</a>
|
||||||
</section>
|
</section>
|
||||||
@ -77,12 +77,17 @@ list_posts = (args={}) =>
|
|||||||
posts = @site\query_pages { is_a: "post" }
|
posts = @site\query_pages { is_a: "post" }
|
||||||
table.sort posts, (a, b) -> a.source > b.source
|
table.sort posts, (a, b) -> a.source > b.source
|
||||||
|
|
||||||
return for { meta: meta, source: source } in *posts[1, args.limit or #posts]
|
return for page in *posts[1, args.limit or #posts]
|
||||||
common.fill_ignoring_pre template,
|
page.tpl_scope = page\get_tpl_scope!
|
||||||
target: meta.target
|
page.meta.title = page.meta.title or titleize_slug page.meta.id
|
||||||
post_title: meta.title or titleize_slug meta.id
|
page.template_stack = common.Stack!
|
||||||
publish_date: publish_date source
|
page.template_stack\push @site.config.default_template
|
||||||
blurb: meta.blurb
|
@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>]]
|
-- call like this from a template: $(get_posts())[[<p>$target</p>]]
|
||||||
-- or like this: $(get_posts({limit = 5}))[[<p>$target</p>]]
|
-- or like this: $(get_posts({limit = 5}))[[<p>$target</p>]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user