cripslock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 0f4da2662817a8fd36eacce416074ca87adcfc72
parent a7fbd53eca9b097e565f00d68c6fc6fb89f8843e
Author: Daniel Barlow <dan@telent.net>
Date:   Thu,  7 Aug 2025 19:45:58 +0100

print [[no-such-page]] as plain text

instead of dying because it can't get the page title

Diffstat:
Msite.fnl | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/site.fnl b/site.fnl @@ -8,17 +8,20 @@ (local textile (require :textile)) (local lcmark (require :lcmark)) (local { : to-html } (require :html)) -(local { : parse-timestamp : trace } (require :lib)) +(local { : parse-timestamp : trace : %% } (require :lib)) (fn translate-markdown [site md] ;; lcmark/cmark doesn't have any extension points that allow us ;; to add actual new syntax so we're just going to postprocess - (let [subst-links (fn [slug title] - (string.format - "<a href=%q class=internal>%s</a>" + (let [subst-links + (fn [slug title] + (let [post (site:get slug)] + (if post + (%% "<a href=%q class=internal>%s</a>" slug - (or title (. (site:get slug) :title))))] + (or title (. post :title))) + (or title slug))))] (-> md (lcmark.convert "html" { :yaml_parser #($1) }) (string.gsub "%[%[([%w_-]+)|(.-)%]%]" subst-links)