From 14858277fb74c3788af1226f37b22089229edc34 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 29 Oct 2016 21:43:37 +0200 Subject: Use Hakyll to generate web pages --- Cooking.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Cooking.hs (limited to 'Cooking.hs') 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 -- cgit v1.2.3