From 2ac650f5be1d9e5f826145c32a8c82dbfb4b7e29 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 5 Jul 2022 20:19:26 -0400 Subject: builder: atom: Refactor using site-url. --- haunt/builder/atom.scm | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/haunt/builder/atom.scm b/haunt/builder/atom.scm index 1f90d24..9d03b2d 100644 --- a/haunt/builder/atom.scm +++ b/haunt/builder/atom.scm @@ -37,7 +37,6 @@ #:use-module (haunt utils) #:use-module (haunt html) #:use-module (haunt serve mime-types) - #:use-module (web uri) #:export (make-enclosure enclosure? enclosure-title @@ -140,21 +139,16 @@ (define* (post->atom-entry site slug->file-name post) "Convert POST into an Atom XML node." - (let ((uri (uri->string - (build-uri (site-scheme site) - #:host (site-domain site) - #:path (string-append "/" - (slug->file-name - (site-post-slug site post))))))) + (let ((url (site-url site (slug->file-name (site-post-slug site post))))) `(entry (title ,(post-ref post 'title)) - (id ,uri) + (id ,url) (author (name ,(post-ref post 'author)) ,(let ((email (post-ref post 'email))) (if email `(email ,email) '()))) (updated ,(date->string* (post-date post))) - (link (@ (href ,uri) (rel "alternate"))) + (link (@ (href ,url) (rel "alternate"))) (summary (@ (type "html")) ,(sxml->html-string (post-sxml post))) ,@(map (lambda (enclosure) @@ -191,20 +185,15 @@ MAX-ENTRIES: The maximum number of posts to render in the feed" (make-compat-slug->file-name blog-prefix)))) (lambda (site posts) - (let ((uri (uri->string - (build-uri (site-scheme site) - #:host (site-domain site) - #:path (string-append "/" file-name))))) + (let ((feed-url (site-url site file-name))) (serialized-artifact file-name `(feed (@ (xmlns "http://www.w3.org/2005/Atom")) (title ,(site-title site)) - (id ,uri) + (id ,feed-url) (subtitle ,subtitle) (updated ,(date->string* (current-date))) - (link (@ (href ,(string-append (site-domain site) - "/" file-name)) - (rel "self"))) - (link (@ (href ,(site-domain site)))) + (link (@ (href ,feed-url) (rel "self"))) + (link (@ (href ,(site-url site "/")))) ,@(map (cut post->atom-entry site slug->file-name* <>) (take-up-to max-entries (filter posts)))) sxml->xml*)))) -- cgit v1.2.3