Skip to content

Commit

Permalink
don't require email address for feeds (jaspervdj#736)
Browse files Browse the repository at this point in the history
Use empty string rather than Maybe for backwards-compat

Co-authored-by: Jasper Van der Jeugt <m@jaspervdj.be>
  • Loading branch information
robx and jaspervdj authored Feb 11, 2023
1 parent 8cdce62 commit 8b0a398
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data/templates/atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<id>$root$$url$</id>
<author>
<name>$authorName$</name>
$if(authorEmail)$
<email>$authorEmail$</email>
$endif$
</author>
<updated>$updated$</updated>
$body$
Expand Down
11 changes: 8 additions & 3 deletions lib/Hakyll/Web/Feed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -102,15 +103,15 @@ renderFeed feedTpl itemTpl config itemContext items = do
[ itemContext
, constField "root" (feedRoot config)
, constField "authorName" (feedAuthorName config)
, constField "authorEmail" (feedAuthorEmail config)
, emailField
]

feedContext = mconcat
[ bodyField "body"
, constField "title" (feedTitle config)
, constField "description" (feedDescription config)
, constField "authorName" (feedAuthorName config)
, constField "authorEmail" (feedAuthorEmail config)
, emailField
, constField "root" (feedRoot config)
, urlField "url"
, updatedField
Expand All @@ -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 ::
Expand Down

0 comments on commit 8b0a398

Please sign in to comment.