@@ -4,7 +4,7 @@ import Text.Hakyll (hakyll)
4import Text.Hakyll.Render
4import Text.Hakyll.Render
5import Text.Hakyll.Tags (readTagMap, renderTagCloud, renderTagLinks)
5import Text.Hakyll.Tags (readTagMap, renderTagCloud, renderTagLinks)
6import Text.Hakyll.File (getRecursiveContents, directory, removeSpaces)
6import Text.Hakyll.File (getRecursiveContents, directory, removeSpaces)
7−import Text.Hakyll.Renderables (createPagePath, createCustomPage)
7+import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListingWith)
8import Text.Hakyll.Context (ContextManipulation, renderDate)
8import Text.Hakyll.Context (ContextManipulation, renderDate)
9import Data.List (sort)
9import Data.List (sort)
10import Data.Map (toList)
10import Data.Map (toList)
@@ -20,23 +20,24 @@ main = hakyll $ do
20 let renderablePosts = map createPagePath postPaths
20 let renderablePosts = map createPagePath postPaths
22 -- Read tag map.
22 -- Read tag map.
23− tagMap <- readTagMap "postTags" postPaths
23+ tagMap <- readTagMap "postTags" renderablePosts
25 -- Render all posts list.
25 -- Render all posts list.
26− renderPostList "posts.html" "All posts" postPaths
26+ renderPostList "posts.html" "All posts" renderablePosts
28 -- Render post list per tag
28 -- Render post list per tag
29 mapM_ (\(tag, posts) -> renderPostList (tagToURL tag) ("Posts tagged " ++ tag) posts)
29 mapM_ (\(tag, posts) -> renderPostList (tagToURL tag) ("Posts tagged " ++ tag) posts)
30 (toList tagMap)
30 (toList tagMap)
32 -- Render index, including recent posts.
32 -- Render index, including recent posts.
33− let recentPosts = renderAndConcatWith postManipulation
34− ["templates/postitem.html"]
35− (take 3 renderablePosts)
36− renderChain ["index.html", "templates/default.html"] $
37− createCustomPage "index.html" ("templates/postitem.html" : take 3 postPaths)
38− [("title", Left "Home"), ("posts", Right recentPosts),
39− ("tagcloud", Left $ renderTagCloud tagMap tagToURL 100 200)]
33+ let tagCloud = renderTagCloud tagMap tagToURL 100 200
34+ let index = createListingWith postManipulation "index.html"
35+ "templates/postitem.html"
36+ (take 3 renderablePosts)
38+ , ("tagcloud", tagCloud)
40+ renderChain ["index.html", "templates/default.html"] index
41 -- Render all posts.
42 -- Render all posts.
42 mapM_ (renderChainWith postManipulation
43 mapM_ (renderChainWith postManipulation
@@ -61,10 +62,5 @@ main = hakyll $ do
61 tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
62 tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
63 renderPostList url title posts = do
64 renderPostList url title posts = do
64− let postItems = renderAndConcatWith postManipulation
65− ["templates/postitem.html"]
66− (map createPagePath posts)
67− customPage = createCustomPage url
68− ("templates/postitem.html" : posts)
65+ let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)]
69− [("title", Left title), ("posts", Right postItems)]
70− renderChain ["posts.html", "templates/default.html"] customPage
66+ renderChain ["posts.html", "templates/default.html"] list