on master help sign in
Update hakyll site to hakyll3
commit645ac84b636f1a7725f032c2eeff68214aacda64 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 12 Feb 2011, 15:16 (16 years ago) parent6e2cc76
5 files changed+64−49
examples/hakyll/css/default.css+4 examples/hakyll/hakyll.hs+44−33 examples/hakyll/sidebar.markdown+6−7 examples/hakyll/templates/default.html+7−7 examples/hakyll/tutorial.markdown+3−2
examples/hakyll/css/default.css+4
@@ -75,6 +75,10 @@ h3 {
7575 text-transform: uppercase;
7676}
7777
78+h1 a, h2 a, h3 a {
79+ text-decoration: none;
80+}
81+
7882div.column {
7983 width: 50%;
8084 float: left;
examples/hakyll/hakyll.hs+44−33
@@ -1,39 +1,50 @@
1−import Text.Hakyll
2−import Text.Hakyll.Render
3−import Text.Hakyll.File
4−import Text.Hakyll.CreateContext
5−import Control.Monad.Reader (liftIO)
6−import System.Directory
7−import Control.Monad (mapM_, forM_, liftM)
8−import Data.List (sort)
1+{-# LANGUAGE OverloadedStrings #-}
2+import Hakyll
3+import Control.Monad (forM_)
4+import Control.Arrow ((>>>), arr)
5+import Text.Pandoc (writerTableOfContents, writerTemplate, writerStandalone)
96
10−main = hakyll "http://jaspervdj.be/hakyll" $ do
11− directory css "css"
12− directory static "images"
13− directory static "examples"
14− directory static "reference"
7+main :: IO ()
8+main = hakyll $ do
9+ route "css/*" idRoute
10+ compile "css/*" defaultCompressCss
1511
16− tutorials <- liftM sort $ getRecursiveContents "tutorials"
17− let tutorialPage = createListing "tutorials.html"
18− ["templates/tutorialitem.html"]
19− (map createPage tutorials)
20− [("title", Left "Tutorials")]
21− renderChain ["templates/tutorials.html", "templates/default.html"]
22− (withSidebar tutorialPage)
12+ -- Static directories
13+ forM_ ["images/*", "examples/*", "reference/*"] $ \f -> do
14+ route f idRoute
15+ compile f defaultCopyFile
2316
24− mapM_ (render' ["templates/default.html"]) $
25− [ "about.markdown"
26− , "index.markdown"
27− , "philosophy.markdown"
28− , "reference.markdown"
29− , "changelog.markdown"
30− ]
17+ -- Pages
18+ forM_ pages $ \p -> do
19+ route p $ setExtension "html"
20+ compile p $ defaultPageRead
21+ >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
22+ >>> defaultApplyTemplate "templates/default.html"
23+ >>> defaultRelativizeUrls
3124
32− forM_ tutorials $ render' [ "templates/tutorial.html"
33− , "templates/default.html"
34− ]
25+ -- Tutorial
26+ route "tutorial.markdown" $ setExtension "html"
27+ compile "tutorial.markdown" $ pageRead
28+ >>> pageRenderPandocWith defaultParserState withToc
29+ >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
30+ >>> defaultApplyTemplate "templates/default.html"
31+ >>> defaultRelativizeUrls
3532
33+ -- Sidebar
34+ compile "sidebar.markdown" defaultPageRead
35+
36+ -- Templates
37+ compile "templates/*" defaultTemplateRead
3638 where
37− render' templates = renderChain templates . withSidebar . createPage
38− withSidebar a = a `combine` createPage "sidebar.markdown"
39−
39+ withToc = defaultWriterOptions
40+ { writerTableOfContents = True
41+ , writerTemplate = "<h2>Table of contents</h2>\n$toc$\n$body$"
42+ , writerStandalone = True
43+ }
44+
45+ pages = [ "about.markdown"
46+ , "changelog.markdown"
47+ , "index.markdown"
48+ , "philosophy.markdown"
49+ , "reference.markdown"
50+ ]
examples/hakyll/sidebar.markdown+6−7
@@ -1,9 +1,8 @@
1−--- sidebar
21## Navigation
32
4−[home]($root/index.html)
5−[philosophy]($root/philosophy.html)
6−[about]($root/about.html)
7−[tutorials]($root/tutorials.html)
8−[reference]($root/reference.html)
9−[changelog]($root/changelog.html)
3+[home](/index.html)
4+[philosophy](/philosophy.html)
5+[about](/about.html)
6+[tutorial](/tutorial.html)
7+[reference](/reference.html)
8+[changelog](/changelog.html)
examples/hakyll/templates/default.html+7−7
@@ -4,11 +4,11 @@
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>Hakyll - $title</title>
7+ <title>Hakyll - $title$</title>
88
99 <!-- Stylesheets. -->
10− <link rel="stylesheet" type="text/css" href="$root/css/default.css" />
11− <link rel="stylesheet" type="text/css" href="$root/css/syntax.css" />
10+ <link rel="stylesheet" type="text/css" href="/css/default.css" />
11+ <link rel="stylesheet" type="text/css" href="/css/syntax.css" />
1212
1313 <!-- Metadata. -->
1414 <meta name="keywords" content="hakyll,static site generator,static,site,generator,haskell,blog"/>
@@ -17,16 +17,16 @@
1717 <body>
1818 <div id="main">
1919 <div id="header">
20− <img src="$root/images/lambda.png" alt="lambda" />
21− <h1>Hakyll - $title</h1>
20+ <img src="/images/lambda.png" alt="lambda" />
21+ <h1>Hakyll - $title$</h1>
2222 </div>
2323 <!-- Sidebar. -->
2424 <div id="sidebar">
25− $sidebar
25+ $sidebar$
2626 </div>
2727
2828 <div id="content">
29− $body
29+ $body$
3030 </div>
3131
3232 <div id="footer">
examples/hakyll/tutorial.markdown+3−2
@@ -1,5 +1,6 @@
1−The Hakyll Tutorial
2−===================
1+---
2+title: Tutorial
3+---
34
45Why static websites?
56--------------------