aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs
new file mode 100644
index 0000000..e5f92b9
--- /dev/null
+++ b/src/Main.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+import Data.List (sortBy)
+import Data.Monoid (mappend)
+import Data.Ord (comparing)
+
+import Hakyll
+import Hakyll.Core.Item (Item(itemIdentifier))
+
+main :: IO ()
+main = hakyllWith configuration $ do
+ match "images/*" $ do
+ route idRoute
+ compile copyFileCompiler
+
+ 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
+
+configuration :: Configuration
+configuration = defaultConfiguration
+ { destinationDirectory = "public"
+ , inMemoryCache = True
+ }