From d34bd42e89d6e9f4157bb2a631f982deab346c9d Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Sun, 17 Dec 2023 16:54:23 +0800 Subject: [PATCH] feat: allow specifying title other than page title for taxonomy (#560) --- .../hb/modules/blog/functions/filter-taxonomies.html | 5 +++++ layouts/partials/hb/modules/blog/taxonomies/default.html | 3 ++- layouts/partials/hb/modules/blog/taxonomies/toggle.html | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html b/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html index fb0a6025..c8bac554 100644 --- a/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html +++ b/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html @@ -6,6 +6,7 @@ {{- $limit := $defaultLimit }} {{- $count := $defaultCount }} {{- $weight := 10 }} + {{- $title := "" }} {{- with index $opts $name }} {{- if default false .disable }} {{- continue }} @@ -13,6 +14,9 @@ {{- with .limit }} {{- $limit = . }} {{- end }} + {{- with .title }} + {{- $title = . }} + {{- end }} {{- if isset . "count" }} {{- $count = .count }} {{- end }} @@ -22,6 +26,7 @@ {{- end }} {{- $taxonomies = $taxonomies | append (dict "name" $name + "title" $title "terms" (first $limit $taxonomy.ByCount) "count" $count "weight" $weight) diff --git a/layouts/partials/hb/modules/blog/taxonomies/default.html b/layouts/partials/hb/modules/blog/taxonomies/default.html index e1ed5987..3ffced90 100644 --- a/layouts/partials/hb/modules/blog/taxonomies/default.html +++ b/layouts/partials/hb/modules/blog/taxonomies/default.html @@ -2,10 +2,11 @@ {{- range $taxonomies }} {{- $name := .name }} {{- $count := .count }} + {{- $title := .title }}
{{- with site.GetPage $name }} {{- end }} {{- range .terms }} diff --git a/layouts/partials/hb/modules/blog/taxonomies/toggle.html b/layouts/partials/hb/modules/blog/taxonomies/toggle.html index dc4bad5c..2702bb66 100644 --- a/layouts/partials/hb/modules/blog/taxonomies/toggle.html +++ b/layouts/partials/hb/modules/blog/taxonomies/toggle.html @@ -4,6 +4,7 @@ {{- $first := true }} {{- range $taxonomies }} {{- $name := .name }} + {{- $title := .title }} {{- if not .terms }} {{- continue }} {{- end }} @@ -18,7 +19,7 @@ role="tab" aria-controls="taxonomy-{{ $name }}-tab-pane" aria-selected="{{ cond $first `true` `false` }}"> - {{- $page.Title -}} + {{- default $page.Title $title -}} {{- $first = false }}