aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2016-05-25 14:31:53 +0200
committerJoris2017-07-25 00:36:39 +0200
commit7091d40b31d4e9fe32ab15b865397e9abf0ba5d8 (patch)
tree237d92ecd75edf3a875b08921ea5e5eae8eac085 /src
Init with potimarron page
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs
new file mode 100644
index 0000000..b9ba49c
--- /dev/null
+++ b/src/Main.hs
@@ -0,0 +1,47 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+import Data.List (sortBy)
+import Data.Monoid (mappend)
+import Data.Ord (comparing)
+
+import Hakyll
+import Hakyll.Core.Item (Item(itemIdentifier))
+import System.Process (readProcess)
+
+main :: IO ()
+main = hakyllWith configuration $ do
+ match "images/*" $ do
+ route idRoute
+ compile copyFileCompiler
+
+ match "design/**" $ do
+ route $ customRoute $ const "main.css"
+ compile $ do
+ filePath <- getResourceFilePath
+ unsafeCompiler (readProcess "runghc" [ filePath ] "")
+ >>= makeItem
+
+ match "legumes/**" $ do
+ route $ setExtension "html"
+ compile $ pandocCompiler
+ >>= loadAndApplyTemplate "templates/main.html" defaultContext
+ >>= relativizeUrls
+
+ match "index.html" $ do
+ route idRoute
+ let context =
+ listField "vegetables" defaultContext (loadAll "legumes/*") `mappend`
+ defaultContext
+ compile $
+ getResourceBody
+ >>= applyAsTemplate context
+ >>= loadAndApplyTemplate "templates/main.html" context
+ >>= relativizeUrls
+
+ match "templates/*" $ compile templateBodyCompiler
+
+configuration :: Configuration
+configuration = defaultConfiguration
+ { destinationDirectory = "public"
+ , inMemoryCache = True
+ }