2010-01-02 18:57:12 +00:00
|
|
|
module Main where
|
|
|
|
|
2010-01-18 20:43:31 +00:00
|
|
|
import Control.Monad.Reader (liftIO)
|
|
|
|
import Text.Hakyll (hakyll, defaultHakyllConfiguration)
|
2010-01-02 18:57:12 +00:00
|
|
|
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(..))
|
|
|
|
|
2010-01-18 20:43:31 +00:00
|
|
|
main = hakyll defaultHakyllConfiguration $ do
|
2010-01-02 18:57:12 +00:00
|
|
|
-- Static directory.
|
|
|
|
directory css "css"
|
|
|
|
|
|
|
|
-- Find all post paths.
|
|
|
|
postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts"
|
|
|
|
let renderablePosts = map createPagePath postPaths
|
|
|
|
|
2010-01-08 11:41:58 +00:00
|
|
|
-- Render index, including recent posts.
|
2010-01-18 20:43:31 +00:00
|
|
|
let recentPosts = renderAndConcat ["templates/postitem.html"] $ take 3 renderablePosts
|
2010-01-08 11:41:58 +00:00
|
|
|
renderChain ["index.html", "templates/default.html"] $
|
|
|
|
createCustomPage "index.html" ("templates/postitem.html" : take 3 postPaths)
|
|
|
|
[("title", Left "Home"), ("posts", Right recentPosts)]
|
|
|
|
|
2010-01-02 18:57:12 +00:00
|
|
|
-- Render all posts list.
|
2010-01-18 20:43:31 +00:00
|
|
|
let postItems = renderAndConcat ["templates/postitem.html"] $ renderablePosts
|
2010-01-02 18:57:12 +00:00
|
|
|
renderChain ["posts.html", "templates/default.html"] $
|
|
|
|
createCustomPage "posts.html" ("templates/postitem.html" : postPaths)
|
|
|
|
[("title", Left "All posts"), ("posts", Right postItems)]
|
|
|
|
|
|
|
|
-- Render all posts.
|
2010-01-18 20:43:31 +00:00
|
|
|
liftIO $ putStrLn "Generating posts..."
|
2010-01-02 18:57:12 +00:00
|
|
|
mapM_ (renderChain ["templates/post.html", "templates/default.html"]) renderablePosts
|
|
|
|
|
|
|
|
-- Render rss feed
|
2010-01-18 20:43:31 +00:00
|
|
|
let recentRSSItems = renderAndConcat ["templates/rssitem.xml"] $ take 3 renderablePosts
|
2010-01-02 18:57:12 +00:00
|
|
|
let rssPage = createCustomPage "rss.xml"
|
|
|
|
("templates/postitem.html" : take 3 postPaths)
|
|
|
|
[("items", Right recentRSSItems)]
|
|
|
|
renderChain ["templates/rss.xml"] rssPage
|