hakyll-series: Adds series functionality to hakyll
Module for adding series functionality to hakyll.
Example here.
In your posts, provide metadata at the top like so:
--- title: something series: things ---
This will add the following fields to the post:
series
- The name of the series
seriesLength
- The total number of posts in the series
seriesCurPos
- The position of the current post in the series
seriesUrl
- The URL of the series page
Using that, in your post template, something like this:
$if(series)$ <a href="$seriesUrl$">Part $seriesCurPos$ of a $seriesLength$-part series on $series$</a> $endif$
Will render like this:
Part 1 of a 5-part series on things
Linked to the aggregate page for the series, which would render something like this:
Things Part 1: something
To add it to your blog, add something like this to your main
:
series <- buildSeries "posts/*" (fromCapture "series/*.html") tagsRules series $ \(s:erie) pattrn -> do let title = toUpper s : erie route idRoute compile $ do posts <- chronological =<< loadAll pattrn let ctx = constField "title" title `mappend` listField "posts" postCtx (pure posts) `mappend` defaultContext makeItem "" >>= loadAndApplyTemplate "templates/series.html" ctx >>= loadAndApplyTemplate "templates/default.html" ctx >>= relativizeUrls
To have access to the series context in each post, change the post rule to something like this:
match "posts/*" $ do route $ setExtension "html" compile $ pandocCompiler >>= loadAndApplyTemplate "templates/post.html" (postCtxWithSeries series) >>= loadAndApplyTemplate "templates/default.html" (postCtxWithSeries series) >>= relativizeUrls
Where postCtxWithSeries
can be something like:
postCtxWithSeries :: Tags -> Context String postCtxWithSeries series = seriesField series `mappend` postCtx
A minimal example is provided in this repo, on top of the default hakyll setup. (it also provides the templates)
Downloads
- hakyll-series-0.1.0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.1 |
---|---|
Dependencies | base (>=4 && <5), containers (>=0.5), hakyll (>=4.8.0) [details] |
License | MIT |
Copyright | 2016 Donnacha Oisín Kidney |
Author | Donnacha Oisín Kidney |
Maintainer | mail@doisinkidney.com |
Category | Web |
Home page | https://github.com/oisdk/hakyll-series |
Source repo | head: git clone https://github.com/oisdk/hakyll-series |
Uploaded | by oisdk at 2016-11-02T21:53:12Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Downloads | 880 total (5 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |