Refactor
This commit is contained in:
parent
5d2d8ba8c9
commit
e47041931d
19
site.moon
19
site.moon
@ -90,22 +90,17 @@ template = [[
|
|||||||
-- @tparam[opt] string template a string that can contain variables and
|
-- @tparam[opt] string template a string that can contain variables and
|
||||||
-- helpers.
|
-- helpers.
|
||||||
--
|
--
|
||||||
-- @treturn func the function that will be called when this is used in a
|
-- @treturn func the function that will be called from the template.
|
||||||
-- template.
|
|
||||||
list_posts = (template) => (args={}) =>
|
list_posts = (template) => (args={}) =>
|
||||||
pages = @site\query_pages { is_a: "post" }
|
pages = @site\query_pages { is_a: "post" }
|
||||||
table.sort pages, (a, b) -> a.source > b.source
|
table.sort pages, (a, b) -> a.source > b.source
|
||||||
limit = math.min args.limit or #pages, #pages
|
limit_or_page_count = math.min args.limit or #pages, #pages
|
||||||
|
|
||||||
return for page in *pages[1, limit]
|
return for page in *pages[1, limit_or_page_count]
|
||||||
{ title: title, id: id, publish_date: date, blurb: blurb } = page.meta
|
{ :title, :id, publish_date: pub_date, :blurb } = page.meta
|
||||||
|
title = title or titleize_slug id
|
||||||
vals = {
|
url = rootname page\url_for!
|
||||||
title: title or titleize_slug id
|
vals = { title: title, publish_date: pub_date, blurb: blurb, url: url }
|
||||||
publish_date: date
|
|
||||||
blurb: blurb
|
|
||||||
url: rootname page\url_for!
|
|
||||||
}
|
|
||||||
|
|
||||||
if template then common.fill_ignoring_pre template, vals else vals
|
if template then common.fill_ignoring_pre template, vals else vals
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user