@@ -4,7 +4,7 @@ import Text.Hakyll (hakyll)
44import Text.Hakyll.Render
55import Text.Hakyll.Tags (readTagMap, renderTagCloud, renderTagLinks)
66import Text.Hakyll.File (getRecursiveContents, directory, removeSpaces)
7−import Text.Hakyll.Renderables (createPagePath, createCustomPage)
7+import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListingWith)
88import Text.Hakyll.Context (ContextManipulation, renderDate)
99import Data.List (sort)
1010import Data.Map (toList)
@@ -20,23 +20,24 @@ main = hakyll $ do
2020 let renderablePosts = map createPagePath postPaths
2121
2222 -- Read tag map.
23− tagMap <- readTagMap "postTags" postPaths
23+ tagMap <- readTagMap "postTags" renderablePosts
2424
2525 -- Render all posts list.
26− renderPostList "posts.html" "All posts" postPaths
26+ renderPostList "posts.html" "All posts" renderablePosts
2727
2828 -- Render post list per tag
2929 mapM_ (\(tag, posts) -> renderPostList (tagToURL tag) ("Posts tagged " ++ tag) posts)
3030 (toList tagMap)
3131
3232 -- 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)
37+ [ ("title", "Home")
38+ , ("tagcloud", tagCloud)
39+ ]
40+ renderChain ["index.html", "templates/default.html"] index
4041
4142 -- Render all posts.
4243 mapM_ (renderChainWith postManipulation
@@ -61,10 +62,5 @@ main = hakyll $ do
6162 tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
6263
6364 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)
69− [("title", Left title), ("posts", Right postItems)]
70− renderChain ["posts.html", "templates/default.html"] customPage
65+ let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)]
66+ renderChain ["posts.html", "templates/default.html"] list