From 76f99322f7831c11b7305462c2b5685551c67fb3 Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Mon, 16 Jun 2025 20:18:05 -0700 Subject: [PATCH] Clean up --- index.html | 10 --------- site.moon | 60 ++++++++++-------------------------------------------- 2 files changed, 11 insertions(+), 59 deletions(-) diff --git a/index.html b/index.html index c5c9559..e679bf0 100644 --- a/index.html +++ b/index.html @@ -6,16 +6,6 @@ $render{"templates/wares"}

Posts

-$({{hi = "there"}})[[$hi]] - -$(test1({limit = 2}))[[

inline template $title

]] -$each{test2({limit = 2}), "post"}[[$post]] - -$(list_posts1({limit = 2}))[[

$title

]] -$each{list_posts2({limit = 2}), "post"}[[$post]] - -
- $each{list_posts({limit = 5}), "post"}[[$post]]

diff --git a/site.moon b/site.moon index 7bf1dee..395d34f 100644 --- a/site.moon +++ b/site.moon @@ -69,23 +69,15 @@ template = [[ ]] --- use in templates like this --- $each{list_posts({limit = 5}), "post"}[[$post]] --- or like this --- $each{list_posts(), "post"}[[$post]] - --- can call this two ways. One takes a template, the others uses a template passed --- in --- $(list_posts({limit = 2}, true))[[

$title

]] --- $each{list_posts({limit = 2}), "post"}[[$post]] - --- to inline a template, use like this --- @list_posts = list_posts @ --- and then call from template like this --- $(list_posts({limit = 2}))[[

$title

]] --- to pass in a template, use like this --- @list_posts = list_posts @, [[

$title

]] --- $each{list_posts({limit = 2}), "post"}[[$post]] +-- setup in create function: +-- +-- sitegen.create => +-- @list_posts = list_posts @, [template] +-- +-- use in templates: +-- +-- `list_posts @` expects $(list_posts({limit = 2}))[[

$title

]] +-- `list_posts @, template` expects $each{list_posts({limit = 2}), "post"}[[$post]] list_posts = (template) => (args={}) => pages = @site\query_pages { is_a: "post" } table.sort pages, (a, b) -> a.source > b.source @@ -103,27 +95,6 @@ list_posts = (template) => (args={}) => if template then common.fill_ignoring_pre template, vals else vals --- call like this from a template: $(get_posts())[[

$title

]] --- or like this: $(get_posts({limit = 5}))[[

$title

]] -get_posts = (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 - - return for page in *pages[1, limit] - { title: title, id: id, publish_date: date, blurb: blurb } = page.meta - - { - title: title or titleize_slug id - publish_date: date - blurb: blurb - url: rootname page\url_for! - } - -test = (args={}, template) => - vals = { title: "yoayasdf" } - if template then common.fill_ignoring_pre template, vals else { vals } - -- replace '$if' helper function with cosmo's 'cif' html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block -- add a '$titleize' helper function @@ -133,22 +104,13 @@ documents = (path=".") -> files = reverse get_files path {join(path, file), target(file, "/posts") for file in *files} -test3 = (args, template) => - p two - sitegen.create => @site_title = "WebDevCat.me" @app_name = "stasis" @version = "0.2.12" - @list_posts = list_posts @ - @list_posts1 = list_posts @ - @list_posts2 = list_posts @, template - @get_posts = get_posts - @test1 = (args) => test @, args - @test2 = (args) => test @, args, [[passed template $title]] - @test3 = test3 + @list_posts = list_posts @, template - add_all = (name="", files) -> + add_all = (name, files) -> for path, target in pairs files id = extract_id path