hakyll/web/site.hs

72 lines
2.4 KiB
Haskell
Raw Normal View History

2012-12-05 15:54:57 +00:00
--------------------------------------------------------------------------------
2011-02-12 14:16:42 +00:00
{-# LANGUAGE OverloadedStrings #-}
2012-12-05 15:54:57 +00:00
import Control.Monad (forM_)
import Data.Monoid (mappend)
import Hakyll
import Text.Pandoc
2010-01-02 19:47:52 +00:00
2012-12-05 15:54:57 +00:00
--------------------------------------------------------------------------------
2011-02-12 14:16:42 +00:00
main :: IO ()
2011-06-16 09:51:55 +00:00
main = hakyllWith config $ do
match "css/*" $ do
route idRoute
compile compressCssCompiler
2011-02-12 14:16:42 +00:00
-- Static directories
forM_ ["images/*", "examples/*", "reference/**"] $ \f -> match f $ do
route idRoute
compile copyFileCompiler
2010-01-02 19:47:52 +00:00
2011-02-12 14:16:42 +00:00
-- Pages
2012-12-05 15:54:57 +00:00
match "*.markdown" $ do
route $ setExtension "html"
2012-12-16 09:05:21 +00:00
compile $ pandocCompiler
2012-12-14 09:42:30 +00:00
>>= loadAndApplyTemplate "templates/default.html" defaultContext
2012-12-05 15:54:57 +00:00
>>= relativizeUrls
2011-06-13 16:26:04 +00:00
-- Tutorials
match "tutorials/*" $ do
route $ setExtension "html"
2012-12-16 09:05:21 +00:00
compile $ pandocCompilerWith defaultHakyllParserState withToc
2012-12-14 09:42:30 +00:00
>>= loadAndApplyTemplate "templates/tutorial.html" defaultContext
>>= loadAndApplyTemplate "templates/default.html" defaultContext
2012-12-05 15:54:57 +00:00
>>= relativizeUrls
2011-06-13 16:26:04 +00:00
-- Tutorial list
2012-12-05 15:54:57 +00:00
match "tutorials.html" $ do
route idRoute
compile $ do
2012-12-14 09:42:30 +00:00
tutorials <- loadAll "tutorials/*"
itemTpl <- loadBody "templates/tutorial-item.html"
2012-12-05 15:54:57 +00:00
list <- applyTemplateList itemTpl defaultContext $
chronological tutorials
let tutorialsCtx =
constField "title" "Tutorials" `mappend`
constField "tutorials" list `mappend`
defaultContext
2011-06-13 16:26:04 +00:00
2012-12-05 15:54:57 +00:00
makeItem ""
2012-12-14 09:42:30 +00:00
>>= loadAndApplyTemplate "templates/tutorials.html" tutorialsCtx
>>= loadAndApplyTemplate "templates/default.html" tutorialsCtx
2012-12-05 15:54:57 +00:00
>>= relativizeUrls
2011-02-12 14:16:42 +00:00
-- Templates
match "templates/*" $ compile templateCompiler
where
2011-02-12 14:21:26 +00:00
withToc = defaultHakyllWriterOptions
2011-02-12 14:16:42 +00:00
{ writerTableOfContents = True
2011-06-13 16:26:04 +00:00
, writerTemplate = "$toc$\n$body$"
2011-02-12 14:16:42 +00:00
, writerStandalone = True
}
2011-06-16 09:51:55 +00:00
2012-12-05 15:54:57 +00:00
--------------------------------------------------------------------------------
config :: Configuration
config = defaultConfiguration
{ verbosity = Debug
, deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
2012-12-17 16:28:12 +00:00
\_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
2011-06-16 09:51:55 +00:00
}