From c5c4c493e11b24837547f012167394670cb5e3e8 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Fri, 23 May 2025 15:19:52 -0700 Subject: [PATCH] Fix blurb encoding --- site.moon | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/site.moon b/site.moon index eab45d6..120ede0 100644 --- a/site.moon +++ b/site.moon @@ -50,7 +50,10 @@ reverse = (list={}) -> [item for item in *list[#list, 1, -1]] extract_id = (source) -> string.match Path.filename(source), "%a[%w%-]+" extract_date = (source) -> string.match Path.filename(source), "%d+%-%d%d%-%d%d" format_date = (str) -> date(str)\fmt "%b %d, %Y" -publish_date = (path) -> format_date extract_date path + +publish_date = (path using nil) -> + date = extract_date path + date, format_date date strip_date = (filename) -> filename\gsub "#{escape_patt(extract_date(filename) .. "-")}/?", "" @@ -75,12 +78,6 @@ html_renderer.cosmo_helpers.titleize = (slug) => titleize_slug slug files_from = (path=".") -> [Path.join path, file for file in *reverse get_files path] -listing_info = (page) -> - { :title, :id, publish_date: pub_date, :blurb } = page.meta - title = title or titleize_slug id - url = rootname page\url_for! - { title: title, publish_date: pub_date, blurb: blurb, url: url } - get_posts = (limit) => pages = @site\query_pages { is_a: "post" } table.sort pages, (a, b) -> a.source > b.source @@ -93,25 +90,30 @@ sitegen.create => @version = "0.2.12" @just_render_the_damn_list = (arg={}, _) => - posts = [listing_info post for post in *get_posts @, arg.limit] + posts = [post for post in *get_posts @, arg.limit] html.build -> import section, h3, time, a from tag - [section { - h3 { a { title, href: url }} - time { pretty, datetime: iso } - "—", blurb, a { "Read post →", class: "read-post-link", href: url } - } for { :title, :url, :blurb, publish_date: { iso, pretty }} in *posts] + return for post in *posts + {:title, :blurb, :id, publish_date: {iso, pretty}} = post.meta + url = rootname post\url_for! + blurb = html.builders.raw!(html.build -> blurb) if blurb + + section { + h3 { a { title or titleize_slug(id), href: url }} + time { pretty, datetime: iso } + "—", blurb, a { "Read post →", class: "read-post-link", href: url } + } add_all = (files) -> - for path in *files - add path, - target: target(path, "/posts") - template: "post" - is_a: "post" - publish_date: { extract_date(path), publish_date path } - id: extract_id path + add path, { + target: target path, "/posts" + template: "post" + is_a: "post" + publish_date: { publish_date path } + id: extract_id path + } for path in *files add "index.html", title: "Catalin Mititiuc" add "blog.html", title: "Posts", target: "posts/index", template: "blog"