From 743ab3108207bd9ef06cc3cc0f42aa8e15519c26 Mon Sep 17 00:00:00 2001 From: rekado Date: Fri, 20 Sep 2013 15:46:27 +0800 Subject: add Atom and RSS feeds --- site.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/site.hs b/site.hs index fd7f541..350d999 100644 --- a/site.hs +++ b/site.hs @@ -13,6 +13,15 @@ config = defaultConfiguration { deployCommand = "rsync -Havz _site/ rekado@elephly.net:/srv/disk1/rekado/elephly.net" } +myFeedConfiguration :: FeedConfiguration +myFeedConfiguration = FeedConfiguration + { feedTitle = "Rekado's website" + , feedDescription = "Music, words, and hacking" + , feedAuthorName = "Rekado" + , feedAuthorEmail = "rekado+feed@elephly.net" + , feedRoot = "http://elephly.net" + } + -------------------------------------------------------------------------------- main :: IO () main = hakyllWith config $ do @@ -76,6 +85,9 @@ main = hakyllWith config $ do >>= loadAndApplyTemplate "templates/default.html" archiveCtx >>= relativizeUrls + create ["rss.xml"] $ postFeed renderRss + create ["atom.xml"] $ postFeed renderAtom + -- always show the most recent blog post create ["index.html"] $ do route idRoute @@ -108,6 +120,13 @@ photoSnippet = snippet "photo-snippet" "photo" "templates/photo.html" flattrSnippet = snippet "flattr-snippet" "flattr" "templates/flattr.html" licenseSnippet = snippet "license-snippet" "license" "templates/license.html" +postFeed renderer = do + route idRoute + compile $ do + let feedCtx = postCtx `mappend` bodyField "description" + posts <- fmap (take 10) . recentFirst =<< + loadAllSnapshots "posts/*.markdown" "content" + renderer myFeedConfiguration feedCtx posts -------------------------------------------------------------------------------- postList :: ([Item String] -> Compiler [Item String]) -> Compiler String @@ -128,6 +147,7 @@ customPandocCompiler = defaultCompiler = customPandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= saveSnapshot "content" >>= loadAndApplyTemplate "templates/default.html" postCtx >>= saveSnapshot "non-relative" >>= relativizeUrls -- cgit v1.2.3