From 8b0a398a82afdb0a03b24fd0a635b9894d8909fc Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 11 Feb 2023 20:38:43 +0100 Subject: [PATCH] don't require email address for feeds (#736) Use empty string rather than Maybe for backwards-compat Co-authored-by: Jasper Van der Jeugt --- data/templates/atom.xml | 2 ++ lib/Hakyll/Web/Feed.hs | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/data/templates/atom.xml b/data/templates/atom.xml index ef1faef57..1143a79e7 100644 --- a/data/templates/atom.xml +++ b/data/templates/atom.xml @@ -6,7 +6,9 @@ $root$$url$ $authorName$ + $if(authorEmail)$ $authorEmail$ + $endif$ $updated$ $body$ diff --git a/lib/Hakyll/Web/Feed.hs b/lib/Hakyll/Web/Feed.hs index 60a662c66..fd1516fcf 100644 --- a/lib/Hakyll/Web/Feed.hs +++ b/lib/Hakyll/Web/Feed.hs @@ -73,7 +73,8 @@ data FeedConfiguration = FeedConfiguration feedDescription :: String , -- | Name of the feed author. feedAuthorName :: String - , -- | Email of the feed author. + , -- | Email of the feed author. Set this to the empty String to leave out + -- the email address. feedAuthorEmail :: String , -- | Absolute root URL of the feed site (e.g. @http://jaspervdj.be@) feedRoot :: String @@ -102,7 +103,7 @@ renderFeed feedTpl itemTpl config itemContext items = do [ itemContext , constField "root" (feedRoot config) , constField "authorName" (feedAuthorName config) - , constField "authorEmail" (feedAuthorEmail config) + , emailField ] feedContext = mconcat @@ -110,7 +111,7 @@ renderFeed feedTpl itemTpl config itemContext items = do , constField "title" (feedTitle config) , constField "description" (feedDescription config) , constField "authorName" (feedAuthorName config) - , constField "authorEmail" (feedAuthorEmail config) + , emailField , constField "root" (feedRoot config) , urlField "url" , updatedField @@ -125,6 +126,10 @@ renderFeed feedTpl itemTpl config itemContext items = do StringField s -> return s _ -> fail "Hakyll.Web.Feed.renderFeed: Internal error" + emailField = case feedAuthorEmail config of + "" -> missingField + email -> constField "authorEmail" email + -------------------------------------------------------------------------------- -- | Render an RSS feed using given templates with a number of items. renderRssWithTemplates ::