on master help sign in
Made tutorial list dynamic.
36056f1Jasper Van der Jeugt
examples/hakyll/hakyll.hs+17−8
@@ -3,19 +3,28 @@ import Text.Hakyll.Render
3import Text.Hakyll.Renderables
3import Text.Hakyll.Renderables
4import Text.Hakyll.File
4import Text.Hakyll.File
5
5
6−import Control.Monad(mapM_)
6+import Control.Monad (mapM_, liftM)
7+import Data.List (sort)
8+
9+import Text.Regex.Posix
7
10
8main = hakyll $ do
11main = hakyll $ do
9 directory css "css"
12 directory css "css"
10 directory static "images"
13 directory static "images"
11 directory static "examples"
14 directory static "examples"
12
15
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+
13− mapM_ render' [ "about.markdown"
26+ mapM_ render' $ [ "about.markdown"
14− , "index.markdown"
27+ , "index.markdown"
15− , "tutorials.markdown"
28+ ] ++ tutorials
16− , "tutorial1.markdown"
17− , "tutorial2.markdown"
18− , "tutorial3.markdown"
19− ]
20
29
21 where render' = renderChain ["templates/default.html"] . createPagePath
30 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 @@
1---
1---
2title: Tutorial (Part I)
2title: Tutorial (Part I)
3+what: explains how to create a simple brochure site
3---
4---
4
5
5## Getting started
6## Getting started
examples/hakyll/tutorial2.markdown+1
@@ -1,5 +1,6 @@
1---
1---
2title: Tutorial (Part II)
2title: Tutorial (Part II)
3+what: creates a simple blog
3---
4---
4
5
5## Creating a simple blog with Hakyll
6## Creating a simple blog with Hakyll
examples/hakyll/tutorial3.markdown+1
@@ -1,5 +1,6 @@
1---
1---
2title: Tutorial (Part III)
2title: Tutorial (Part III)
3+what: adds an RSS feed to the blog from the previous tutorial
3---
4---
4
5
5## Adding RSS to our simple blog
6## 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.