2009-12-29 18:09:11 +00:00
|
|
|
module Main where
|
|
|
|
|
2010-01-19 19:42:16 +00:00
|
|
|
import Text.Hakyll (hakyll)
|
2010-01-10 20:45:36 +00:00
|
|
|
import Text.Hakyll.Render
|
|
|
|
import Text.Hakyll.Context
|
2009-12-29 18:09:11 +00:00
|
|
|
import Text.Hakyll.File (getRecursiveContents, directory)
|
2010-03-12 15:46:08 +00:00
|
|
|
import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
|
2009-12-29 18:09:11 +00:00
|
|
|
import Data.List (sort)
|
2010-03-30 17:25:22 +00:00
|
|
|
import Control.Monad (forM_, liftM)
|
2010-01-18 20:43:31 +00:00
|
|
|
import Control.Monad.Reader (liftIO)
|
2009-12-29 18:09:11 +00:00
|
|
|
import Data.Either (Either(..))
|
|
|
|
|
2010-03-12 15:46:08 +00:00
|
|
|
main = hakyll "http://example.com" $ do
|
2009-12-29 18:09:11 +00:00
|
|
|
-- Static directory.
|
|
|
|
directory css "css"
|
|
|
|
|
|
|
|
-- Find all post paths.
|
|
|
|
postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts"
|
2010-03-12 15:46:08 +00:00
|
|
|
let postPages = map createPage postPaths
|
2009-12-29 18:09:11 +00:00
|
|
|
|
|
|
|
-- Render index, including recent posts.
|
2010-03-30 17:25:22 +00:00
|
|
|
let index = createListing "index.html" ["templates/postitem.html"]
|
|
|
|
(take 3 postPages) [("title", Left "Home")]
|
2010-01-29 11:19:53 +00:00
|
|
|
renderChain ["index.html", "templates/default.html"] index
|
2009-12-29 18:09:11 +00:00
|
|
|
|
|
|
|
-- Render all posts list.
|
2010-03-30 17:25:22 +00:00
|
|
|
let posts = createListing "posts.html" ["templates/postitem.html"]
|
|
|
|
postPages [("title", Left "All posts")]
|
2010-01-29 11:19:53 +00:00
|
|
|
renderChain ["posts.html", "templates/default.html"] posts
|
2009-12-29 18:09:11 +00:00
|
|
|
|
|
|
|
-- Render all posts.
|
2010-01-18 20:43:31 +00:00
|
|
|
liftIO $ putStrLn "Generating posts..."
|
2010-03-30 17:25:22 +00:00
|
|
|
forM_ postPages $ renderChain [ "templates/post.html"
|
|
|
|
, "templates/default.html"
|
|
|
|
]
|