summaryrefslogtreecommitdiff
path: root/examples/hakyll/hakyll.hs
blob: 53b9a4b53c8e15f4a78d2feb852f06127d0ca013 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Text.Hakyll
import Text.Hakyll.Render
import Text.Hakyll.CreateContext
import Text.Hakyll.File
import Text.Hakyll.Regex
import Control.Monad.Reader (liftIO)
import System.Directory
import Control.Monad (mapM_, liftM)
import Data.List (sort)

main = hakyll "http://jaspervdj.be/hakyll" $ do
    directory css "css"
    directory static "images"
    directory static "examples"
    directory static "reference"

    tutorials <- liftM sort $ getRecursiveContents "tutorials"
    let tutorialPage = createListing "tutorials.html"
                                     ["templates/tutorialitem.html"]
                                     (map createPage tutorials)
                                     [("title", Left "Tutorials")]
    renderChain ["templates/tutorials.html", "templates/default.html"] $ withSidebar tutorialPage

    mapM_ render' $ [ "about.markdown"
                    , "index.markdown"
                    , "philosophy.markdown"
                    , "reference.markdown"
                    , "changelog.markdown"
                    ] ++ tutorials

  where
    render' = renderChain ["templates/default.html"] . withSidebar . createPage
    withSidebar a = a `combine` createPage "sidebar.markdown"