summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2019-01-27 16:40:40 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2019-01-27 16:40:40 +0100
commitd832cd80ddf43872532db8943f310eed4edb7fe5 (patch)
treea088d3b39f98267197f7cae71eb56f47ecb39f3e /web
parenta983c8cbc917ffa3ce81d2540b50bdb321588b92 (diff)
downloadhakyll-d832cd80ddf43872532db8943f310eed4edb7fe5.tar.gz
Refactor tutorials on hakyll website
Diffstat (limited to 'web')
-rw-r--r--web/site.hs45
-rw-r--r--web/templates/tutorials.html30
-rw-r--r--web/tutorials/01-installation.markdown1
-rw-r--r--web/tutorials/02-basics.markdown1
-rw-r--r--web/tutorials/03-rules-routes-compilers.markdown1
-rw-r--r--web/tutorials/04-compilers.markdown1
-rw-r--r--web/tutorials/05-snapshots-feeds.markdown1
-rw-r--r--web/tutorials/06-versions.markdown1
-rw-r--r--web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown1
-rw-r--r--web/tutorials/external-add-tags-to-your-hakyll-blog.md2
-rw-r--r--web/tutorials/external-blogger-port.md2
-rw-r--r--web/tutorials/external-cassius-template.md2
-rw-r--r--web/tutorials/external-clean-urls-with-hakyll.md2
-rw-r--r--web/tutorials/external-deploying-with-widely.md2
-rw-r--r--web/tutorials/external-functionfield.md2
-rw-r--r--web/tutorials/external-github-pages-circle-ci.md2
-rw-r--r--web/tutorials/external-inlining-and-compressing-css.md2
-rw-r--r--web/tutorials/faq.markdown1
-rw-r--r--web/tutorials/github-pages-tutorial.md1
-rw-r--r--web/tutorials/hakyll-3-to-hakyll4-migration-guide.markdown1
-rw-r--r--web/tutorials/using-clay-with-hakyll.markdown1
-rw-r--r--web/tutorials/using-teasers-in-hakyll.markdown1
22 files changed, 45 insertions, 58 deletions
diff --git a/web/site.hs b/web/site.hs
index a20d15b..2bfaf3e 100644
--- a/web/site.hs
+++ b/web/site.hs
@@ -1,8 +1,7 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Control.Arrow (second)
-import Control.Monad (forM_)
-import Data.Char (isDigit)
+import Control.Monad (filterM, forM_)
import Data.List (isPrefixOf, sortBy)
import Data.Monoid ((<>))
import Data.Ord (comparing)
@@ -57,17 +56,11 @@ main = hakyllWith config $ do
create ["tutorials.html"] $ do
route idRoute
compile $ do
- tuts <-
+ ctx <- tutorialsCtx <$>
sortBy (comparing itemIdentifier) <$> loadAll "tutorials/*"
-
- let tutorialsCtx =
- constField "title" "Tutorials" `mappend`
- listField "tutorials" tutorialCtx (return tuts) `mappend`
- defaultContext
-
makeItem ""
- >>= loadAndApplyTemplate "templates/tutorials.html" tutorialsCtx
- >>= loadAndApplyTemplate "templates/default.html" tutorialsCtx
+ >>= loadAndApplyTemplate "templates/tutorials.html" ctx
+ >>= loadAndApplyTemplate "templates/default.html" ctx
>>= relativizeUrls
-- Templates
@@ -109,27 +102,15 @@ hackage url
--------------------------------------------------------------------------------
-data TutorialType = SeriesTutorial | ArticlesTutorial | ExternalTutorial
- deriving (Eq)
-
-
---------------------------------------------------------------------------------
-- | Partition tutorials into tutorial series, other articles, external articles
-tutorialCtx :: Context String
-tutorialCtx =
- field "isSeries" (isTutorialType SeriesTutorial) <>
- field "isArticle" (isTutorialType ArticlesTutorial) <>
- field "isExternal" (isTutorialType ExternalTutorial) <>
+tutorialsCtx :: [Item String] -> Context String
+tutorialsCtx tuts =
+ constField "title" "Tutorials" <>
+ listField "main" defaultContext (ofType "main") <>
+ listField "articles" defaultContext (ofType "article") <>
+ listField "externals" defaultContext (ofType "external") <>
defaultContext
where
- getTutorialType item = do
- mbExternal <- getMetadataField (itemIdentifier item) "external"
- return $ case mbExternal of
- Just _ -> ExternalTutorial
- _ -> case splitPath (toFilePath $ itemIdentifier item) of
- [_, (x : _)] -> if isDigit x then SeriesTutorial else ArticlesTutorial
- _ -> ArticlesTutorial
-
- isTutorialType ty0 item = do
- ty1 <- getTutorialType item
- if ty0 == ty1 then return "yes" else fail "no"
+ ofType ty = filterM (\item -> do
+ mbType <- getMetadataField (itemIdentifier item) "type"
+ return $ Just ty == mbType) tuts
diff --git a/web/templates/tutorials.html b/web/templates/tutorials.html
index cafdacb..9650897 100644
--- a/web/templates/tutorials.html
+++ b/web/templates/tutorials.html
@@ -1,23 +1,19 @@
<h1>Tutorials about Hakyll</h1>
<h2 id="series">Tutorial series</h2>
<ul>
- $for(tutorials)$
- $if(isSeries)$
- <li>
- <a href="$url$">$title$</a>
- </li>
- $endif$
+ $for(main)$
+ <li>
+ <a href="$url$">$title$</a>
+ </li>
$endfor$
</ul>
<h2 id="articles">Other articles</h2>
<p>In no particular order:</p>
<ul>
- $for(tutorials)$
- $if(isArticle)$
- <li>
- <a href="$url$">$title$</a> by <em>$author$</em>
- </li>
- $endif$
+ $for(articles)$
+ <li>
+ <a href="$url$">$title$</a> by <em>$author$</em>
+ </li>
$endfor$
</ul>
<h2 id="external-articles">External articles</h2>
@@ -28,12 +24,10 @@
</p>
<p>In no particular order:</p>
<ul>
- $for(tutorials)$
- $if(isExternal)$
- <li>
- <a href="$url$">$title$</a> by <em>$author$</em>
- </li>
- $endif$
+ $for(externals)$
+ <li>
+ <a href="$url$">$title$</a> by <em>$author$</em>
+ </li>
$endfor$
</ul>
<p>
diff --git a/web/tutorials/01-installation.markdown b/web/tutorials/01-installation.markdown
index 7826792..cf9fa78 100644
--- a/web/tutorials/01-installation.markdown
+++ b/web/tutorials/01-installation.markdown
@@ -1,6 +1,7 @@
---
title: Installation
author: Jasper Van der Jeugt
+type: main
---
Installation
diff --git a/web/tutorials/02-basics.markdown b/web/tutorials/02-basics.markdown
index b79d336..e791b2d 100644
--- a/web/tutorials/02-basics.markdown
+++ b/web/tutorials/02-basics.markdown
@@ -1,6 +1,7 @@
---
title: The basics
author: Jasper Van der Jeugt
+type: main
---
Building and cleaning
diff --git a/web/tutorials/03-rules-routes-compilers.markdown b/web/tutorials/03-rules-routes-compilers.markdown
index 4130a86..a615a81 100644
--- a/web/tutorials/03-rules-routes-compilers.markdown
+++ b/web/tutorials/03-rules-routes-compilers.markdown
@@ -1,6 +1,7 @@
---
title: Rules, routes and compilers
author: Jasper Van der Jeugt
+type: main
---
Basic rules
diff --git a/web/tutorials/04-compilers.markdown b/web/tutorials/04-compilers.markdown
index c89410f..ce18f3b 100644
--- a/web/tutorials/04-compilers.markdown
+++ b/web/tutorials/04-compilers.markdown
@@ -1,6 +1,7 @@
---
title: 'More on compilers: load, and templates'
author: Jasper Van der Jeugt
+type: main
---
Loading items
diff --git a/web/tutorials/05-snapshots-feeds.markdown b/web/tutorials/05-snapshots-feeds.markdown
index a8c06c6..419b6d9 100644
--- a/web/tutorials/05-snapshots-feeds.markdown
+++ b/web/tutorials/05-snapshots-feeds.markdown
@@ -1,6 +1,7 @@
---
title: Snapshots, and how to produce an RSS/Atom feed
author: Jasper Van der Jeugt
+type: main
---
Basic feed configuration
diff --git a/web/tutorials/06-versions.markdown b/web/tutorials/06-versions.markdown
index 48aae15..c51f4b0 100644
--- a/web/tutorials/06-versions.markdown
+++ b/web/tutorials/06-versions.markdown
@@ -1,6 +1,7 @@
---
title: Producing multiple versions of a single file
author: Jasper Van der Jeugt
+type: main
---
Basics
diff --git a/web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown b/web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown
index 632ce4f..3c711d0 100644
--- a/web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown
+++ b/web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown
@@ -1,6 +1,7 @@
---
title: A Guide to the Hakyll Module Zoo
author: Brent Yorgey
+type: article
---
The hakyll package [contains a bewildering array](/reference/) of modules, and
diff --git a/web/tutorials/external-add-tags-to-your-hakyll-blog.md b/web/tutorials/external-add-tags-to-your-hakyll-blog.md
index 188e2ea..867a173 100644
--- a/web/tutorials/external-add-tags-to-your-hakyll-blog.md
+++ b/web/tutorials/external-add-tags-to-your-hakyll-blog.md
@@ -2,5 +2,5 @@
title: Add tags to your Hakyll blog
author: Javran Cheng
url: https://javran.github.io/posts/2014-03-01-add-tags-to-your-hakyll-blog.html
-external: true
+type: external
---
diff --git a/web/tutorials/external-blogger-port.md b/web/tutorials/external-blogger-port.md
index a14cfad..576f1b9 100644
--- a/web/tutorials/external-blogger-port.md
+++ b/web/tutorials/external-blogger-port.md
@@ -2,5 +2,5 @@
title: Port an existing Blogger blog to Hakyll
author: Daniel Campoverde
url: 'http://www.sillybytes.net/posts/from_blogger_to_hakyll.html'
-external: true
+type: external
---
diff --git a/web/tutorials/external-cassius-template.md b/web/tutorials/external-cassius-template.md
index 1a10f82..a0f9e20 100644
--- a/web/tutorials/external-cassius-template.md
+++ b/web/tutorials/external-cassius-template.md
@@ -2,5 +2,5 @@
title: Using Cassius templating with Hakyll
author: Daniel Campoverde
url: 'http://www.sillybytes.net/posts/using_hakyll_with_cassius.html'
-external: true
+type: external
---
diff --git a/web/tutorials/external-clean-urls-with-hakyll.md b/web/tutorials/external-clean-urls-with-hakyll.md
index 127a192..c34f904 100644
--- a/web/tutorials/external-clean-urls-with-hakyll.md
+++ b/web/tutorials/external-clean-urls-with-hakyll.md
@@ -2,5 +2,5 @@
title: Clean URLs with Hakyll
author: Rohan Jain
url: http://www.rohanjain.in/hakyll-clean-urls/
-external: true
+type: external
---
diff --git a/web/tutorials/external-deploying-with-widely.md b/web/tutorials/external-deploying-with-widely.md
index 635ce09..7950825 100644
--- a/web/tutorials/external-deploying-with-widely.md
+++ b/web/tutorials/external-deploying-with-widely.md
@@ -2,5 +2,5 @@
title: Deploying with Widely
author: Kyle Marek-Spartz
url: http://kyle.marek-spartz.org/posts/2013-12-09-widely-and-hakyll.html
-external: true
+type: external
---
diff --git a/web/tutorials/external-functionfield.md b/web/tutorials/external-functionfield.md
index 91df254..f83704d 100644
--- a/web/tutorials/external-functionfield.md
+++ b/web/tutorials/external-functionfield.md
@@ -2,5 +2,5 @@
title: Hakyll's functionField
author: Beerend Lauwers
url: http://beerendlauwers.be/posts/2015-09-21-hakylls-functionfield.html
-external: true
+type: external
---
diff --git a/web/tutorials/external-github-pages-circle-ci.md b/web/tutorials/external-github-pages-circle-ci.md
index 8e25b8e..a881787 100644
--- a/web/tutorials/external-github-pages-circle-ci.md
+++ b/web/tutorials/external-github-pages-circle-ci.md
@@ -2,5 +2,5 @@
title: Create a GitHub page with Hakyll and CircleCI
author: Juan Pedro Villa
url: https://www.stackbuilders.com/news/dr-hakyll-create-a-github-page-with-hakyll-and-circleci
-external: true
+type: external
---
diff --git a/web/tutorials/external-inlining-and-compressing-css.md b/web/tutorials/external-inlining-and-compressing-css.md
index 30beca5..1168e96 100644
--- a/web/tutorials/external-inlining-and-compressing-css.md
+++ b/web/tutorials/external-inlining-and-compressing-css.md
@@ -2,5 +2,5 @@
title: Inlining and compressing CSS
author: Kyle Marek-Spartz
url: http://kyle.marek-spartz.org/posts/2014-12-09-hakyll-css-template-compiler.html
-external: true
+type: external
---
diff --git a/web/tutorials/faq.markdown b/web/tutorials/faq.markdown
index e978c8d..382f7f4 100644
--- a/web/tutorials/faq.markdown
+++ b/web/tutorials/faq.markdown
@@ -1,6 +1,7 @@
---
title: FAQ
author: Jasper Van der Jeugt
+type: article
---
## "hGetContents: invalid argument" or "commitBuffer: invalid argument"
diff --git a/web/tutorials/github-pages-tutorial.md b/web/tutorials/github-pages-tutorial.md
index 7681353..3e55115 100644
--- a/web/tutorials/github-pages-tutorial.md
+++ b/web/tutorials/github-pages-tutorial.md
@@ -1,6 +1,7 @@
---
title: Using Hakyll with GitHub Pages
author: Erik Stevenson
+type: article
---
## Introduction
diff --git a/web/tutorials/hakyll-3-to-hakyll4-migration-guide.markdown b/web/tutorials/hakyll-3-to-hakyll4-migration-guide.markdown
index 929e909..2e03f66 100644
--- a/web/tutorials/hakyll-3-to-hakyll4-migration-guide.markdown
+++ b/web/tutorials/hakyll-3-to-hakyll4-migration-guide.markdown
@@ -1,6 +1,7 @@
---
title: Hakyll 3 to Hakyll 4 migration guide
author: Jasper Van der Jeugt
+type: article
---
Introduction
diff --git a/web/tutorials/using-clay-with-hakyll.markdown b/web/tutorials/using-clay-with-hakyll.markdown
index c676a80..456a108 100644
--- a/web/tutorials/using-clay-with-hakyll.markdown
+++ b/web/tutorials/using-clay-with-hakyll.markdown
@@ -1,6 +1,7 @@
---
title: Using Clay with Hakyll
author: Jasper Van der Jeugt
+type: article
---
[Clay](http://sebastiaanvisser.github.com/clay/) is a nice CSS preprocesser
diff --git a/web/tutorials/using-teasers-in-hakyll.markdown b/web/tutorials/using-teasers-in-hakyll.markdown
index 978d37b..1886ba1 100644
--- a/web/tutorials/using-teasers-in-hakyll.markdown
+++ b/web/tutorials/using-teasers-in-hakyll.markdown
@@ -1,6 +1,7 @@
---
title: Using teasers in Hakyll
author: Ivan Veselov
+type: article
---
## Introduction