@@ -108,24 +108,18 @@ code into a more general function:
108108
109109~~~~{.haskell}
110110renderPostList url title posts = do
111− let postItems = renderAndConcatWith
112− postManipulation
113− "templates/postitem.html"
114− (map createPagePath posts)
115− customPage = createCustomPage
116− url
117− ("templates/postitem.html" : posts)
118− [ ("title", Left title)
119− , ("posts", Right postItems)
120− ]
121− renderChain ["posts.html", "templates/default.html"]
122− customPage
111+ let list = createListingWith postManipulation
112+ url "templates/postitem.html"
113+ posts [("title", title)]
114+ renderChain ["posts.html", "templates/default.html"] list
123115~~~~~
124116
125−Our "render all posts" action can now be written as:
117+As you can see, `createListing` also has a `xxxWith` variant that lets you
118+specify a `ContextManipulation` to apply on every `Renderable`. Our "render all
119+posts" action can now be written as:
126120
127121~~~~~{.haskell}
128−renderPostList "posts.html" "All posts" postPaths
122+renderPostList "posts.html" "All posts" renderablePosts
129123~~~~~
130124
131125## Tag links
@@ -136,7 +130,7 @@ clickable. We can again solve this with a `ContextManipulation`. We have a
136130function that produces an url for a given tag:
137131
138132~~~~~{.haskell}
139−tagToURL tag = "/tags/" ++ removeSpaces tag ++ ".html"
133+tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
140134~~~~~
141135
142136`removeSpaces` is an auxiliary function from `Text.Hakyll.File`. Now, there is
@@ -151,6 +145,8 @@ postManipulation = renderDate "date" "%B %e, %Y" "Unknown date"
151145 . renderTagLinks tagToURL
152146~~~~~
153147
148+So, the `renderTagLinks` function replaces the `$tags` value from
149+`epic fail, random` to `<a href="$root/tags/epic-fail.html">epic fail</a>, ...`.
154150If we click a tag, we get a `404`. That's because we haven't generated the
155151post lists for every tag.
156152
@@ -159,7 +155,8 @@ post lists for every tag.
159155Hakyll provides a function called `readTagMap`. Let's inspect it's type.
160156
161157~~~~~{.haskell}
162−readTagMap String [FilePath] -> Hakyll Map String [FilePath]
158+type TagMap = Map String [FilePath]
159+readTagMap String [FilePath] -> Hakyll TagMap
163160~~~~~
164161
165162You give it a list of paths, and it creates a map that, for every tag, holds
@@ -183,7 +180,7 @@ A tag cloud is a commonly found thing on blogs. Hakyll also provides code to
183180generate a tag cloud. Let's have a look at the `renderTagCloud` function.
184181
185182~~~~~{.haskell}
186−renderTagCloud :: M.Map String [FilePath]
183+renderTagCloud :: TagMap
187184 -> (String -> String)
188185 -> Float
189186 -> Float
@@ -197,13 +194,12 @@ tag cloud back. We can add this to our index:
197194
198195~~~~~{.haskell}
199196let tagCloud = renderTagCloud tagMap tagToURL 100 200
200−...
201−createCustomPage "index.html"
202− ("templates/postitem.html" : take 3 postPaths)
203− [ ("title", Left "Home")
204− , ("posts", Right recentPosts)
205− , ("tagcloud", Left tagCloud)
206− ]
197+ index = createListingWith postManipulation "index.html"
198+ "templates/postitem.html"
199+ (take 3 renderablePosts)
200+ [ ("title", "Home")
201+ , ("tagcloud", tagCloud)
202+ ]
207203~~~~~
208204
209205## That's it