From 37958c8ad8592e43558ba55c0fee929f0354c367 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 20 May 2025 17:49:56 -0700 Subject: [PATCH] WIP: i think i got it --- blog.html | 8 -------- index.html | 8 +------- site.moon | 31 +++++++++---------------------- 3 files changed, 10 insertions(+), 37 deletions(-) diff --git a/blog.html b/blog.html index f611c0c..3162ebb 100644 --- a/blog.html +++ b/blog.html @@ -1,11 +1,3 @@

Posts

$lp - -$list_posts[[ -
-

$post_title

- — $blurb - Read post → -
-]] diff --git a/index.html b/index.html index 2dfefb1..a4682a2 100644 --- a/index.html +++ b/index.html @@ -6,13 +6,7 @@ $render{"templates/wares"}

Posts

-$list_posts{limit = 5}[[ -
-

$post_title

- — $blurb - Read post → -
-]] +$lp{limit = 5}

View more posts diff --git a/site.moon b/site.moon index 0de76f4..6171d18 100644 --- a/site.moon +++ b/site.moon @@ -5,6 +5,7 @@ html = require "sitegen.html" cosmo = require "sitegen.cosmo" date = require "date" +html_renderer = require "sitegen.renderers.html" import tag from html import escape_patt from require "sitegen.common" import p from require "moon" @@ -76,7 +77,7 @@ titleize = (word) -> h(word), t(word) titleize_slug = (slug) -> words = [{ titleize word } for word in *common.split slug, "-"] - table.concat [head .. tail for { head, tail } in *words] + table.concat [head .. tail for { head, tail } in *words], " " template = [[
@@ -86,29 +87,16 @@ template = [[
]] -list_posts = (page, limit) -> +list_posts = (page, args={}) -> posts = page.site\query_pages { is_a: "post" } table.sort posts, (a, b) -> a.source > b.source - table.concat [cosmo.f(template) { + table.concat [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 - } for { meta: meta, source: source } in *posts[1, limit or #posts]] - -- html.build -> - -- import section, h3, a, time from tag - -- - -- [section { - -- h3 { a { href: meta.target, meta.title or titleize_slug meta.id }} - -- time { publish_date source } - -- { "—", if meta.blurb then html.builders.text! meta.blurb } - -- a { class: "read-post-link", href: meta.target, - -- "Read post →" - -- } - -- } for { meta: meta, source: source } in *posts[1, limit or #posts]] - - + } for { meta: meta, source: source } in *posts[1, args.limit or #posts]] list_posts2 = (page, args={}) -> pages = page.site\query_pages { is_a: "post" } @@ -123,7 +111,6 @@ list_posts2 = (page, args={}) -> for post in *posts do cosmo.yield post -html_renderer = require "sitegen.renderers.html" html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block html_renderer.cosmo_helpers.titleize = (slug) => html.build -> titleize_slug(slug) if slug @@ -138,10 +125,10 @@ sitegen.create => add "index.html", title: "Catalin Mititiuc" add "blog.html", title: "Posts", target: "posts/index", template: "blog" - add "about.html", some: { - { one: "alpha", two: "beta" }, - { one: "A", two: "B" } - }, cif: cosmo.cif, math: math, x: 2 + -- add "about.html", some: { + -- { one: "alpha", two: "beta" }, + -- { one: "A", two: "B" } + -- }, cif: cosmo.cif, math: math, x: 2 for path, target in pairs posts "docs" id = extract_id path