site: compile posts
authorLucian Mogosanu <lucian.mogosanu@gmail.com>
Wed, 17 Jul 2013 15:14:50 +0000 (18:14 +0300)
committerLucian Mogosanu <lucian.mogosanu@gmail.com>
Wed, 17 Jul 2013 15:14:50 +0000 (18:14 +0300)
site.hs

diff --git a/site.hs b/site.hs
index 04c614f..4073dba 100644 (file)
--- 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