-------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} import Control.Monad (forM_) import Data.Monoid (mappend) import Hakyll import Text.Pandoc -------------------------------------------------------------------------------- main :: IO () main = hakyllWith config $ do match "css/*" $ do route idRoute compile compressCssCompiler -- Static directories forM_ ["images/*", "examples/*", "reference/**"] $ \f -> match f $ do route idRoute compile copyFileCompiler -- Pages match "*.markdown" $ do route $ setExtension "html" compile $ pandocCompiler >>= loadAndApplyTemplate "templates/default.html" defaultContext >>= relativizeUrls -- Tutorials match "tutorials/*" $ do route $ setExtension "html" compile $ pandocCompilerWith defaultHakyllParserState withToc >>= loadAndApplyTemplate "templates/tutorial.html" defaultContext >>= loadAndApplyTemplate "templates/default.html" defaultContext >>= relativizeUrls -- Tutorial list match "tutorials.html" $ do route idRoute compile $ do tutorials <- loadAll "tutorials/*" itemTpl <- loadBody "templates/tutorial-item.html" list <- applyTemplateList itemTpl defaultContext $ chronological tutorials let tutorialsCtx = constField "title" "Tutorials" `mappend` constField "tutorials" list `mappend` defaultContext makeItem "" >>= loadAndApplyTemplate "templates/tutorials.html" tutorialsCtx >>= loadAndApplyTemplate "templates/default.html" tutorialsCtx >>= relativizeUrls -- Templates match "templates/*" $ compile templateCompiler where withToc = defaultHakyllWriterOptions { writerTableOfContents = True , writerTemplate = "$toc$\n$body$" , writerStandalone = True } -------------------------------------------------------------------------------- config :: Configuration config = defaultConfiguration { verbosity = Debug , deployCommand = "rsync --checksum -ave 'ssh -p 2222' \ \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/hakyll" }