Skip to content

Commit

Permalink
feat: allow specifying title other than page title for taxonomy (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Dec 17, 2023
1 parent 699420b commit d34bd42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
{{- $limit := $defaultLimit }}
{{- $count := $defaultCount }}
{{- $weight := 10 }}
{{- $title := "" }}
{{- with index $opts $name }}
{{- if default false .disable }}
{{- continue }}
{{- end }}
{{- with .limit }}
{{- $limit = . }}
{{- end }}
{{- with .title }}
{{- $title = . }}
{{- end }}
{{- if isset . "count" }}
{{- $count = .count }}
{{- end }}
Expand All @@ -22,6 +26,7 @@
{{- end }}
{{- $taxonomies = $taxonomies | append (dict
"name" $name
"title" $title
"terms" (first $limit $taxonomy.ByCount)
"count" $count
"weight" $weight)
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/hb/modules/blog/taxonomies/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
{{- range $taxonomies }}
{{- $name := .name }}
{{- $count := .count }}
{{- $title := .title }}
<div class="taxonomy-terms hb-module">
{{- with site.GetPage $name }}
<div class="taxonomy-terms-title h5">
<a class="text-decoration-none" href="{{ .RelPermalink }}">{{- .Title -}}</a>
<a class="text-decoration-none" href="{{ .RelPermalink }}">{{- default .Title $title -}}</a>
</div>
{{- end }}
{{- range .terms }}
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/hb/modules/blog/taxonomies/toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{- $first := true }}
{{- range $taxonomies }}
{{- $name := .name }}
{{- $title := .title }}
{{- if not .terms }}
{{- continue }}
{{- end }}
Expand All @@ -18,7 +19,7 @@
role="tab"
aria-controls="taxonomy-{{ $name }}-tab-pane"
aria-selected="{{ cond $first `true` `false` }}">
{{- $page.Title -}}
{{- default $page.Title $title -}}
</button>
</li>
{{- $first = false }}
Expand Down

0 comments on commit d34bd42

Please sign in to comment.