From 7128cc9b5f77eb40bfb0b04d74ddfe2e10a171fe Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 29 Jan 2010 12:19:53 +0100 Subject: Updated simpleblog, rssblog and tagblog examples to trunk. --- examples/tagblog/hakyll.hs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'examples/tagblog/hakyll.hs') diff --git a/examples/tagblog/hakyll.hs b/examples/tagblog/hakyll.hs index dcbb943..de1d1a0 100644 --- a/examples/tagblog/hakyll.hs +++ b/examples/tagblog/hakyll.hs @@ -4,7 +4,7 @@ import Text.Hakyll (hakyll) import Text.Hakyll.Render import Text.Hakyll.Tags (readTagMap, renderTagCloud, renderTagLinks) import Text.Hakyll.File (getRecursiveContents, directory, removeSpaces) -import Text.Hakyll.Renderables (createPagePath, createCustomPage) +import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListingWith) import Text.Hakyll.Context (ContextManipulation, renderDate) import Data.List (sort) import Data.Map (toList) @@ -20,23 +20,24 @@ main = hakyll $ do let renderablePosts = map createPagePath postPaths -- Read tag map. - tagMap <- readTagMap "postTags" postPaths + tagMap <- readTagMap "postTags" renderablePosts -- Render all posts list. - renderPostList "posts.html" "All posts" postPaths + renderPostList "posts.html" "All posts" renderablePosts -- Render post list per tag mapM_ (\(tag, posts) -> renderPostList (tagToURL tag) ("Posts tagged " ++ tag) posts) (toList tagMap) -- Render index, including recent posts. - let recentPosts = renderAndConcatWith postManipulation - ["templates/postitem.html"] - (take 3 renderablePosts) - renderChain ["index.html", "templates/default.html"] $ - createCustomPage "index.html" ("templates/postitem.html" : take 3 postPaths) - [("title", Left "Home"), ("posts", Right recentPosts), - ("tagcloud", Left $ renderTagCloud tagMap tagToURL 100 200)] + let tagCloud = renderTagCloud tagMap tagToURL 100 200 + let index = createListingWith postManipulation "index.html" + "templates/postitem.html" + (take 3 renderablePosts) + [ ("title", "Home") + , ("tagcloud", tagCloud) + ] + renderChain ["index.html", "templates/default.html"] index -- Render all posts. mapM_ (renderChainWith postManipulation @@ -61,10 +62,5 @@ main = hakyll $ do tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html" renderPostList url title posts = do - let postItems = renderAndConcatWith postManipulation - ["templates/postitem.html"] - (map createPagePath posts) - customPage = createCustomPage url - ("templates/postitem.html" : posts) - [("title", Left title), ("posts", Right postItems)] - renderChain ["posts.html", "templates/default.html"] customPage + let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)] + renderChain ["posts.html", "templates/default.html"] list -- cgit v1.2.3