From bbb5ceddf960681050e3d942c2f0d7fc27482d13 Mon Sep 17 00:00:00 2001 From: jamie Date: Wed, 28 May 2025 17:43:48 +0100 Subject: feat: add basic rss feed --- site.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'site.hs') diff --git a/site.hs b/site.hs index f370ed9..b116755 100644 --- a/site.hs +++ b/site.hs @@ -25,6 +25,7 @@ main = hakyll $ do route $ setExtension "html" compile $ pandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= saveSnapshot "content" >>= loadAndApplyTemplate "templates/default.html" postCtx >>= relativizeUrls @@ -42,6 +43,21 @@ main = hakyll $ do >>= loadAndApplyTemplate "templates/default.html" archiveCtx >>= relativizeUrls + create ["atom.xml"] $ do + route idRoute + compile $ do + let feedCtx = postCtx `mappend` bodyField "description" + posts <- fmap (take 10) . recentFirst =<< + loadAllSnapshots "posts/*" "content" + renderAtom feedConfiguration feedCtx posts + + create ["rss.xml"] $ do + route idRoute + compile $ do + let feedCtx = postCtx `mappend` bodyField "description" + posts <- fmap (take 10) . recentFirst =<< + loadAllSnapshots "posts/*" "content" + renderRss feedConfiguration feedCtx posts match "index.html" $ do route idRoute @@ -60,6 +76,15 @@ main = hakyll $ do -------------------------------------------------------------------------------- +feedConfiguration :: FeedConfiguration +feedConfiguration = FeedConfiguration + { feedTitle = "Posts on Skiletro.com" + , feedDescription = "Recent posts from Skiletro.com" + , feedAuthorName = "Skiletro" + , feedAuthorEmail = "19377854+skiletro@users.noreply.github.com" -- you're not getting my email that easily + , feedRoot = "https://skiletro.com" + } + postCtx :: Context String postCtx = dateField "date" "%B %e, %Y" `mappend` -- cgit v1.3.1