summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-01-13 12:18:24 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-01-13 12:18:24 +0100
commitd129cdc775b728c700dcabe0fc9b600235b92284 (patch)
tree140aadfa2b8cc23aba83de4fa2a186cffc350789 /web
parent1ceb5eb205438b3ff57fe74ada821d89695869d9 (diff)
downloadhakyll-d129cdc775b728c700dcabe0fc9b600235b92284.tar.gz
Partition tutorials into series and articles
Diffstat (limited to 'web')
-rw-r--r--web/site.hs20
-rw-r--r--web/templates/tutorials.html15
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 @@
<h1>Tutorials about Hakyll</h1>
-<p>
- Here is a list of tutorials I've written about Hakyll:
-</p>
-<ul>
- $tutorials$
-</ul>
+<h2>Tutorial series</h2>
+<ul>$series$</ul>
+<h2>Other articles</h2>
+<p>In no particular order:</p>
+<ul>$articles$</ul>
<p>
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:
- <pre><code>$ ghc-pkg unregister hakyll
+</p>
+<pre><code>$ ghc-pkg unregister hakyll
$ cabal update
$ cabal install hakyll</code></pre>
-</p>