create RSS and Atom feeds

This commit is contained in:
nek0 2023-12-16 05:35:51 +01:00
parent d40b04a5e3
commit 111ea2e3f1
1 changed files with 33 additions and 0 deletions

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