diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-04-04 15:06:34 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-04-08 08:57:55 -0400 |
commit | ed1602dc36444bcf1023926854a2cb01b5199e7e (patch) | |
tree | b25aa2ef353a1a0cd9793ff9974c7175baaa9e79 | |
parent | 37b4cde1a3f1946322589f91c9a98d205d467869 (diff) |
builder: atom: Allow atom feeds to correctly set the blog prefix.
* haunt/builder/atom.scm (post->atom-key, atom-feed, atom-feeds-by-tag):
Add #:blog-prefix keyword.
-rw-r--r-- | haunt/builder/atom.scm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/haunt/builder/atom.scm b/haunt/builder/atom.scm index 339c5ef..84f112c 100644 --- a/haunt/builder/atom.scm +++ b/haunt/builder/atom.scm @@ -1,5 +1,6 @@ ;;; Haunt --- Static site generator for GNU Guile ;;; Copyright © 2015 David Thompson <davet@gnu.org> +;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org> ;;; ;;; This file is part of Haunt. ;;; @@ -44,7 +45,7 @@ "Convert date to ISO-8601 formatted string." (date->string date "~4")) -(define (post->atom-entry site post) +(define* (post->atom-entry site post #:key (blog-prefix "")) "Convert POST into an Atom <entry> XML node." `(entry (title ,(post-ref post 'title)) @@ -53,7 +54,8 @@ ,(let ((email (post-ref post 'email))) (if email `(email ,email) '()))) (updated ,(date->string* (post-date post))) - (link (@ (href ,(string-append "/" (site-post-slug site post) ".html")) + (link (@ (href ,(string-append "/" blog-prefix + (site-post-slug site post) ".html")) (rel "alternate"))) (summary (@ (type "html")) ,(sxml->html-string (post-sxml post))))) @@ -62,7 +64,8 @@ (file-name "feed.xml") (subtitle "Recent Posts") (filter posts/reverse-chronological) - (max-entries 20)) + (max-entries 20) + (blog-prefix "")) "Return a builder procedure that renders a list of posts as an Atom feed. All arguments are optional: @@ -79,14 +82,16 @@ MAX-ENTRIES: The maximum number of posts to render in the feed" (link (@ (href ,(string-append "/" file-name)) (rel "self"))) (link (@ (href ,(site-domain site)))) - ,@(map (cut post->atom-entry site <>) + ,@(map (cut post->atom-entry site <> + #:blog-prefix blog-prefix) (take-up-to max-entries (filter posts)))) sxml->xml*))) (define* (atom-feeds-by-tag #:key (prefix "feeds/tags") (filter posts/reverse-chronological) - (max-entries 20)) + (max-entries 20) + (blog-prefix "")) "Return a builder procedure that renders an atom feed for every tag used in a post. All arguments are optional: @@ -100,6 +105,7 @@ MAX-ENTRIES: The maximum number of posts to render in each feed" ((atom-feed #:file-name (string-append prefix "/" tag ".xml") #:subtitle (string-append "Tag: " tag) #:filter filter - #:max-entries max-entries) + #:max-entries max-entries + #:blog-prefix blog-prefix) site posts))) tag-groups)))) |