main :: IO ()
main = hakyll $ do
- match "index.html" $ do
+ match "index.html" compileIndex
+ match "posts/*" compilePosts
+ match "templates/*" $ compile templateCompiler
+
+compileIndex :: Rules ()
+compileIndex = do
route idRoute -- TODO: make a "copy to root" route?
compile $ do
let indexCtx = defaultContext
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
- match "templates/*" $ compile templateCompiler
+compilePosts :: Rules ()
+compilePosts = do
+ route $ setExtension "html"
+ compile $ pandocCompiler
+ >>= loadAndApplyTemplate "templates/default.html" postCtx
+ >>= relativizeUrls
+
+postCtx :: Context String
+postCtx = dateField "date" "$B %e, %Y" `mappend` defaultContext