match "posts/*" compilePosts
match (fromList ["about.markdown"]) compilePages
create ["archive.html"] compileArchive
+ create ["rss.xml"] compileRss
match "templates/*" $ compile templateCompiler
+-- compilers go here
compileIndex :: Rules ()
compileIndex = do
route idRoute -- TODO: make a "copy to root" route?
compilePosts = do
route $ setExtension "html"
compile $ pandocCompiler
+ >>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
>>= relativizeUrls
+compileRss :: Rules ()
+compileRss = do
+ -- shamelessly stolen from
+ -- http://jaspervdj.be/hakyll/tutorials/05-snapshots-feeds.html
+ route idRoute
+ compile $ do
+ let feedCtx = postCtx `mappend` bodyField "description"
+ posts <- loadAllSnapshots "posts/*" "content"
+ >>= fmap (take 7) . recentFirst
+ renderRss tarpitFeed feedCtx posts
+
+-- post context
postCtx :: Context String
postCtx = dateField "date" "%B %e, %Y" `mappend` defaultContext
+
+-- support for RSS feeds
+tarpitFeed :: FeedConfiguration
+tarpitFeed = FeedConfiguration
+ { feedTitle = "The Tar Pit"
+ , feedDescription = "tarpit :: IO ()"
+ , feedAuthorName = "Lucian Mogoșanu"
+ , feedAuthorEmail = ""
+ , feedRoot = "http://thetarpit.org"
+ }