MyNixOS website logo
Description

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)

Metadata

Version

0.1.0.1

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows