+PREFIX: The directory in which to write the posts
+FILTER: The procedure called to manipulate the posts list before rendering"
+ (lambda (site posts)
+ (define (tag-list tag posts all-posts)
+ (define (render-list title posts prefix)
+ (let ((body ((theme-collection-template theme)
+ site title posts prefix all-posts tag)))
+ ((theme-layout theme) site title body)))
+ (make-page (tag-uri my-tag-prefix tag)
+ (render-list (string-append "Notes tagged ‘" tag "’")
+ (filter posts)
+ prefix)
+ sxml->html))
+ (let ((tag-groups (posts/group-by-tag posts)))
+ (map (match-lambda
+ ((tag . tagged-posts) (tag-list tag tagged-posts posts)))
+ tag-groups))))
+
+(define (tag-links posts)
+ "Generate an alphabetically sorted list of links to tagged posts.
+The link text consists of the tag name and the number of tagged posts
+in parentheses."
+ `(ul (@ (class "tag-list"))
+ ,(map (match-lambda
+ ((tag . posts)
+ `(li
+ ,(aa (string-append tag
+ " ("
+ (number->string (length posts))
+ ")")
+ (tag-uri my-tag-prefix tag)))))
+ ;; sort by tag
+ (sort (posts/group-by-tag posts)
+ (lambda (a b) (string<? (car a) (car b)))))))