-------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} import Data.Monoid (mappend) import Hakyll -------------------------------------------------------------------------------- main :: IO () main = hakyll $ do create ["feed.xml"] $ do route idRoute compile $ do let feedCtx = postCtx `mappend` bodyField "description" posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content" renderAtom feedConfig feedCtx posts match "images/*" $ do route idRoute compile copyFileCompiler match "files/*" $ do route idRoute compile copyFileCompiler match "fonts/*" $ do route idRoute compile copyFileCompiler match "style.css" $ do route idRoute compile compressCssCompiler match "posts/*" $ do route $ setExtension "html" compile $ pandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx >>= saveSnapshot "content" >>= loadAndApplyTemplate "templates/default.html" postCtx >>= relativizeUrls match "index.html" $ do route idRoute compile $ do posts <- recentFirst =<< loadAll "posts/*" let indexCtx = listField "posts" postCtx (return posts) `mappend` defaultContext getResourceBody >>= applyAsTemplate indexCtx >>= loadAndApplyTemplate "templates/default.html" indexCtx >>= relativizeUrls match "templates/*" $ compile templateBodyCompiler -------------------------------------------------------------------------------- postCtx :: Context String postCtx = dateField "date" "%Y-%m-%d" `mappend` defaultContext feedConfig :: FeedConfiguration feedConfig = FeedConfiguration { feedTitle = "cel's dev?blog" , feedDescription = "banished technology" , feedAuthorName = "cel ❀" , feedAuthorEmail = "cel@bunny.garden" , feedRoot = "https://bunny.garden/~cel" }