From c25bc2a27ab46649393ef7b310e14fff1311116d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Fri, 26 May 2023 08:35:27 +0200 Subject: [PATCH] taxonomy: add support for category default taxonomy #541 --- README.md | 2 +- exampleSite/content/_index.en.md | 2 +- .../content/basics/migration/_index.en.md | 6 +++ exampleSite/content/cont/tags.en.md | 36 ---------------- exampleSite/content/cont/tags.pir.md | 6 --- exampleSite/content/cont/taxonomy.en.md | 42 +++++++++++++++++++ exampleSite/content/cont/taxonomy.pir.md | 7 ++++ layouts/partials/content-footer.html | 13 +++++- layouts/partials/tags.html | 11 ++--- 9 files changed, 75 insertions(+), 50 deletions(-) delete mode 100644 exampleSite/content/cont/tags.en.md delete mode 100644 exampleSite/content/cont/tags.pir.md create mode 100644 exampleSite/content/cont/taxonomy.en.md create mode 100644 exampleSite/content/cont/taxonomy.pir.md diff --git a/README.md b/README.md index bb62e1cebc..aaadda0ec3 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ The Relearn theme is a fork of the great [Learn theme](https://github.com/matcor - In page search - [Site search](https://mcshelby.github.io/hugo-theme-relearn/basics/configuration#activate-search) - [Dedicated search page](https://mcshelby.github.io/hugo-theme-relearn/basics/configuration#activate-dedicated-search-page) - - [Tagging support](https://mcshelby.github.io/hugo-theme-relearn/cont/tags) + - [Taxonomy support](https://mcshelby.github.io/hugo-theme-relearn/cont/taxonomy) - Hidden pages - Unlimited nested menu dependend on your site structure - Navigation buttons dependend on your site structure diff --git a/exampleSite/content/_index.en.md b/exampleSite/content/_index.en.md index 574c500606..486d3bc61b 100644 --- a/exampleSite/content/_index.en.md +++ b/exampleSite/content/_index.en.md @@ -34,7 +34,7 @@ The theme is a fork of the great [Learn theme](https://github.com/matcornic/hugo - In page search - [Site search]({{%relref "basics/configuration#activate-search" %}}) - [Dedicated search page]({{%relref "basics/configuration#activate-dedicated-search-page" %}}) - - [Tagging support]({{%relref "cont/tags" %}}) + - [Taxonomy support]({{%relref "cont/taxonomy" %}}) - Hidden pages - Unlimited nested menu dependend on your site structure - Navigation buttons dependend on your site structure diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index 83600e80e5..9bb79eddda 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -18,6 +18,12 @@ This document shows you what's new in the latest release. For a detailed list of --- +## 5.16.0 (2023-05-25) + +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Besides the _tag_ [taxonomy]({{% relref "cont/taxonomy" %}}) the theme now also provides the _category_ taxonomy out of the box and shows them in the content footer of each page. + +--- + ## 5.15.0 (2023-05-25) - {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) has changed behavior if you haven't set the `groupid` parameter. diff --git a/exampleSite/content/cont/tags.en.md b/exampleSite/content/cont/tags.en.md deleted file mode 100644 index a3f0b954d4..0000000000 --- a/exampleSite/content/cont/tags.en.md +++ /dev/null @@ -1,36 +0,0 @@ -+++ -tags = ["documentation", "tutorial stuff"] -title = "Tags" -weight = 7 -+++ - -The Relearn theme supports one default taxonomy of Hugo: the *tag* feature. - -## Configuration - -Just add tags to any page: - -```toml -+++ -tags = ["tutorial", "theme"] -title = "Theme tutorial" -weight = 15 -+++ -``` - -## Behavior - -The tags are displayed at the top of the page, in their insertion order. - -Each tag is a link to a *Taxonomy* page displaying all the articles with the given tag. - -## List all the tags - -In the `config.toml` file you can add a shortcut to display all the tags - -```toml -[[menu.shortcuts]] -name = " Tags" -url = "/tags" -weight = 30 -``` \ No newline at end of file diff --git a/exampleSite/content/cont/tags.pir.md b/exampleSite/content/cont/tags.pir.md deleted file mode 100644 index 04f105cd5c..0000000000 --- a/exampleSite/content/cont/tags.pir.md +++ /dev/null @@ -1,6 +0,0 @@ -+++ -tags = ["documentat'n", "tutorrrial"] -title = "Tags" -weight = 7 -+++ -{{< piratify >}} \ No newline at end of file diff --git a/exampleSite/content/cont/taxonomy.en.md b/exampleSite/content/cont/taxonomy.en.md new file mode 100644 index 0000000000..a77ce680b2 --- /dev/null +++ b/exampleSite/content/cont/taxonomy.en.md @@ -0,0 +1,42 @@ ++++ +categories = ["taxonomy", "content"] +tags = "tutorial" +title = "Taxonomy" +weight = 7 ++++ + +The Relearn theme supports Hugo's default taxonomies *tag* and *category* out of the box. + +## Configuration + +Just add tags and/or categories to any page. They can be given as a single string or an array of strings. + +```toml ++++ +categories = ["taxonomy", "content"] +tags = "tutorial" +title = "Taxonomy" ++++ +``` + +## Behavior + +The tags are displayed at the top of the page in alphabetical order. + +The categories are displayed at the bottom of the page in alphabetical order in the default implementation of the theme but can be customized by providing your own `content-footer.html` partial. + +Each item is a link to a taxonomy page displaying all the articles with the given term. + +## List all the tags + +In the `config.toml` file you can add a shortcut to display all the tags and categories + +```toml +[[menu.shortcuts]] +name = " Tags" +url = "/tags" + +[[menu.shortcuts]] +name = " Categories" +url = "/categories" +``` diff --git a/exampleSite/content/cont/taxonomy.pir.md b/exampleSite/content/cont/taxonomy.pir.md new file mode 100644 index 0000000000..7494e790ad --- /dev/null +++ b/exampleSite/content/cont/taxonomy.pir.md @@ -0,0 +1,7 @@ ++++ +categories = ["taxonomy", "content"] +tags = "tutorrrial" +title = "Taxonomy" +weight = 7 ++++ +{{< piratify >}} \ No newline at end of file diff --git a/layouts/partials/content-footer.html b/layouts/partials/content-footer.html index 4c92a2e707..d7411b43be 100644 --- a/layouts/partials/content-footer.html +++ b/layouts/partials/content-footer.html @@ -3,4 +3,15 @@ {{- with $.Date }} {{ . | time.Format ":date_medium" }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} +{{- $page := . }} +{{- if .Params.categories }} + + {{- $categories := slice | append .Params.categories }} + {{- range $idx, $category := sort $categories }} + {{- with $page.Site.GetPage (printf "%s%s" ("/categories/" | relURL ) ( $category | anchorize ) ) }} + {{- $to := . }} + {{ if gt $idx 0 }} | {{ end }}{{ $category }} + {{- end }} + {{- end }} +{{- end }} diff --git a/layouts/partials/tags.html b/layouts/partials/tags.html index 5ac6f74bdf..65398689ae 100644 --- a/layouts/partials/tags.html +++ b/layouts/partials/tags.html @@ -2,12 +2,13 @@ {{- $page := . }} {{- if .Params.tags }}
-{{- range sort .Params.tags }} - {{- $tag := . }} - {{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | anchorize ) ) }} - {{- $to := . }} + {{- $tags := slice | append .Params.tags }} + {{- range sort $tags }} + {{- $tag := . }} + {{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | anchorize ) ) }} + {{- $to := . }} {{ $tag }} + {{- end }} {{- end }} -{{- end }}
{{- end }} \ No newline at end of file