diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2026-02-14 19:50:49 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2026-02-14 19:50:49 -0500 |
| commit | 0605db909c9edde1dcbdb6157f18f29ec1112e54 (patch) | |
| tree | 1d5702d112234f85f2a870d3ad6f7eecb222ff57 /jakob/theme.scm | |
| parent | 229b41676baf1cbb719098e25b05cbdd1622e240 (diff) | |
Show recent comments in sidebar
Diffstat (limited to 'jakob/theme.scm')
| -rw-r--r-- | jakob/theme.scm | 34 |
1 files changed, 20 insertions, 14 deletions
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)))) |