diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-02 19:57:12 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-02 19:57:12 +0100 |
commit | ac8e89cc1904d25e118c41b441bbb4008583b78a (patch) | |
tree | e4087fcdef7ad615429d4011a35dddb18b59b81d /examples/rssblog/hakyll.hs | |
parent | ef7a0dfa0b7c15ec97ac0179aaca5aa105748868 (diff) | |
download | hakyll-ac8e89cc1904d25e118c41b441bbb4008583b78a.tar.gz |
Added another tutorial.
Diffstat (limited to 'examples/rssblog/hakyll.hs')
-rw-r--r-- | examples/rssblog/hakyll.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/rssblog/hakyll.hs b/examples/rssblog/hakyll.hs new file mode 100644 index 0000000..7ed1b8e --- /dev/null +++ b/examples/rssblog/hakyll.hs @@ -0,0 +1,34 @@ +module Main where + +import Text.Hakyll (hakyll) +import Text.Hakyll.Render (renderAndConcat, renderChain, css) +import Text.Hakyll.File (getRecursiveContents, directory) +import Text.Hakyll.Renderables (createPagePath, createCustomPage) +import Data.List (sort) +import Control.Monad (mapM_, liftM) +import Data.Either (Either(..)) + +main = hakyll $ do + -- Static directory. + directory css "css" + + -- Find all post paths. + postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts" + let renderablePosts = map createPagePath postPaths + + -- Render all posts list. + let postItems = renderAndConcat "templates/postitem.html" $ renderablePosts + renderChain ["posts.html", "templates/default.html"] $ + createCustomPage "posts.html" ("templates/postitem.html" : postPaths) + [("title", Left "All posts"), ("posts", Right postItems)] + + -- Render all posts. + putStrLn "Generating posts..." + mapM_ (renderChain ["templates/post.html", "templates/default.html"]) renderablePosts + + -- Render rss feed + let recentRSSItems = renderAndConcat "templates/rssitem.xml" $ take 3 renderablePosts + let rssPage = createCustomPage "rss.xml" + ("templates/postitem.html" : take 3 postPaths) + [("items", Right recentRSSItems)] + renderChain ["templates/rss.xml"] rssPage |