Skip to content

Commit

Permalink
taxonomy: fix sorting of terms on content pages #710
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Nov 1, 2023
1 parent ec482bb commit 4ebb6d9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions layouts/partials/term-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
{{- end }}
{{- $taxonomy_page := $page.Site.GetPage $taxonomy }}
{{- $terms := slice | append (index $page.Params $taxonomy) }}
{{- $term_pages := dict }}
{{- range sort $terms }}
{{- $term_pages := slice }}
{{- range $terms }}
{{- $term := trim . " " }}
{{- if not $term }}
{{- continue }}
{{- end }}
{{- $term_key := ($term | plainify | anchorize) }}
{{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }}
{{- $term_pages = $term_pages | merge (dict $term_key .) }}
{{- end }}
{{- $term_key = ($term | urlize) }}
{{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }}
{{- $term_pages = $term_pages | merge (dict $term_key .) }}
{{- $term_pages = $term_pages | append (dict "Title" (default .Data.Term .Title) "Term" . )}}
{{- else }}
{{- $term_key = ($term | urlize) }}
{{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }}
{{- $term_pages = $term_pages | append (dict "Title" (default .Data.Term .Title) "Term" . )}}
{{- end }}
{{- end }}
{{- end }}
{{- with $term_pages }}
Expand All @@ -34,9 +35,9 @@
<i class="{{ $icon }}"></i>
{{- end }}
<ul>
{{- range $term_page := . }}
{{- $to := . }}
<li><a class="term-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ default $to.Data.Term $to.Title }}</a></li>
{{- range sort . ".Title" }}
{{- $to := .Term }}
<li><a class="term-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ .Title }}</a></li>
{{- end }}
</ul>
</div>
Expand Down

0 comments on commit 4ebb6d9

Please sign in to comment.