@@ -1,10 +1,12 @@
1+--------------------------------------------------------------------------------
12{-# LANGUAGE OverloadedStrings #-}
2−import Hakyll
3−import Control.Monad (forM_)
4−import Control.Arrow ((>>>), arr)
5−import Data.Monoid (mempty)
6−import Text.Pandoc
3+import Control.Monad (forM_)
4+import Data.Monoid (mappend)
5+import Hakyll
6+import Text.Pandoc
77
8+
9+--------------------------------------------------------------------------------
810main :: IO ()
911main = hakyllWith config $ do
1012 match "css/*" $ do
@@ -17,35 +19,38 @@ main = hakyllWith config $ do
1719 compile copyFileCompiler
1820
1921 -- Pages
20− forM_ pages $ \p -> match p $ do
22+ match "*.markdown" $ do
2123 route $ setExtension "html"
2224 compile $ pageCompiler
23− >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
24− >>> applyTemplateCompiler "templates/default.html"
25− >>> relativizeUrlsCompiler
25+ >>= requireApplyTemplate "templates/default.html" defaultContext
26+ >>= relativizeUrls
2627
2728 -- Tutorials
2829 match "tutorials/*" $ do
2930 route $ setExtension "html"
3031 compile $ pageCompilerWith defaultHakyllParserState withToc
31− >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
32− >>> applyTemplateCompiler "templates/tutorial.html"
33− >>> applyTemplateCompiler "templates/default.html"
34− >>> relativizeUrlsCompiler
32+ >>= requireApplyTemplate "templates/tutorial.html" defaultContext
33+ >>= requireApplyTemplate "templates/default.html" defaultContext
34+ >>= relativizeUrls
3535
3636 -- Tutorial list
37− match "tutorials.html" $ route idRoute
38− create "tutorials.html" $ constA mempty
39− >>> arr (setField "title" "Tutorials")
40− >>> setFieldPageList chronological
41− "templates/tutorial-item.html" "tutorials" "tutorials/*"
42− >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
43− >>> applyTemplateCompiler "templates/tutorials.html"
44− >>> applyTemplateCompiler "templates/default.html"
45− >>> relativizeUrlsCompiler
37+ match "tutorials.html" $ do
38+ route idRoute
39+ compile $ do
40+ tutorials <- requireAll "tutorials/*"
41+ itemTpl <- requireBody "templates/tutorial-item.html"
42+ list <- applyTemplateList itemTpl defaultContext $
43+ chronological tutorials
44+
45+ let tutorialsCtx =
46+ constField "title" "Tutorials" `mappend`
47+ constField "tutorials" list `mappend`
48+ defaultContext
4649
47− -- Sidebar
48− match "sidebar.markdown" $ compile pageCompiler
50+ makeItem ""
51+ >>= requireApplyTemplate "templates/tutorials.html" tutorialsCtx
52+ >>= requireApplyTemplate "templates/default.html" tutorialsCtx
53+ >>= relativizeUrls
4954
5055 -- Templates
5156 match "templates/*" $ compile templateCompiler
@@ -56,16 +61,11 @@ main = hakyllWith config $ do
5661 , writerStandalone = True
5762 }
5863
59− pages = [ "about.markdown"
60− , "changelog.markdown"
61− , "examples.markdown"
62− , "index.markdown"
63− , "philosophy.markdown"
64− , "reference.markdown"
65− ]
6664
67−config :: HakyllConfiguration
68−config = defaultHakyllConfiguration
69− { deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
65+--------------------------------------------------------------------------------
66+config :: Configuration
67+config = defaultConfiguration
68+ { verbosity = Debug
69+ , deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
7070 \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/hakyll"
7171 }