-
Notifications
You must be signed in to change notification settings - Fork 2
/
site.hs
107 lines (102 loc) · 4.19 KB
/
site.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll
import Debug.Trace
--------------------------------------------------------------------------------
main :: IO ()
main =
hakyll $ do
match "images/*" $ do
route idRoute
compile copyFileCompiler
match "css/*" $ do
route idRoute
compile compressCssCompiler
match "blocks/sites/*.md" $ do
route $
composeRoutes
(gsubRoute "blocks/sites/" (const ""))
(setExtension "html")
compile $
pandocCompiler >>=
loadAndApplyTemplate "templates/default.html" defaultContext >>=
relativizeUrls
match "posts/*" $ do
route $ setExtension "html"
compile $
pandocCompiler >>= loadAndApplyTemplate "templates/post.html" postCtx >>=
loadAndApplyTemplate "templates/default.html" postCtx >>=
relativizeUrls
match "blocks/**.md" $ compile pandocCompiler
create ["about.html"] $ do
route idRoute
compile $ do
about <- thesesCompiler "blocks/about/*.md"
let aboutCtx =
constField "title" "Über uns" `mappend` constField "about" about `mappend`
defaultContext
makeItem "" >>= loadAndApplyTemplate "templates/about.html" aboutCtx >>=
loadAndApplyTemplate "templates/default.html" aboutCtx >>=
relativizeUrls
create ["mitmachen.html"] $ do
route idRoute
compile $ do
articles <- thesesCompiler "blocks/mitmachen/*.md"
let ctx =
constField "title" "Mitmachen" `mappend` constField "articles" articles `mappend`
defaultContext
makeItem "" >>= loadAndApplyTemplate "templates/mitmachen.html" ctx >>=
loadAndApplyTemplate "templates/default.html" ctx >>=
relativizeUrls
create ["wahlprogramm.html"] $ do
route idRoute
compile $ do
wahlprogramm <- thesesCompiler "blocks/wahlprogramm/*.md"
let wahlprogrammCtx =
constField "title" "Wahlprogramm" `mappend` constField "wahlprogramm" wahlprogramm `mappend`
defaultContext
makeItem "" >>= loadAndApplyTemplate "templates/wahlprogramm.html" wahlprogrammCtx >>=
loadAndApplyTemplate "templates/default.html" wahlprogrammCtx >>=
relativizeUrls
create ["datenschutz.html"] $ do
route idRoute
compile $ do
datenschutz <- thesesCompiler "blocks/datenschutz/*.md"
let datenschutzCtx =
constField "title" "Datenschutz" `mappend` constField "datenschutz" datenschutz `mappend`
defaultContext
makeItem "" >>= loadAndApplyTemplate "templates/datenschutz.html" datenschutzCtx >>=
loadAndApplyTemplate "templates/default.html" datenschutzCtx >>=
relativizeUrls
create ["impressum.html"] $ do
route idRoute
compile $ do
impressum <- thesesCompiler "blocks/impressum/*.md"
let impressumCtx =
constField "title" "Impressum" `mappend` constField "impressum" impressum `mappend`
defaultContext
makeItem "" >>= loadAndApplyTemplate "templates/impressum.html" impressumCtx >>=
loadAndApplyTemplate "templates/default.html" impressumCtx >>=
relativizeUrls
create ["index.html"] $ do
route idRoute
compile $ do
theses <- thesesCompiler "blocks/theses/*.md"
let indexCtx =
constField "title" "Home" `mappend` constField "theses" theses `mappend`
defaultContext
makeItem "" >>= loadAndApplyTemplate "templates/index.html" indexCtx >>=
loadAndApplyTemplate "templates/default.html" indexCtx >>=
relativizeUrls
match "templates/*" $ compile templateBodyCompiler
--------------------------------------------------------------------------------
thesesCompiler :: Pattern -> Compiler String
thesesCompiler p = do
theses <- loadAll p
thesisTemplate <- loadBody "templates/thesis.html"
applyTemplateList thesisTemplate defaultContext theses
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y" `mappend`
defaultContext