Skip to content

Commit

Permalink
feat: Adding series to the theme
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
agilix and lxndrblz committed Aug 15, 2021
1 parent e59100b commit d530d03
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Anatole's aims to be minimalistic and sleek but still brings some great function
- Compliant to strict CSP
- Syntax highlighting
- Uses Hugo pipes to process assets
- Series

## Preview the exampleSite

Expand Down Expand Up @@ -637,6 +638,27 @@ toc = true

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).
Expand Down
7 changes: 6 additions & 1 deletion exampleSite/config/_default/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ pygmentsCodefencesGuessSyntax = true
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe=true
unsafe=true

[taxonomies]
category = "categories"
series = "series"
tag = "tags"
41 changes: 41 additions & 0 deletions exampleSite/content/english/post/series-part-1.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions exampleSite/content/english/post/series-part-2.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ <h3>Table of Contents</h3>

{{ .Content }}

{{- if isset .Params "series" -}}
{{- partial "series.html" . -}}

{{- end -}}

{{- if (eq .Params.contact true) -}}
{{- partial "contact.html" . -}}

Expand Down
10 changes: 10 additions & 0 deletions layouts/partials/series.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit d530d03

Please sign in to comment.