added feed stuffs

This commit is contained in:
Shaun Kerr 2018-08-23 13:49:50 +12:00
parent 23b5fdc920
commit 22fd5291b8

28
site.hs
View File

@ -49,6 +49,7 @@ main = do
route $ cleanRoute route $ cleanRoute
compile $ pandocCompiler compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx >>= loadAndApplyTemplate "templates/post.html" postCtx
>>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/default.html" postCtx >>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls >>= relativizeUrls
>>= cleanIndexUrls >>= cleanIndexUrls
@ -69,6 +70,24 @@ main = do
match "templates/*" $ compile templateBodyCompiler 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 :: Context String
ctx = defaultContext <> ctx = defaultContext <>
faviconsField faviconsField
@ -98,3 +117,12 @@ cleanIndex url
| idx `isSuffixOf` url = take (length url - length idx) url | idx `isSuffixOf` url = take (length url - length idx) url
| otherwise = url | otherwise = url
where idx = "index.html" 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"
}