content: {-# LANGUAGE OverloadedStrings #-}
  module Main where
  
  import Prelude hiding (id)
  import Control.Category (id)
  import Control.Arrow ((>>>), (***), arr)
  import Data.Monoid (mempty, mconcat)
  
  import Hakyll
  
  main :: IO ()
  main = hakyll $ do
      -- Compress CSS
      match "css/*" $ do
          route   idRoute
          compile compressCssCompiler
      
      match "doc/*" $ do
          route idRoute
          compile copyFileCompiler
      
      match (list ["documentation.md", "about.md", "tutorial.md", "index.md"]) $ do
        route $ setExtension ".html"
        compile $ pageCompiler
          >>> applyTemplateCompiler "templates/default.html"
          >>> relativizeUrlsCompiler
      
      -- Read templates
      match "templates/*" $ compile templateCompiler
  
  -- | Auxiliary compiler: generate a post list from a list of given posts, and
  -- add it to the current page under @$posts@
  --
  addPostList :: Compiler (Page String, [Page String]) (Page String)
  addPostList = setFieldA "posts" $
      arr (reverse . sortByBaseName)
          >>> require "templates/newsitem.html" (\p t -> map (applyTemplate t) p)
          >>> arr mconcat
          >>> arr pageBody
  