hakyll/web/hakyll.hs

66 lines
2.1 KiB
Haskell
Raw Normal View History

2011-02-12 14:16:42 +00:00
{-# LANGUAGE OverloadedStrings #-}
import Hakyll
import Control.Monad (forM_)
import Control.Arrow ((>>>), arr)
2011-06-13 16:26:04 +00:00
import Data.Monoid (mempty)
2011-02-12 14:21:26 +00:00
import Text.Pandoc
2010-01-02 19:47:52 +00:00
2011-02-12 14:16:42 +00:00
main :: IO ()
main = hakyll $ 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
forM_ pages $ \p -> match p $ do
route $ setExtension "html"
compile $ pageCompiler
2011-02-12 14:16:42 +00:00
>>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
2011-02-26 14:49:46 +00:00
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
2011-06-13 16:26:04 +00:00
-- Tutorials
match "tutorials/*" $ do
route $ setExtension "html"
2011-06-13 16:26:04 +00:00
compile $ pageCompilerWith defaultHakyllParserState withToc
>>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
2011-06-13 16:26:04 +00:00
>>> applyTemplateCompiler "templates/tutorial.html"
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
2011-06-13 16:26:04 +00:00
-- Tutorial list
match "tutorials.html" $ route idRoute
create "tutorials.html" $ constA mempty
>>> arr (setField "title" "Tutorials")
>>> setFieldPageList chronological
"templates/tutorial-item.html" "tutorials" "tutorials/*"
>>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
>>> applyTemplateCompiler "templates/tutorials.html"
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
2011-02-12 14:16:42 +00:00
-- Sidebar
match "sidebar.markdown" $ compile pageCompiler
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
}
pages = [ "about.markdown"
, "changelog.markdown"
2011-05-29 09:43:54 +00:00
, "examples.markdown"
2011-02-12 14:16:42 +00:00
, "index.markdown"
, "philosophy.markdown"
, "reference.markdown"
]