create RSS and Atom feeds

This commit is contained in:
nek0 2023-12-16 05:35:51 +01:00
parent d40b04a5e3
commit 111ea2e3f1

View file

@ -110,6 +110,20 @@ main = do
defaultCtx full
>>= relativizeUrls
create ["atom.xml"] $ do
route idRoute
compile $ do
loadAllSnapshots "site/posts/*.md" "content"
>>= recentFirst
>>= renderAtom feedConf feedCtx
create ["rss.xml"] $ do
route idRoute
compile $ do
loadAllSnapshots "site/posts/*.md" "content"
>>= recentFirst
>>= renderRss feedConf feedCtx
--------------------------------------------------------------------------------
myRoute :: Routes
@ -135,6 +149,25 @@ config = defaultConfiguration
--------------------------------------------------------------------------------
feedCtx :: Context String
feedCtx = mconcat
[ bodyField "description"
, defaultContext
]
--------------------------------------------------------------------------------
feedConf :: FeedConfiguration
feedConf = FeedConfiguration
{ feedTitle = "Chaosone news"
, feedDescription = "News from eastern european hackerspaces"
, feedAuthorName = "Chaoszone members"
, feedAuthorEmail = "nek0@chaoszone.cz"
, feedRoot = "https://chaoszone.cz"
}
--------------------------------------------------------------------------------
sortIdentifiersByDate :: [Identifier] -> [Identifier]
sortIdentifiersByDate =
sortBy byDate