cripslock

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

commit 39bea00a19e419b01b9d6809cc931ec88caf2779
parent d34497f54cea576e236f820e4337cc83c3b01522
Author: Daniel Barlow <dan@telent.net>
Date:   Mon, 31 Aug 2026 18:51:18 +0100

site: DRY calls to index-posts

Diffstat:
Msite.fnl | 27+++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/site.fnl b/site.fnl @@ -231,18 +231,21 @@ (site:refresh)))))) (fn for-pathname [path] - (var posts (index-posts path)) - { - :get #(. posts $2) - :search #(search-posts posts $2) - :path path - :static-file (fn [_ name] - (static-path-if-safe path name)) - :topics #(topics posts) - :weighted-topics #(weighted-topics posts) - :refresh #(set posts (index-posts path)) - :watch watch-changes - }) + (var posts {}) + (doto + { + :get #(. posts $2) + :search #(search-posts posts $2) + :path path + :static-file (fn [_ name] + (static-path-if-safe path name)) + :topics #(topics posts) + :weighted-topics #(weighted-topics posts) + :refresh (fn [self] (set posts (index-posts path)) self) + :watch watch-changes + } + (: :refresh))) + (define-tests :static-path (expect (static-path-if-safe "./" "/README.md"))