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
|
||||
-- helpers.
|
||||
--
|
||||
-- @treturn func the function that will be called when this is used in a
|
||||
-- template.
|
||||
-- @treturn func the function that will be called from the template.
|
||||
list_posts = (template) => (args={}) =>
|
||||
pages = @site\query_pages { is_a: "post" }
|
||||
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]
|
||||
{ title: title, id: id, publish_date: date, blurb: blurb } = page.meta
|
||||
|
||||
vals = {
|
||||
title: title or titleize_slug id
|
||||
publish_date: date
|
||||
blurb: blurb
|
||||
url: rootname page\url_for!
|
||||
}
|
||||
return for page in *pages[1, limit_or_page_count]
|
||||
{ :title, :id, publish_date: pub_date, :blurb } = page.meta
|
||||
title = title or titleize_slug id
|
||||
url = rootname page\url_for!
|
||||
vals = { title: title, publish_date: pub_date, blurb: blurb, url: url }
|
||||
|
||||
if template then common.fill_ignoring_pre template, vals else vals
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user