@@ -0,0 +1,100 @@
1+-- | This module provides a simple default configuration which behaves similar
2+-- to the Jekyll static site generator.
4+-- <http://jekyllrb.com/>
6+-- The idea is that you don't have to write your configuration yourself: you
7+-- just follow some conventions, and Hakyll does the rest.
9+{-# LANGUAGE OverloadedStrings #-}
10+{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
11+module Hakyll.Configs.SmallBlog
12+ ( SmallBlogConfiguration
13+ , defaultSmallBlogConfiguration
18+import Control.Arrow ((>>>))
22+-- | Configuration datatype for the 'smallBlog' ruleset
24+data SmallBlogConfiguration = SmallBlogConfiguration
25+ { -- | Number of recent posts that are available
26+ numberOfRecentPosts :: Int
29+-- | Defaults for 'SmallBlogConfiguration'
31+defaultSmallBlogConfiguration :: SmallBlogConfiguration
32+defaultSmallBlogConfiguration = SmallBlogConfiguration
33+ { numberOfRecentPosts = 3
36+-- | A default configuration for a small blog
39+smallBlog = smallBlogWith defaultSmallBlogConfiguration
41+-- | Version of 'smallBlog' which allows setting a config
43+smallBlogWith :: SmallBlogConfiguration -> Rules
44+smallBlogWith conf = do
45+ -- Images and static files
46+ ["favicon.ico"] --> copy
47+ ["img/**", "images/**"] --> copy
48+ ["static/**", "files/**"] --> copy
51+ ["css/*.css", "style/*.css", "stylesheets/*.css"] --> css
54+ ["templates/*"] --> template
60+ ["*.markdown", "*.html", "*.rst", "*.lhs"] --> topLevel
62+ -- Useful combinator here
63+ xs --> f = mapM_ (\p -> match p $ f) xs
66+ copy = route idRoute >> compile copyFileCompiler
69+ css = route (setExtension "css") >> compile compressCssCompiler
72+ template = compile templateCompiler
76+ route $ setExtension "html"
77+ compile $ pageCompiler
78+ >>> applyTemplateCompiler "templates/post.html"
79+ >>> applyTemplateCompiler "templates/default.html"
80+ >>> relativizeUrlsCompiler
84+ route $ setExtension "html"
85+ compile $ pageCompilerWithFields defaultHakyllParserState
86+ defaultHakyllWriterOptions id topLevelFields
87+ >>> applyTemplateCompiler "templates/default.html"
88+ >>> relativizeUrlsCompiler
90+ -- Add the fields we need to top-level pages
91+ topLevelFields = setFieldPostList recentFirst "allPosts"
92+ >>> setFieldPostList (take nRecent . recentFirst) "recentPosts"
93+ >>> setFieldPostList chronological "chronologicalPosts"
95+ -- Create a post list based on ordering/selection
96+ setFieldPostList f k = setFieldPageList f
97+ "templates/post-item.html" k "posts/*"
99+ -- Number of most recent posts to show
100+ nRecent = numberOfRecentPosts conf