Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't require email address for feeds #736

Merged
merged 3 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
don't require email address for feeds
  • Loading branch information
robx committed Oct 29, 2019
commit e1b5910dd2bfc451b3074a890253d88dfc6a5ca4
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
10 changes: 7 additions & 3 deletions lib/Hakyll/Web/Feed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ data FeedConfiguration = FeedConfiguration
, -- | Name of the feed author.
feedAuthorName :: String
, -- | Email of the feed author.
feedAuthorEmail :: String
feedAuthorEmail :: Maybe String
, -- | Absolute root URL of the feed site (e.g. @http://jaspervdj.be@)
feedRoot :: String
} deriving (Show, Eq)
Expand Down Expand Up @@ -97,15 +97,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 @@ -120,6 +120,10 @@ renderFeed feedTpl itemTpl config itemContext items = do
StringField s -> return s
_ -> fail "Hakyll.Web.Feed.renderFeed: Internal error"

emailField = case feedAuthorEmail config of
Nothing -> missingField
Just email -> constField "authorEmail" email
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer a new helper

optField : String -> Maybe String -> Context a

used as optField "authorEmail" (feedAuthorEmail config)?


--------------------------------------------------------------------------------
-- | Render an RSS feed using given templates with a number of items.
renderRssWithTemplates ::
Expand Down