From d129cdc775b728c700dcabe0fc9b600235b92284 Mon Sep 17 00:00:00 2001
From: Jasper Van der Jeugt
Date: Sun, 13 Jan 2013 12:18:24 +0100
Subject: Partition tutorials into series and articles
---
web/site.hs | 20 +++++++++++++++-----
web/templates/tutorials.html | 15 +++++++--------
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/web/site.hs b/web/site.hs
index 79578dd..2fca8e0 100644
--- a/web/site.hs
+++ b/web/site.hs
@@ -3,7 +3,7 @@
import Control.Applicative ((<$>))
import Control.Arrow (second)
import Control.Monad (forM_)
-import Data.List (isPrefixOf)
+import Data.List (isPrefixOf, partition)
import Data.Monoid (mappend)
import Hakyll
import System.FilePath (dropTrailingPathSeparator, splitPath)
@@ -53,12 +53,16 @@ main = hakyllWith config $ do
compile $ do
tutorials <- loadAll "tutorials/*"
itemTpl <- loadBody "templates/tutorial-item.html"
- list <- applyTemplateList itemTpl defaultContext $
- chronological tutorials
+ let (series, articles) = partitionTutorials $
+ chronological tutorials
+
+ series' <- applyTemplateList itemTpl defaultContext series
+ articles' <- applyTemplateList itemTpl defaultContext articles
let tutorialsCtx =
- constField "title" "Tutorials" `mappend`
- constField "tutorials" list `mappend`
+ constField "title" "Tutorials" `mappend`
+ constField "series" series' `mappend`
+ constField "articles" articles' `mappend`
defaultContext
makeItem ""
@@ -102,3 +106,9 @@ hackage url
(packageName, version') = second (drop 1) $ break (== '-') package
(baseName : package : _) = map dropTrailingPathSeparator $
reverse $ splitPath url
+
+
+--------------------------------------------------------------------------------
+-- | Partition tutorials into tutorial series & other articles
+partitionTutorials :: [Item a] -> ([Item a], [Item a])
+partitionTutorials = partition $ matches (fromRegex "\\d*-.*") . itemIdentifier
diff --git a/web/templates/tutorials.html b/web/templates/tutorials.html
index dd3132b..af14097 100644
--- a/web/templates/tutorials.html
+++ b/web/templates/tutorials.html
@@ -1,14 +1,13 @@
Tutorials about Hakyll
-
- Here is a list of tutorials I've written about Hakyll:
-
-
+Tutorial series
+
+Other articles
+In no particular order:
+
All these tutorials assume you are using the latest stable version of
Hakyll. If this is not the case, you might want to update using:
-
$ ghc-pkg unregister hakyll
+
+$ ghc-pkg unregister hakyll
$ cabal update
$ cabal install hakyll
-
--
cgit v1.2.3