mirror of https://github.com/lxndrblz/anatole.git

Kenneth
15.01.2021 d530d03761514d90de059ca005063d447f50460c
feat: Adding series to the theme

Closes #234

* Implemented basic functionality to group posts by a series
* Added two example posts to display how the series work
* Updated the ReadMe to include how to setup the series

Co-authored-by: Alexander Bilz <mail@alexbilz.com>
3 files added
3 files modified
102 ■■■■■ changed files
README.md 22 ●●●●● patch | view | raw | blame | history
exampleSite/config/_default/config.toml 7 ●●●● patch | view | raw | blame | history
exampleSite/content/english/post/series-part-1.md 41 ●●●●● patch | view | raw | blame | history
exampleSite/content/english/post/series-part-2.md 17 ●●●●● patch | view | raw | blame | history
layouts/_default/single.html 5 ●●●●● patch | view | raw | blame | history
layouts/partials/series.html 10 ●●●●● patch | view | raw | blame | history
README.md
@@ -34,6 +34,7 @@
- Compliant to strict CSP
- Syntax highlighting
- Uses Hugo pipes to process assets
- Series
## Preview the exampleSite
@@ -637,6 +638,27 @@
Please note that only "## H2 Headings" and "### H3 Headings" will appear in the table of contents.
### Enabling Series
You can enable series, which allows splitting up a huge post into a set of multiple blog posts that are still linked. This would also provide a unique link to the full series of blog posts. Each individual post in the series will also contain links to the other parts under the heading `Posts in this Series`.
First, we need to enable the `series` taxonomy in the config.
```toml
[taxonomies]
    category = "categories"
    series = "series"
    tag = "tags"
```
With this enabled, we can now proceed to specify the series in the Front Matter of each post of that series.
```md
series: - series-name
```
If you want to share the full series, you can do so by sharing the link `<base-url>/series/<series-name>`
## License
Anatole is licensed under the [MIT license](https://github.com/lxndrblz/anatole/blob/master/LICENSE).
exampleSite/config/_default/config.toml
@@ -21,4 +21,9 @@
[markup]
    [markup.goldmark]
        [markup.goldmark.renderer]
        unsafe=true
        unsafe=true
[taxonomies]
    category = "categories"
    series = "series"
    tag = "tags"
exampleSite/content/english/post/series-part-1.md
New file
@@ -0,0 +1,41 @@
---
author: Hugo Authors
title: Series Part 1
date: 2021-08-14
description: A brief guide to how to setup series part 1
series:
  - series-setup
---
In this first part of the series we'll show you how to create a series
<!--more-->
As a first step we need to add series as a taxonomy. We can do this by editing the `config.toml`.
Note: We always need to define the existing taxonomies as well.
```toml
[taxonomies]
    category = "categories"
    series = "series"
    tag = "tags"
```
Now we have the series enabled, the next thing we need to do is add the series name in the FrontMatter.
For our example we'll use this post and the next part.
As you can see we've set the series to `series-setup`. We also do the same in the next parts of the series.
This end results should be a Front Matter that looks similar to this:
```md
---
author: Hugo Authors
title: Series Part 1
date: 2021-08-14
description: A brief guide to how to setup series part 1
series:
  - series-setup
---
```
Each individual post will now also show the other posts in the series under the `Posts in this Series` heading.
exampleSite/content/english/post/series-part-2.md
New file
@@ -0,0 +1,17 @@
---
author: Hugo Authors
title: Series Part 2
date: 2021-08-15
description: A brief guide to how to setup series part 2
series:
  - series-setup
---
In this second part of the series we'll show you where to find the full series
<!--more-->
When you created a series, you'll probably want to link to the full set of blogposts.
In this example we used `series-setup` as our series name.
This means we can now go to `http://localhost:1313/series/series-setup/` to see all the blog posts of this serie.
layouts/_default/single.html
@@ -45,6 +45,11 @@
      {{ .Content }}
      {{- if isset .Params "series" -}}
        {{- partial "series.html" . -}}
      {{- end -}}
      {{- if (eq .Params.contact true) -}}
        {{- partial "contact.html" . -}}
layouts/partials/series.html
New file
@@ -0,0 +1,10 @@
{{ $related := where .Site.RegularPages ".Params.series" "intersect" .Params.series }}
<h3>Posts in this Series</h3>
<ul>
  {{ range $related }}
    <li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a></li>
  {{ end }}
</ul>