@@ -108,24 +108,18 @@ code into a more general function:
109~~~~{.haskell}
109~~~~{.haskell}
110renderPostList url title posts = do
110renderPostList url title posts = do
111− let postItems = renderAndConcatWith
112− postManipulation
111+ let list = createListingWith postManipulation
113− "templates/postitem.html"
114− (map createPagePath posts)
115− customPage = createCustomPage
117− ("templates/postitem.html" : posts)
112+ url "templates/postitem.html"
118− [ ("title", Left title)
113+ posts [("title", title)]
119− , ("posts", Right postItems)
121− renderChain ["posts.html", "templates/default.html"]
114+ renderChain ["posts.html", "templates/default.html"] list
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
125−Our "render all posts" action can now be written as:
119+posts" action can now be written as:
127~~~~~{.haskell}
121~~~~~{.haskell}
128−renderPostList "posts.html" "All posts" postPaths
122+renderPostList "posts.html" "All posts" renderablePosts
131## Tag links
125## Tag links
@@ -136,7 +130,7 @@ clickable. We can again solve this with a `ContextManipulation`. We have a
136function that produces an url for a given tag:
130function that produces an url for a given tag:
138~~~~~{.haskell}
132~~~~~{.haskell}
139−tagToURL tag = "/tags/" ++ removeSpaces tag ++ ".html"
133+tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
142`removeSpaces` is an auxiliary function from `Text.Hakyll.File`. Now, there is
136`removeSpaces` is an auxiliary function from `Text.Hakyll.File`. Now, there is
@@ -151,6 +145,8 @@ postManipulation = renderDate "date" "%B %e, %Y" "Unknown date"
151 . renderTagLinks tagToURL
145 . renderTagLinks tagToURL
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>, ...`.
154If we click a tag, we get a `404`. That's because we haven't generated the
150If we click a tag, we get a `404`. That's because we haven't generated the
155post lists for every tag.
151post lists for every tag.
@@ -159,7 +155,8 @@ post lists for every tag.
159Hakyll provides a function called `readTagMap`. Let's inspect it's type.
155Hakyll provides a function called `readTagMap`. Let's inspect it's type.
161~~~~~{.haskell}
157~~~~~{.haskell}
158+type TagMap = Map String [FilePath]
162−readTagMap String [FilePath] -> Hakyll Map String [FilePath]
159+readTagMap String [FilePath] -> Hakyll TagMap
165You give it a list of paths, and it creates a map that, for every tag, holds
162You 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
183generate a tag cloud. Let's have a look at the `renderTagCloud` function.
180generate a tag cloud. Let's have a look at the `renderTagCloud` function.
185~~~~~{.haskell}
182~~~~~{.haskell}
186−renderTagCloud :: M.Map String [FilePath]
183+renderTagCloud :: TagMap
187 -> (String -> String)
184 -> (String -> String)
@@ -197,13 +194,12 @@ tag cloud back. We can add this to our index:
198~~~~~{.haskell}
195~~~~~{.haskell}
199let tagCloud = renderTagCloud tagMap tagToURL 100 200
196let tagCloud = renderTagCloud tagMap tagToURL 100 200
200−...
197+ index = createListingWith postManipulation "index.html"
201−createCustomPage "index.html"
202− ("templates/postitem.html" : take 3 postPaths)
198+ "templates/postitem.html"
199+ (take 3 renderablePosts)
203− [ ("title", Left "Home")
200+ [ ("title", "Home")
204− , ("posts", Right recentPosts)
205− , ("tagcloud", Left tagCloud)
201+ , ("tagcloud", tagCloud)
209## That's it
205## That's it