@@ -1,101 +0,0 @@
1−-- | This module provides a simple default configuration which behaves similar
2−-- to the Jekyll static site generator.
3−--
4−-- <http://jekyllrb.com/>
5−--
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.
8−--
9−{-# LANGUAGE OverloadedStrings #-}
10−{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
11−module Hakyll.Configs.SmallBlog
12− ( SmallBlogConfiguration
13− , defaultSmallBlogConfiguration
14− , smallBlog
15− , smallBlogWith
16− ) where
17−
18−import Control.Arrow ((>>>))
19−
20−import Hakyll
21−
22−-- | Configuration datatype for the 'smallBlog' ruleset
23−--
24−data SmallBlogConfiguration = SmallBlogConfiguration
25− { -- | Number of recent posts that are available
26− numberOfRecentPosts :: Int
27− } deriving (Show)
28−
29−-- | Defaults for 'SmallBlogConfiguration'
30−--
31−defaultSmallBlogConfiguration :: SmallBlogConfiguration
32−defaultSmallBlogConfiguration = SmallBlogConfiguration
33− { numberOfRecentPosts = 3
34− }
35−
36−-- | A default configuration for a small blog
37−--
38−smallBlog :: Rules
39−smallBlog = smallBlogWith defaultSmallBlogConfiguration
40−
41−-- | Version of 'smallBlog' which allows setting a config
42−--
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
49− ["js/**"] --> copy
50−
51− -- CSS files
52− ["css/*.css", "style/*.css", "stylesheets/*.css"] --> css
53−
54− -- All templates
55− ["templates/*"] --> template
56−
57− -- "Dynamic" content
58− ["posts/*"] --> post
59−
60− -- Top-level pages
61− ["*.markdown", "*.html", "*.rst", "*.lhs"] --> topLevel
62− where
63− -- Useful combinator here
64− xs --> f = mapM_ (\p -> match p $ f) xs
65−
66− -- Completely static
67− copy = route idRoute >> compile copyFileCompiler
68−
69− -- CSS directories
70− css = route (setExtension "css") >> compile compressCssCompiler
71−
72− -- Templates
73− template = compile templateCompiler
74−
75− -- Posts
76− post = do
77− route $ setExtension "html"
78− compile $ pageCompiler
79− >>> applyTemplateCompiler "templates/post.html"
80− >>> applyTemplateCompiler "templates/default.html"
81− >>> relativizeUrlsCompiler
82−
83− -- Top-level pages
84− topLevel = do
85− route $ setExtension "html"
86− compile $ pageCompilerWithFields defaultHakyllParserState
87− defaultHakyllWriterOptions id topLevelFields
88− >>> applyTemplateCompiler "templates/default.html"
89− >>> relativizeUrlsCompiler
90−
91− -- Add the fields we need to top-level pages
92− topLevelFields = setFieldPostList recentFirst "allPosts"
93− >>> setFieldPostList (take nRecent . recentFirst) "recentPosts"
94− >>> setFieldPostList chronological "chronologicalPosts"
95−
96− -- Create a post list based on ordering/selection
97− setFieldPostList f k = setFieldPageList f
98− "templates/post-item.html" k "posts/*"
99−
100− -- Number of most recent posts to show
101− nRecent = numberOfRecentPosts conf