aboutsummaryrefslogtreecommitdiff
path: root/haunt/jakob/builder/blog.scm
diff options
context:
space:
mode:
Diffstat (limited to 'haunt/jakob/builder/blog.scm')
-rw-r--r--haunt/jakob/builder/blog.scm33
1 files changed, 10 insertions, 23 deletions
diff --git a/haunt/jakob/builder/blog.scm b/haunt/jakob/builder/blog.scm
index 5a178d7..f8a8d6e 100644
--- a/haunt/jakob/builder/blog.scm
+++ b/haunt/jakob/builder/blog.scm
@@ -24,6 +24,7 @@
#:use-module (jakob theme)
#:use-module (jakob utils)
#:use-module (jakob utils sxml)
+ #:use-module (jakob utils tags)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-26)
@@ -51,7 +52,7 @@
"Tags: "
,@(intersperse
(map (lambda (tag)
- (hyperlink (tag-uri tag) tag))
+ (hyperlink (tag-uri %tag-prefix tag) tag))
(post-ref post 'tags))
", "))
(article
@@ -70,7 +71,7 @@
" ❖ Tags: "
(intersperse
(map (lambda (tag)
- (hyperlink (tag-uri tag) tag))
+ (hyperlink (tag-uri %tag-prefix tag) tag))
(post-ref post 'tags))
", ")))
(p ,(first-paragraph post))
@@ -95,10 +96,10 @@ to PREVIOUS-PAGE and NEXT-PAGE."
;;;
;; Subdirectory for permalink pages.
-(define %prefix "blog")
+(define %prefix "/blog")
(define (post-uri post)
- "Return the path of POST relative to the site's base directory."
+ "Return the path of POST relative to the site's root."
(let* ((file-name (post-file-name post))
(splice-start (1+ (string-rindex file-name (cut char=? <> #\/))))
(splice-end (string-rindex file-name (cut char=? <> #\.)))
@@ -168,12 +169,7 @@ and output file names beginning with BASE-FILE-NAME."
;;;
;; Subdirectory for post listings conditioned on post tags.
-(define %tag-prefix "tag")
-
-(define* (tag-uri tag #:optional (extension ".html"))
- "Return the URI relative to the site's root of a page listing posts tagged
-with TAG."
- (string-append %tag-prefix "/" tag extension))
+(define %tag-prefix "/blog/tag")
(define (tags->pages posts)
"Return a list of pages for each tag used in POSTS, with said pages containing
@@ -181,18 +177,9 @@ only the posts tagged with that tag."
(flat-map (match-lambda
((tag . posts)
(post-list->pages (format #f "Posts tagged as \"~a\"" tag)
- (tag-uri tag "")
+ (tag-uri %tag-prefix tag "")
posts)))
- (posts/group-by-tag posts)))
-
-(define (count-tags posts)
- "Return lists of the form (tag-name count) summarizing tag usage across POSTS,
-ordered such that tags with greater usage are at the beginning of the list, and
-tags with less usage are at the end of the list."
- (sort (map (lambda (tag)
- (list (car tag) (length (cdr tag))))
- (posts/group-by-tag posts))
- (lambda (a b) (> (cadr a) (cadr b)))))
+ (group-by-tag posts (cut post-ref <> 'tags))))
(define (all-tags posts)
"Return a page summarizing tag usage across POSTS."
@@ -201,9 +188,9 @@ tags with less usage are at the end of the list."
(ul (@ (id "tag-cloud"))
,@(map (match-lambda
((tag count)
- (hyperlink (tag-uri tag)
+ (hyperlink (tag-uri %tag-prefix tag)
`(li ,(format #f "~a (~a)" tag count)))))
- (count-tags posts)))))
+ (count-tags posts (cut post-ref <> 'tags))))))
(make-page "tag.html"
(theme #:title "All Tags"
#:content content)

© 2015 - 2026 Jakob L. Kreuze