@@ -1,80 +0,0 @@
3−import Control.Arrow ((>>>), arr)
4−import Text.Hakyll (hakyll)
5−import Text.Hakyll.Render
6−import Text.Hakyll.Tags (readCategoryMap, withTagMap)
7−import Text.Hakyll.Feed (FeedConfiguration (..), renderRss)
8−import Text.Hakyll.File (getRecursiveContents, directory, removeSpaces, sortByBaseName)
9−import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
10−import Text.Hakyll.ContextManipulations (renderDate, copyValue, changeValue)
11−import Text.Hakyll.Util (link)
12−import Data.Map (toList)
13−import Control.Monad (forM_, liftM, (<=<))
14−import Data.Either (Either(..))
16−main = hakyll "http://example.com" $ do
20− -- Find all post paths.
21− postPaths <- liftM (reverse . sortByBaseName) $ getRecursiveContents "posts"
22− let renderablePosts = map ((>>> postManipulation) . createPage) postPaths
24− -- Read category map.
25− let categoryMap = readCategoryMap "categoryMap" postPaths
27− -- Render all posts list.
28− renderPostList "posts.html" "All posts" renderablePosts
30− -- Render post list per category
31− let renderListForCategory category posts =
32− renderPostList (categoryToUrl category) ("Posts about " ++ category)
33− (map (>>> postManipulation) posts)
34− withTagMap categoryMap renderListForCategory
36− -- Render index, including recent posts.
37− let categoryList' = categoryMap >>> categoryList
38− let index = createListing "index.html"
39− ["templates/postitem.html"]
40− (take 3 renderablePosts)
41− [ ("title", Left "Home")
42− , ("categories", Right $ categoryList')
44− renderChain ["index.html", "templates/default.html"] index
47− forM_ renderablePosts $ renderChain [ "templates/post.html"
48− , "templates/default.html"
52− renderRss myFeedConfiguration $
53− map (>>> copyValue "body" "description") (take 3 renderablePosts)
56− postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
57− >>> renderCategoryLink
60− changeValue "category" (\c -> link c $ categoryToUrl c)
62− categoryToUrl c = "$root/categories/" ++ removeSpaces c ++ ".html"
64− categoryList = arr $ uncurry categoryListItem <=< toList
66− categoryListItem category posts =
67− "<li>" ++ link category (categoryToUrl category)
68− ++ " - " ++ show (length posts) ++ " items.</li>"
70− renderPostList url title posts = do
71− let list = createListing url ["templates/postitem.html"]
72− posts [("title", Left title)]
73− renderChain ["posts.html", "templates/default.html"] list
75−myFeedConfiguration = FeedConfiguration
76− { feedUrl = "rss.xml"
77− , feedTitle = "SimpleBlog RSS feed."
78− , feedDescription = "A simple demo of an RSS feed created with Hakyll."
79− , feedAuthorName = "Jasper Van der Jeugt"