{-# LANGUAGE OverloadedStrings #-} import Data.List (sortBy) import Data.Monoid (mappend) import Data.Ord (comparing) import Hakyll import Hakyll.Core.Item (Item(itemIdentifier)) import System.Process (readProcess) main :: IO () main = hakyllWith configuration $ do match "images/*" $ do route idRoute compile copyFileCompiler match "design/**" $ do route $ customRoute $ const "main.css" compile $ do filePath <- getResourceFilePath unsafeCompiler (readProcess "runghc" [ filePath ] "") >>= makeItem match "legumes/**" $ do route $ setExtension "html" compile $ pandocCompiler >>= loadAndApplyTemplate "templates/main.html" defaultContext >>= relativizeUrls match "index.html" $ do route idRoute let context = listField "vegetables" defaultContext (loadAll "legumes/*") `mappend` defaultContext compile $ getResourceBody >>= applyAsTemplate context >>= loadAndApplyTemplate "templates/main.html" context >>= relativizeUrls match "templates/*" $ compile templateBodyCompiler configuration :: Configuration configuration = defaultConfiguration { destinationDirectory = "public" , inMemoryCache = True }