cripslock

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

commit 3eba1eeea34c193050fcac7661d8b4339cfcc337
parent bb67cbd0be3ef1a6f9dcd853cf5487e40ec2851b
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 20 Jul 2025 18:05:56 +0100

set timestamp and slug when building index

Diffstat:
Mmain.fnl | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/main.fnl b/main.fnl @@ -85,6 +85,11 @@ (expect= (parse-timestamp "Sat Jul 19 23:53:21 2025") 1752965601) ) +(fn slug [title] + (-> title + (string.gsub "[^A-Za-z0-9]+" "_") + (string.gsub "_+$" ""))) + (fn index-posts [path] (collect [name (lfs.dir path)] (let [fullname (.. path "/" name) @@ -96,7 +101,12 @@ (string.match name "%.textile$") (string.match name "%.md$"))) (with-open [f (io.open fullname)] - (values name (frontmatter f))))))) + (let [fields (frontmatter f)] + (values (slug (or fields.subject fields.title)) + (doto fields + (tset :path name) + (tset :date (and fields.date (parse-timestamp fields.date))))))))))) + ;; (print (view (index-posts "data/blogs/telent.blog/posts/")))