on master help sign in
Partition tutorials into series and articles
commitd129cdc775b728c700dcabe0fc9b600235b92284 authorJasper Van der Jeugt <m@jaspervdj.be> dateSun 13 Jan 2013, 12:18 (14 years ago) parent1ceb5eb
2 files changed+22−13
web/site.hs+15−5 web/templates/tutorials.html+7−8
web/site.hs+15−5
@@ -3,7 +3,7 @@
33import Control.Applicative ((<$>))
44import Control.Arrow (second)
55import Control.Monad (forM_)
6−import Data.List (isPrefixOf)
6+import Data.List (isPrefixOf, partition)
77import Data.Monoid (mappend)
88import Hakyll
99import System.FilePath (dropTrailingPathSeparator, splitPath)
@@ -53,12 +53,16 @@ main = hakyllWith config $ do
5353 compile $ do
5454 tutorials <- loadAll "tutorials/*"
5555 itemTpl <- loadBody "templates/tutorial-item.html"
56− list <- applyTemplateList itemTpl defaultContext $
57− chronological tutorials
56+ let (series, articles) = partitionTutorials $
57+ chronological tutorials
58+
59+ series' <- applyTemplateList itemTpl defaultContext series
60+ articles' <- applyTemplateList itemTpl defaultContext articles
5861
5962 let tutorialsCtx =
60− constField "title" "Tutorials" `mappend`
61− constField "tutorials" list `mappend`
63+ constField "title" "Tutorials" `mappend`
64+ constField "series" series' `mappend`
65+ constField "articles" articles' `mappend`
6266 defaultContext
6367
6468 makeItem ""
@@ -102,3 +106,9 @@ hackage url
102106 (packageName, version') = second (drop 1) $ break (== '-') package
103107 (baseName : package : _) = map dropTrailingPathSeparator $
104108 reverse $ splitPath url
109+
110+
111+--------------------------------------------------------------------------------
112+-- | Partition tutorials into tutorial series & other articles
113+partitionTutorials :: [Item a] -> ([Item a], [Item a])
114+partitionTutorials = partition $ matches (fromRegex "\\d*-.*") . itemIdentifier
web/templates/tutorials.html+7−8
@@ -1,14 +1,13 @@
11<h1>Tutorials about Hakyll</h1>
2−<p>
3− Here is a list of tutorials I've written about Hakyll:
4−</p>
5−<ul>
6− $tutorials$
7−</ul>
2+<h2>Tutorial series</h2>
3+<ul>$series$</ul>
4+<h2>Other articles</h2>
5+<p>In no particular order:</p>
6+<ul>$articles$</ul>
87<p>
98 All these tutorials assume you are using the latest stable version of
109 Hakyll. If this is not the case, you might want to update using:
11− <pre><code>$ ghc-pkg unregister hakyll
10+</p>
11+<pre><code>$ ghc-pkg unregister hakyll
1212$ cabal update
1313$ cabal install hakyll</code></pre>
14−</p>