@@ -1,13 +1,28 @@
1−import Text.Hakyll (hakyll)
2−import Text.Hakyll.File (directory)
3−import Text.Hakyll.Render (css, static, renderChain)
4−import Text.Hakyll.CreateContext (createPage, combine)
5−
6−main = hakyll "http://example.com" $ do
7− directory css "css"
8− render "about.markdown"
9− render "index.markdown"
10− render "products.markdown"
11− where
12− render = renderChain ["templates/default.html"] . withFooter . createPage
13− withFooter = flip combine $ createPage "footer.markdown"
1+{-# LANGUAGE OverloadedStrings, Arrows #-}
2+module Main where
3+
4+import Control.Monad (forM_)
5+import Control.Arrow (arr, (>>>))
6+
7+import Hakyll
8+
9+main :: IO ()
10+main = hakyll $ do
11+ -- Compress CSS
12+ route "css/*" idRoute
13+ compile "css/*" compressCssCompiler
14+
15+ -- Render static pages
16+ forM_ ["about.markdown", "index.markdown", "products.markdown"] $ \p -> do
17+ route p $ setExtension ".html"
18+ compile p $
19+ pageCompiler
20+ >>> requireA "footer.markdown" (setFieldA "footer" $ arr pageBody)
21+ >>> applyTemplateCompiler "templates/default.html"
22+ >>> relativizeUrlsCompiler
23+
24+ -- Compile footer
25+ compile "footer.markdown" pageCompiler
26+
27+ -- Read templates
28+ compile "templates/*" templateCompiler