Created
June 14, 2011 22:37
-
-
Save jaspervdj/1026111 to your computer and use it in GitHub Desktop.
Jekyll-like hakyll config. Haven't actually tested it, I need sleep.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} | |
import Hakyll | |
import Control.Arrow ((>>>)) | |
main :: IO () | |
main = hakyll $ do | |
-- Favicon | |
match "favicon.ico" copy | |
-- Images | |
match "img/**" copy | |
match "images/**" copy | |
-- Static stuff | |
match "static/**" copy | |
match "files/**" copy | |
-- CSS | |
match "css/*.css" css | |
match "style/*.css" css | |
match "stylesheets/*.css" css | |
-- Templates: load them all | |
match "templates/*" template | |
-- Posts | |
match "posts/*" post | |
-- Top-level page compile | |
match "*.markdown" topLevel | |
where | |
-- Completely static | |
copy = route idRoute >> compile copyFileCompiler | |
-- CSS directories | |
css = route (setExtension "css") >> compile compressCssCompiler | |
-- Templates | |
template = compile templateCompiler | |
-- Posts | |
post = do | |
route $ setExtension "html" | |
compile $ pageCompiler | |
>>> applyTemplateCompiler "templates/post.html" | |
>>> applyTemplateCompiler "templates/default.html" | |
>>> relativizeUrlsCompiler | |
-- Top-level pages | |
topLevel = do | |
route $ setExtension "html" | |
compile $ pageCompilerWithFields defaultHakyllParserState | |
defaultHakyllWriterOptions id topLevelFields | |
-- Add the fields we need to top-level pages | |
topLevelFields = setFieldPostList recentFirst "all-posts" | |
>>> setFieldPostList (take nRecent . recentFirst) "recent-posts" | |
>>> setFieldPostList chronological "chronological-posts" | |
-- Create a post list based on ordering/selection | |
setFieldPostList f k = setFieldPageList f | |
"templates/post-item.html" k "posts/*" | |
-- Number of most recent posts to show | |
nRecent = 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment