From e47041931d2288b7baaa074c278b51a1642be20a Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Thu, 22 May 2025 10:28:18 -0700 Subject: [PATCH] Refactor --- site.moon | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/site.moon b/site.moon index ac4c25e..a8bacc5 100644 --- a/site.moon +++ b/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