diff options
author | rekado <rekado@elephly.net> | 2013-09-20 15:46:27 +0800 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2013-09-20 15:46:27 +0800 |
commit | 743ab3108207bd9ef06cc3cc0f42aa8e15519c26 (patch) | |
tree | 1f74cdc54f78e3ee09af0ae886b3b0685f94016a /site.hs | |
parent | 81ff3989243119b568ed78593b4373f5dfa29747 (diff) |
add Atom and RSS feeds
Diffstat (limited to 'site.hs')
-rw-r--r-- | site.hs | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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 |