From 0605db909c9edde1dcbdb6157f18f29ec1112e54 Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Sat, 14 Feb 2026 19:50:49 -0500 Subject: Show recent comments in sidebar --- jakob/theme.scm | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'jakob/theme.scm') diff --git a/jakob/theme.scm b/jakob/theme.scm index 7e29aa2..0cfebd6 100644 --- a/jakob/theme.scm +++ b/jakob/theme.scm @@ -18,6 +18,9 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (ice-9 match) + #:use-module (jakob dynamic capabilities common) + #:use-module (jakob utils) + #:use-module (jakob utils comments) #:use-module (jakob utils sxml) #:export (theme)) @@ -60,6 +63,8 @@ (time (@ (datetime ,(date->string (current-date) "~Y-~m-~d"))) (string-upcase ,(date->string (current-date) "~d~b~Y"))))) +;; Evaluate ONCE for each invocation of haunt. +(define %recent-comments (fetch-recent-comments)) (define %default-sidebar-modules `((section (@ (class "module search-module") @@ -120,20 +125,21 @@ (style ,(fugue-icon-path "megaphone"))) "Recent Comments") (div (@ (class "sidebar-comment-list")) - (article (@ (class "sidebar-comment-box")) - (span (@ (class "comment-context")) - "on: " - (a (@ (href "/blog/usb-pd-is-pretty-cool.html")) "USB-PD Is Pretty Cool")) - (strong "Bob") - (a (@ (href "/blog/usb-pd-is-pretty-cool.html#comment-reply")) - "I used PETG to make sure it didn't warp...")) - (article (@ (class "sidebar-comment-box")) - (span (@ (class "comment-context")) - "on: " - (a (@ (href "/blog/usb-pd-is-pretty-cool.html")) "USB-PD Is Pretty Cool")) - (strong "Alice") - (a (@ (href "/blog/usb-pd-is-pretty-cool.html#comment-reply")) - "This is a lifesaver for field work. Have you...")))))) + ,@(map (lambda (comment) + `(article (@ (class "sidebar-comment-box")) + (span (@ (class "comment-context")) + "on: " + (a (@ (href ,(format #f "/blog/~a.html" (internal-comment-slug comment)))) + ,(internal-comment-slug comment))) + (strong ,(internal-comment-name comment)) + (a (@ (href ,(format #f "/blog/~a.html#comment-~a" + (internal-comment-slug comment) + (internal-comment-id comment)))) + ,(let ((text (internal-comment-comment comment))) + (if (> (string-length text) 25) + (format #f "~a..." (string-take text 25)) + text))))) + %recent-comments))))) (define %footer (let ((year (date-year (current-date)))) -- cgit v1.3