From 22fd5291b85a294a30c7ced58becceb4eec2f789 Mon Sep 17 00:00:00 2001 From: Shaun Kerr Date: Thu, 23 Aug 2018 13:49:50 +1200 Subject: [PATCH] added feed stuffs --- site.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/site.hs b/site.hs index c12ed49..6b95a43 100644 --- a/site.hs +++ b/site.hs @@ -49,6 +49,7 @@ main = do route $ cleanRoute compile $ pandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= saveSnapshot "content" >>= loadAndApplyTemplate "templates/default.html" postCtx >>= relativizeUrls >>= cleanIndexUrls @@ -69,6 +70,24 @@ main = do match "templates/*" $ compile templateBodyCompiler + create ["atom.xml"] $ do + route idRoute + compile $ do + let feedCtx = postCtx <> + bodyField "description" + posts <- fmap (take 10) . recentFirst + =<< loadAllSnapshots "posts/*" "content" + renderAtom feedConfig feedCtx posts + + create ["rss.xml"] $ do + route idRoute + compile $ do + let feedCtx = postCtx <> + bodyField "description" + posts <- fmap (take 10) . recentFirst + =<< loadAllSnapshots "posts/*" "content" + renderRss feedConfig feedCtx posts + ctx :: Context String ctx = defaultContext <> faviconsField @@ -98,3 +117,12 @@ cleanIndex url | idx `isSuffixOf` url = take (length url - length idx) url | otherwise = url where idx = "index.html" + +feedConfig :: FeedConfiguration +feedConfig = FeedConfiguration { + feedTitle = "Regular Flolloping" + , feedDescription = "tA's Blog" + , feedAuthorName = "Shaun Kerr" + , feedAuthorEmail = "s@p7.co.nz" + , feedRoot = "https://regularflolloping.com" + }