on master help sign in
Update brochure example to hakyll3
commitf08b2222ca756e8311c70862c8c753da007b6917 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateThu 10 Feb 2011, 12:29 (16 years ago) parent8cec091
2 files changed+26−21
examples/brochure/hakyll.hs+18−13 examples/brochure/templates/default.html+8−8
examples/brochure/hakyll.hs+18−13
@@ -1,13 +1,18 @@
1−import Text.Hakyll (hakyll)
2−import Text.Hakyll.File (directory)
3−import Text.Hakyll.Render (css, static, renderChain)
4−import Text.Hakyll.CreateContext (createPage)
5−
6−main = hakyll "http://example.com" $ do
7− directory css "css"
8− render "about.rst"
9− render "index.markdown"
10− render "code.lhs"
11− where
12− render = renderChain ["templates/default.html"]
13− . createPage
1+{-# LANGUAGE OverloadedStrings #-}
2+import Control.Arrow ((>>>))
3+import Control.Monad (forM_)
4+
5+import Hakyll
6+
7+main :: IO ()
8+main = hakyll $ do
9+ route "css/*" idRoute
10+ compile "css/*" defaultCompressCss
11+
12+ compile "templates/*" defaultTemplateRead
13+
14+ forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page -> do
15+ route page $ setExtension "html"
16+ compile page $ defaultPageRead
17+ >>> require "templates/default.html" (flip applyTemplate)
18+ >>> defaultRelativizeUrls
examples/brochure/templates/default.html+8−8
@@ -4,18 +4,18 @@
44<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
55 <head>
66 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7− <title>MyAweSomeCompany - $title</title>
8− <link rel="stylesheet" type="text/css" href="$root/css/default.css" />
9− <link rel="stylesheet" type="text/css" href="$root/css/syntax.css" />
7+ <title>MyAweSomeCompany - $title$</title>
8+ <link rel="stylesheet" type="text/css" href="/css/default.css" />
9+ <link rel="stylesheet" type="text/css" href="/css/syntax.css" />
1010 </head>
1111 <body>
12− <h1>MyAweSomeCompany - $title</h1>
12+ <h1>MyAweSomeCompany - $title$</h1>
1313 <div id="navigation">
14− <a href="$root/index.html">Home</a>
15− <a href="$root/about.html">About</a>
16− <a href="$root/code.html">Code</a>
14+ <a href="/index.html">Home</a>
15+ <a href="/about.html">About</a>
16+ <a href="/code.html">Code</a>
1717 </div>
1818
19− $body
19+ $body$
2020 </body>
2121</html>