on master help sign in
Made tutorial list dynamic.
commit36056f174f2e8641248e95ee52e4369514bf9b14 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 2 Jan 2010, 20:47 (17 years ago) parentac8e89c
7 files changed+30−20
examples/hakyll/hakyll.hs+17−8 examples/hakyll/templates/tutorialitem.html+3 examples/hakyll/templates/tutorials.html+7 examples/hakyll/tutorial1.markdown+1 examples/hakyll/tutorial2.markdown+1 examples/hakyll/tutorial3.markdown+1 examples/hakyll/tutorials.markdown−12
examples/hakyll/hakyll.hs+17−8
@@ -3,19 +3,28 @@ import Text.Hakyll.Render
33import Text.Hakyll.Renderables
44import Text.Hakyll.File
55
6−import Control.Monad(mapM_)
6+import Control.Monad (mapM_, liftM)
7+import Data.List (sort)
8+
9+import Text.Regex.Posix
710
811main = hakyll $ do
912 directory css "css"
1013 directory static "images"
1114 directory static "examples"
1215
13− mapM_ render' [ "about.markdown"
14− , "index.markdown"
15− , "tutorials.markdown"
16− , "tutorial1.markdown"
17− , "tutorial2.markdown"
18− , "tutorial3.markdown"
19− ]
16+ tutorials <- liftM (sort . filter (=~ "tutorial[0-9]*.markdown")) $ getRecursiveContents "."
17+ let tutorialList = renderAndConcat "templates/tutorialitem.html"
18+ (map createPagePath tutorials)
19+ tutorialPage = createCustomPage "tutorials.html"
20+ ("templates/tutorialitem.html" : tutorials)
21+ [ ("title", Left "Tutorials")
22+ , ("tutorials", Right tutorialList)
23+ ]
24+ renderChain ["templates/tutorials.html", "templates/default.html"] tutorialPage
25+
26+ mapM_ render' $ [ "about.markdown"
27+ , "index.markdown"
28+ ] ++ tutorials
2029
2130 where render' = renderChain ["templates/default.html"] . createPagePath
examples/hakyll/templates/tutorialitem.htmlnew file+3
@@ -0,0 +1,3 @@
1+<li>
2+ <a href="$url">$title</a> $what.
3+</li>
examples/hakyll/templates/tutorials.htmlnew file+7
@@ -0,0 +1,7 @@
1+<h2>Tutorials about hakyll</h2>
2+<p>
3+ Here is a list of tutorials I've written about hakyll:
4+</p>
5+<ul>
6+ $tutorials
7+</ul>
examples/hakyll/tutorial1.markdown+1
@@ -1,5 +1,6 @@
11---
22title: Tutorial (Part I)
3+what: explains how to create a simple brochure site
34---
45
56## Getting started
examples/hakyll/tutorial2.markdown+1
@@ -1,5 +1,6 @@
11---
22title: Tutorial (Part II)
3+what: creates a simple blog
34---
45
56## Creating a simple blog with Hakyll
examples/hakyll/tutorial3.markdown+1
@@ -1,5 +1,6 @@
11---
22title: Tutorial (Part III)
3+what: adds an RSS feed to the blog from the previous tutorial
34---
45
56## Adding RSS to our simple blog
examples/hakyll/tutorials.markdowndeleted−12
@@ -1,12 +0,0 @@
1−---
2−title: Tutorials
3−---
4−
5−## Tutorials about hakyll
6−
7−Here is a list of tutorials I've written about hakyll:
8−
9−- [Tutorial 1](tutorial1.html) explains how to create a simple brochure site.
10−- [Tutorial 2](tutorial2.html) creates a simple blog.
11−- [Tutorial 3](tutorial3.html) adds an RSS feed to the blog from the previous
12− tutorial.