From d12848d9b343bbbb2551e9bf5f23fea461805379 Mon Sep 17 00:00:00 2001 From: Lucian Mogosanu Date: Wed, 17 Jul 2013 18:14:50 +0300 Subject: [PATCH] site: compile posts --- site.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/site.hs b/site.hs index 04c614f..4073dba 100644 --- a/site.hs +++ b/site.hs @@ -4,7 +4,12 @@ import Hakyll 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 @@ -14,4 +19,12 @@ main = hakyll $ do >>= 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 -- 1.7.10.4