@@ -1,99 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module Main where
3−
4−import Prelude hiding (id)
5−import Control.Arrow ((>>>), (***), arr)
6−import Control.Category (id)
7−import Data.Monoid (mempty, mconcat)
8−
9−import Hakyll
10−
11−main :: IO ()
12−main = hakyll $ do
13− -- Compress CSS
14− match "css/*" $ do
15− route idRoute
16− compile compressCssCompiler
17−
18− -- Render posts
19− match "posts/*" $ do
20− route $ setExtension ".html"
21− compile $ pageCompiler
22− >>> arr (renderDateField "date" "%B %e, %Y" "Date unknown")
23− >>> renderTagsField "prettytags" (fromCapture "tags/*")
24− >>> applyTemplateCompiler "templates/post.html"
25− >>> applyTemplateCompiler "templates/default.html"
26− >>> relativizeUrlsCompiler
27−
28− -- Render posts list
29− match "posts.html" $ route idRoute
30− create "posts.html" $ constA mempty
31− >>> arr (setField "title" "All posts")
32− >>> requireAllA "posts/*" addPostList
33− >>> applyTemplateCompiler "templates/posts.html"
34− >>> applyTemplateCompiler "templates/default.html"
35− >>> relativizeUrlsCompiler
36−
37− -- Index
38− match "index.html" $ route idRoute
39− create "index.html" $ constA mempty
40− >>> arr (setField "title" "Home")
41− >>> requireA "tags" (setFieldA "tagcloud" (renderTagCloud'))
42− >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
43− >>> applyTemplateCompiler "templates/index.html"
44− >>> applyTemplateCompiler "templates/default.html"
45− >>> relativizeUrlsCompiler
46−
47− -- Tags
48− create "tags" $
49− requireAll "posts/*" (\_ ps -> readTags ps :: Tags String)
50−
51− -- Add a tag list compiler for every tag
52− match "tags/*" $ route $ setExtension ".html"
53− metaCompile $ require_ "tags"
54− >>> arr tagsMap
55− >>> arr (map (\(t, p) -> (tagIdentifier t, makeTagList t p)))
56−
57− -- Render RSS feed
58− match "rss.xml" $ route idRoute
59− create "rss.xml" $
60− requireAll_ "posts/*"
61− >>> mapCompiler (arr $ copyBodyToField "description")
62− >>> renderRss feedConfiguration
63−
64− -- Read templates
65− match "templates/*" $ compile templateCompiler
66− where
67− renderTagCloud' :: Compiler (Tags String) String
68− renderTagCloud' = renderTagCloud tagIdentifier 100 120
69−
70− tagIdentifier :: String -> Identifier
71− tagIdentifier = fromCapture "tags/*"
72−
73−-- | Auxiliary compiler: generate a post list from a list of given posts, and
74−-- add it to the current page under @$posts@
75−--
76−addPostList :: Compiler (Page String, [Page String]) (Page String)
77−addPostList = setFieldA "posts" $
78− arr (reverse . sortByBaseName)
79− >>> require "templates/postitem.html" (\p t -> map (applyTemplate t) p)
80− >>> arr mconcat
81− >>> arr pageBody
82−
83−makeTagList :: String
84− -> [Page String]
85− -> Compiler () (Page String)
86−makeTagList tag posts =
87− constA (mempty, posts)
88− >>> addPostList
89− >>> arr (setField "title" ("Posts tagged ‘" ++ tag ++ "’"))
90− >>> applyTemplateCompiler "templates/posts.html"
91− >>> applyTemplateCompiler "templates/default.html"
92−
93−feedConfiguration :: FeedConfiguration
94−feedConfiguration = FeedConfiguration
95− { feedTitle = "SimpleBlog RSS feed."
96− , feedDescription = "A simple demo of an RSS feed created with Hakyll."
97− , feedAuthorName = "Jasper Van der Jeugt"
98− , feedRoot = "http://example.com"
99− }