hakyll/data/example/site.hs

68 lines
2.2 KiB
Haskell
Raw Normal View History

2012-12-05 22:29:42 +00:00
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
2012-12-13 10:08:41 +00:00
import Hakyll
2012-12-05 22:29:42 +00:00
--------------------------------------------------------------------------------
main :: IO ()
main = hakyll $ do
match "images/*" $ do
route idRoute
compile copyFileCompiler
match "css/*" $ do
route idRoute
compile compressCssCompiler
2012-12-13 10:08:41 +00:00
match (fromList ["about.rst", "contact.markdown"]) $ do
2012-12-05 22:29:42 +00:00
route $ setExtension "html"
2012-12-15 17:02:47 +00:00
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
2012-12-05 22:29:42 +00:00
>>= relativizeUrls
2012-12-07 10:36:20 +00:00
match "posts/*" $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
2012-12-07 10:36:20 +00:00
create ["archive.html"] $ do
2012-12-13 10:08:41 +00:00
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
2012-12-13 10:08:41 +00:00
let archiveCtx =
listField "posts" postCtx (return posts) `mappend`
constField "title" "Archives" `mappend`
2012-12-13 10:08:41 +00:00
defaultContext
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
2012-12-13 10:08:41 +00:00
>>= relativizeUrls
2012-12-07 10:36:20 +00:00
match "index.html" $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
let indexCtx =
listField "posts" postCtx (return posts) `mappend`
constField "title" "Home" `mappend`
defaultContext
2012-12-13 10:08:41 +00:00
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
2012-12-07 10:36:20 +00:00
>>= relativizeUrls
2012-12-05 22:29:42 +00:00
match "templates/*" $ compile templateCompiler
2012-12-13 10:08:41 +00:00
--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y" `mappend`
defaultContext