summaryrefslogtreecommitdiff
path: root/jakob/builder/blog.scm
diff options
context:
space:
mode:
Diffstat (limited to 'jakob/builder/blog.scm')
-rw-r--r--jakob/builder/blog.scm12
1 files changed, 10 insertions, 2 deletions
diff --git a/jakob/builder/blog.scm b/jakob/builder/blog.scm
index c14cecf..b3f83a6 100644
--- a/jakob/builder/blog.scm
+++ b/jakob/builder/blog.scm
@@ -33,6 +33,8 @@
#:use-module (srfi srfi-26)
#:use-module (web uri)
#:export (post-uri
+ render-preview
+ sort-posts
blog))
;;; Commentary:
@@ -165,6 +167,12 @@
;; Subdirectory for post listings conditioned on post tags.
(define %tag-prefix (string-append %blog-prefix "/tag"))
+(define* (sort-posts posts #:keywords (reverse? #f))
+ (sort posts (lambda (a b)
+ ((if reverse? time>=? time<?)
+ (date->time-monotonic (post-date a))
+ (date->time-monotonic (post-date b))))))
+
(define (tags->pages posts)
"Return a list of pages for each tag used in POSTS, with said pages containing
only the posts tagged with that tag."
@@ -173,8 +181,8 @@ only the posts tagged with that tag."
(items->pages render-preview posts
(format #f "Posts tagged with \"~a\"" tag)
(tag-uri %tag-prefix tag ""))))
- (group-by-tag (sort posts (lambda (a b)
- (time<? (date->time-monotonic (post-date a)) (date->time-monotonic (post-date b))))) (cut post-ref <> 'tags))))
+ (group-by-tag (sort-posts posts #:reverse? #t)
+ (cut post-ref <> 'tags))))
(define (all-tags posts)
"Return a page summarizing tag usage across POSTS."