taxonomy: allow to sort terms by overwritten title #701

This commit is contained in:
Sören Weber 2023-10-29 16:38:50 +01:00
parent 2337c924fa
commit 058460b810
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -11,27 +11,31 @@
{{- end }} {{- end }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1> <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- $lastCapital := "" }} {{- $lastCapital := "" }}
{{- range .Data.Terms.Alphabetical }} {{- $terms := slice }}
{{- $capital := substr .Page.Data.Term 0 1 | upper }} {{- range .Data.Terms }}
{{- if ne $lastCapital $capital }} {{- $terms = $terms | append (dict "Title" (default .Page.Data.Term .Page.Title) "Term" . )}}
{{- if ne $lastCapital "" }} {{- end }}
</ul> {{- range sort $terms ".Title" }}
{{- $capital := substr .Title 0 1 | upper }}
{{- $len := 0 }}
{{- range .Term.Pages }}
{{- $c:=""}}{{/* count pages of term */}}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
{{- $len = add $len 1 }}
{{- end }} {{- end }}
{{- end }}
{{- if $len }}
{{- if ne $lastCapital $capital }}
{{- if ne $lastCapital "" }}
</ul>
{{- end }}
<h2 id="{{ $capital | plainify | anchorize }}">{{ $capital }}</h2> <h2 id="{{ $capital | plainify | anchorize }}">{{ $capital }}</h2>
<ul class="columnize"> <ul class="columnize">
{{- end }} {{- end }}
{{- $c:=""}}{{/* display terms of a taxonomy */}} {{- $c:=""}}{{/* display terms of a taxonomy */}}
{{- $len := 0 }} <li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Term.Page) }}">{{ .Title }}</a> ({{ $len }})</li>
{{- range .Pages }} {{- $lastCapital = $capital }}
{{- $c:=""}}{{/* count pages of term */}} {{- end }}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
{{- $len = add $len 1 }}
{{- end }}
{{- end }}
{{- if $len }}
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ (default .Page.Data.Term .Page.Title) }}{{ if and .Page.Title (ne .Page.Data.Term .Page.Title) }} ({{ .Page.Data.Term }}){{ end }}</a> ({{ $len }})</li>
{{- end }}
{{- $lastCapital = $capital }}
{{- end }} {{- end }}
{{- if ne $lastCapital "" }} {{- if ne $lastCapital "" }}
</ul> </ul>