-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsite.hs
More file actions
108 lines (87 loc) · 3.39 KB
/
site.hs
File metadata and controls
108 lines (87 loc) · 3.39 KB
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
108
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid ((<>))
import Hakyll
--------------------------------------------------------------------------------
siteHost :: String
siteHost = "http:://matrixwood.netlify.com"
siteName :: String
siteName = "matrixwood"
feedConfiguration :: FeedConfiguration
feedConfiguration = FeedConfiguration
{ feedTitle = siteName
, feedDescription = "RSS feed for matrixwood.netlify.com."
, feedAuthorName = "canftin.com Collaborators"
, feedAuthorEmail = "wwc7033@gmail.com"
, feedRoot = "http:://matrixwood.netlify.com"
}
--------------------------------------------------------------------------------
main :: IO ()
main = hakyll $ do
match "images/**" $ do
route idRoute
compile copyFileCompiler
match "js/**" $ do
route idRoute
compile copyFileCompiler
match "css/*" $ do
route idRoute
compile compressCssCompiler
match "downloads/*" $ do
route idRoute
compile copyFileCompiler
match (fromList ["projects.md", "about.md"]) $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
match "posts/*" $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
create ["writing.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
let writingCtx =
listField "posts" postCtx (return posts) <>
constField "title" "Writing" <>
defaultContext
makeItem ""
>>= loadAndApplyTemplate "templates/writing.html" writingCtx
>>= loadAndApplyTemplate "templates/default.html" writingCtx
>>= relativizeUrls
create ["rss.xml"] $ do
route idRoute
compile $ do
let feedCtx = postCtx `mappend` bodyField "description"
posts <- fmap (take 10) . recentFirst =<<
loadAllSnapshots "posts/*" "content"
renderRss feedConfiguration feedCtx posts
>>= cleanIndexHtmls
match "index.html" $ do
route idRoute
compile $ do
posts <- (recentFirst =<< loadAll "posts/*")
let indexCtx =
listField "posts" postCtx (return (take 5 posts)) <>
constField "title" "Home" <>
defaultContext
getResourceBody
>>= loadAndApplyTemplate "templates/index.html" indexCtx
>>= relativizeUrls
match "templates/*" $ compile templateBodyCompiler
--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y" <>
teaserField "teaser" "content" <>
defaultContext
cleanIndexHtmls :: Item String -> Compiler (Item String)
cleanIndexHtmls = return . fmap (replaceAll pattern replacement)
where
pattern = "/index.html"
replacement = const "/"