From e84fc0e1c63624c263d3c7dcb42e79239ee9a693 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Mon, 23 Mar 2026 05:45:46 +0100 Subject: [PATCH 1/3] Implemented category badges in secondary color. --- assets/css/compiled/main.css | 32 ++++++++++++++++++++ config/_default/params.toml | 4 ++- layouts/partials/article-meta/basic.html | 37 ++++++++++++------------ layouts/partials/badge-secondary.html | 6 ++++ 4 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 layouts/partials/badge-secondary.html diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css index 785669d7..06b7fc7f 100644 --- a/assets/css/compiled/main.css +++ b/assets/css/compiled/main.css @@ -1666,9 +1666,15 @@ .border-primary-500 { border-color: rgba(var(--color-primary-500), 1); } + .border-secondary-400 { + border-color: rgba(var(--color-secondary-400), 1); + } .border-secondary-500 { border-color: rgba(var(--color-secondary-500), 1); } + .border-secondary-600 { + border-color: rgba(var(--color-secondary-600), 1); + } .border-transparent { border-color: transparent; } @@ -2181,6 +2187,12 @@ .text-primary-800 { color: rgba(var(--color-primary-800), 1); } + .text-secondary-400 { + color: rgba(var(--color-secondary-400), 1); + } + .text-secondary-700 { + color: rgba(var(--color-secondary-700), 1); + } .text-transparent { color: transparent; } @@ -3263,6 +3275,16 @@ border-color: rgba(var(--color-primary-600), 1); } } + .dark\:border-secondary-600 { + &:is(.dark *) { + border-color: rgba(var(--color-secondary-600), 1); + } + } + .dark\:border-secondary-800 { + &:is(.dark *) { + border-color: rgba(var(--color-secondary-800), 1); + } + } .dark\:border-white\/10 { &:is(.dark *) { border-color: color-mix(in oklab, #fff 10%, transparent); @@ -3492,6 +3514,16 @@ color: rgba(var(--color-primary-400), 1); } } + .dark\:text-secondary-200 { + &:is(.dark *) { + color: rgba(var(--color-secondary-200), 1); + } + } + .dark\:text-secondary-400 { + &:is(.dark *) { + color: rgba(var(--color-secondary-400), 1); + } + } .dark\:text-white { &:is(.dark *) { color: #fff; diff --git a/config/_default/params.toml b/config/_default/params.toml index 8b0bf26a..b110de3a 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -88,7 +88,9 @@ forgejoDefaultServer = "https://v11.next.forgejo.org" # showRelatedContent = false # relatedContentLimit = 3 showTaxonomies = false # use showTaxonomies OR showCategoryOnly, not both - showCategoryOnly = false # use showTaxonomies OR showCategoryOnly, not both + showCategories = true # These will show if showTaxonomies is true. + showTags = true # These will show if showTaxonomies is true. + showCategoriesInSecondaryColor = false # This will change the color of category badges, so the user can better distinguish between the two. Only if showTaxonomies is true. showAuthorsBadges = false showWordCount = true # sharingLinks = [ "linkedin", "twitter", "bluesky", "mastodon", "reddit", "pinterest", "facebook", "email", "whatsapp", "telegram", "line"] diff --git a/layouts/partials/article-meta/basic.html b/layouts/partials/article-meta/basic.html index de46cced..9fe54277 100644 --- a/layouts/partials/article-meta/basic.html +++ b/layouts/partials/article-meta/basic.html @@ -98,28 +98,29 @@ {{ if .Params.showTaxonomies | default (.Site.Params.article.showTaxonomies | default false) }}
{{ range $taxonomy, $terms := .Site.Taxonomies }} - {{ if and (not (eq $taxonomy "authors")) (not (eq $taxonomy "series")) }} - {{ if (gt (len ($context.GetTerms $taxonomy)) 0) }} - {{ range $context.GetTerms $taxonomy }} - - {{ partial "badge.html" .LinkTitle }} - + {{ if (gt (len ($context.GetTerms $taxonomy)) 0) }} + {{ range $context.GetTerms $taxonomy }} + {{ if .Params.showCategories | default (.Site.Params.article.showCategories | default true) }} + {{ if (eq $taxonomy "categories") }} + + {{ if .Params.showCategoriesInSecondaryColor | default (.Site.Params.article.showCategoriesInSecondaryColor | default false) }} + {{ partial "badge-secondary.html" .LinkTitle }} + {{ else }} + {{ partial "badge.html" .LinkTitle }} + {{ end }} + + {{ end }} + {{ end }} + {{ if .Params.showTags | default (.Site.Params.article.showTags | default true) }} + {{ if (eq $taxonomy "tags") }} + + {{ partial "badge.html" .LinkTitle }} + + {{ end }} {{ end }} {{ end }} {{ end }} {{ end }}
{{ end }} - - {{/* Output only category */}} - {{ if .Params.showCategoryOnly | default (.Site.Params.article.showCategoryOnly | default false) }} -
- {{ range (.GetTerms "categories") }} - - {{ partial "badge.html" .LinkTitle }} - - {{ end }} -
- {{ end }} - {{ end }} diff --git a/layouts/partials/badge-secondary.html b/layouts/partials/badge-secondary.html new file mode 100644 index 00000000..a8bf7499 --- /dev/null +++ b/layouts/partials/badge-secondary.html @@ -0,0 +1,6 @@ + + + {{ . }} + + \ No newline at end of file From 859685f0c2339039a2e5368d756c814f69b8da7f Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Mon, 23 Mar 2026 08:30:21 +0100 Subject: [PATCH 2/3] Added documentation. --- config/_default/params.toml | 2 +- exampleSite/content/docs/configuration/index.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index b110de3a..b3c50089 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -87,7 +87,7 @@ forgejoDefaultServer = "https://v11.next.forgejo.org" showTableOfContents = false # showRelatedContent = false # relatedContentLimit = 3 - showTaxonomies = false # use showTaxonomies OR showCategoryOnly, not both + showTaxonomies = false # Enable the display of taxonomies for the related article. showCategories = true # These will show if showTaxonomies is true. showTags = true # These will show if showTaxonomies is true. showCategoriesInSecondaryColor = false # This will change the color of category badges, so the user can better distinguish between the two. Only if showTaxonomies is true. diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 9e733bb8..4d1e3c9e 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -260,7 +260,9 @@ Many of the article defaults here can be overridden on a per article basis by sp | `article.showRelatedContent` | `false` | Display related content for each post. Might required additional configuration to your `hugo.toml`. Please check the theme `hugo.toml` if you want to enable this feature and copy all the relevant _related_ entries. Also check [Hugo's docs](https://gohugo.io/content-management/related/) on related content. | | `article.relatedContentLimit` | `3` | Limit of related articles to display if `showRelatedContent` is turned on. | | `article.showTaxonomies` | `false` | Whether or not all the taxonomies related to this article are displayed. | -| `article.showCategoryOnly` | `false` | Whether or not the "category" taxonomy is displayed. `showTaxonomies` should be `false` when this param is used, otherwise duplicates will appear. | +| `article.showCategories` | `true` | Whether or not the `category` taxonomies are displayed. Requires `showTaxonomies` to be `true`. | +| `article.showTags` | `true` | Whether or not the `tag` taxonomies are displayed. Requires `showTaxonomies` to be `true`. | +| `article.showCategoriesInSecondaryColor` | `false` | This will make the `category` taxonomy badges to show in a secondary color, so the user can better distinguish between categories and tags. Requires `showTaxonomies` to be `true`. | | `article.showAuthorsBadges` | `false` | Whether the `authors` taxonomies are are displayed in the article or list header. This requires the setup of `multiple authors` and the `authors` taxonomy. Check [this page]({{< ref "multi-author" >}}) for more details on how to configure that feature. | | `article.showWordCount` | `false` | Whether or not article word counts are displayed. | | `article.showComments` | `false` | Whether or not the [comments partial]({{< ref "partials#comments" >}}) is included after the article footer. | From 167ee1fa4c041bd0ca7615d369710ebc62c2d9a6 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 24 Mar 2026 02:27:38 +0100 Subject: [PATCH 3/3] Use dictionary to pass whether to use a secondaryColor for the badge. --- layouts/partials/article-meta/basic.html | 7 ++----- layouts/partials/badge-secondary.html | 6 ------ layouts/partials/badge.html | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 14 deletions(-) delete mode 100644 layouts/partials/badge-secondary.html diff --git a/layouts/partials/article-meta/basic.html b/layouts/partials/article-meta/basic.html index 9fe54277..d83c703d 100644 --- a/layouts/partials/article-meta/basic.html +++ b/layouts/partials/article-meta/basic.html @@ -103,11 +103,8 @@ {{ if .Params.showCategories | default (.Site.Params.article.showCategories | default true) }} {{ if (eq $taxonomy "categories") }} - {{ if .Params.showCategoriesInSecondaryColor | default (.Site.Params.article.showCategoriesInSecondaryColor | default false) }} - {{ partial "badge-secondary.html" .LinkTitle }} - {{ else }} - {{ partial "badge.html" .LinkTitle }} - {{ end }} + {{ $useSecondaryColor := .Params.showCategoriesInSecondaryColor | default (.Site.Params.article.showCategoriesInSecondaryColor | default false) }} + {{ partial "badge.html" (dict "linkTitle" .LinkTitle "useSecondaryColor" $useSecondaryColor) }} {{ end }} {{ end }} diff --git a/layouts/partials/badge-secondary.html b/layouts/partials/badge-secondary.html deleted file mode 100644 index a8bf7499..00000000 --- a/layouts/partials/badge-secondary.html +++ /dev/null @@ -1,6 +0,0 @@ - - - {{ . }} - - \ No newline at end of file diff --git a/layouts/partials/badge.html b/layouts/partials/badge.html index e97bf399..bcc10ac1 100644 --- a/layouts/partials/badge.html +++ b/layouts/partials/badge.html @@ -1,6 +1,17 @@ - - {{ . }} + {{ $linkTitle := . }} + {{ $useSecondaryColor := false }} + {{ if (reflect.IsMap . ) }} + {{ $linkTitle = .linkTitle }} + {{ $useSecondaryColor = cond (not .useSecondaryColor) false .useSecondaryColor }} + {{ end }} + {{ if $useSecondaryColor }} + + {{ else }} + + {{ end }} + {{ $linkTitle }}