From 111ea2e3f1b49d92670cc20fb2b7cefd94bb6cdf Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 16 Dec 2023 05:35:51 +0100 Subject: [PATCH] create RSS and Atom feeds --- src/Main.hs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 46873b7..cceec0d 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -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