aboutsummaryrefslogtreecommitdiff
path: root/Cooking.hs
diff options
context:
space:
mode:
authorJoris2016-10-29 21:43:37 +0200
committerJoris2016-10-29 21:43:37 +0200
commit14858277fb74c3788af1226f37b22089229edc34 (patch)
treefc3c0a87429362c55673d72518e97a9d6f5bd80d /Cooking.hs
parent57c4fa462996307293e3da3068ec40ef69000e13 (diff)
downloadcooking-14858277fb74c3788af1226f37b22089229edc34.tar.gz
cooking-14858277fb74c3788af1226f37b22089229edc34.tar.bz2
cooking-14858277fb74c3788af1226f37b22089229edc34.zip
Use Hakyll to generate web pages
Diffstat (limited to 'Cooking.hs')
-rw-r--r--Cooking.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Cooking.hs b/Cooking.hs
new file mode 100644
index 0000000..a5be5a1
--- /dev/null
+++ b/Cooking.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+import Data.Monoid (mappend)
+import Hakyll
+
+main :: IO ()
+main = hakyll $ do
+ match "design/*.hs" $ do
+ route $ setExtension "css"
+ compile $ getResourceString >>= withItemBody (unixFilter "runghc" [])
+
+ match "recipes/*" $ do
+ route $ setExtension "html"
+ compile $ pandocCompiler
+ >>= loadAndApplyTemplate "templates/main.html" defaultContext
+ >>= relativizeUrls
+
+ match "index.html" $ do
+ route idRoute
+ let context =
+ listField "recipes" defaultContext (loadAll "recipes/*") `mappend`
+ defaultContext
+ compile $
+ getResourceBody
+ >>= applyAsTemplate context
+ >>= loadAndApplyTemplate "templates/main.html" context
+ >>= relativizeUrls
+
+ match "templates/*" $ compile templateBodyCompiler