1
Files
2025/themes/2026/layouts/taxonomy.html
2026-02-21 01:50:39 +01:00

64 lines
2.0 KiB
HTML

{{ define "main" }}
{{ partial "hero-section.html" . }}
<main>
{{ with .Content }}
<article>
{{ . }}
</article>
{{ end }}
{{- $pages := .Pages -}}
{{- if gt (len $pages) 0 -}}
{{- $sorted := $pages.ByTitle -}}
{{- $scratch := newScratch -}}
{{- $scratch.Set "group" "" -}}
{{- range $sorted -}}
{{- $title := strings.TrimSpace (default .Title .LinkTitle) -}}
{{- if $title -}}
{{- $firstChar := slicestr $title 0 1 -}}
{{- $upper := strings.ToUpper $firstChar -}}
{{- $normalized := $upper -}}
{{- $normalized = replaceRE "[ÀÁÂÃÄÅĀĂĄÆ]" "A" $normalized -}}
{{- $normalized = replaceRE "[ÇĆĈĊČ]" "C" $normalized -}}
{{- $normalized = replaceRE "[ÈÉÊËĒĔĖĘĚ]" "E" $normalized -}}
{{- $normalized = replaceRE "[ÌÍÎÏĨĪĬĮİ]" "I" $normalized -}}
{{- $normalized = replaceRE "[ÑŃŅŇ]" "N" $normalized -}}
{{- $normalized = replaceRE "[ÒÓÔÕÖŌŎŐØŒ]" "O" $normalized -}}
{{- $normalized = replaceRE "[ÙÚÛÜŨŪŬŮŰŲ]" "U" $normalized -}}
{{- $normalized = replaceRE "[ÝŸŶ]" "Y" $normalized -}}
{{- $letterKey := "#" -}}
{{- if gt (len (findRE "^[A-Z]$" $normalized)) 0 -}}
{{- $letterKey = $normalized -}}
{{- end -}}
{{- $current := $scratch.Get "group" -}}
{{- if ne $letterKey $current -}}
{{- if ne $current "" -}}
</ul>
</section>
{{- end -}}
<section>
<header><h2>{{ $letterKey }}</h2></header>
<ul>
{{- $scratch.Set "group" $letterKey -}}
{{- end -}}
<li>
<a href="{{ .RelPermalink }}">{{ $title }}</a>
{{ with .Pages }}<sub>{{ len . }}</sub>{{ else }}<sub>0</sub>{{ end }}
</li>
{{- end -}}
{{- end -}}
{{- if ne ($scratch.Get "group") "" -}}
</ul>
</section>
{{- end -}}
{{- else -}}
<p>Aucun mot-clé disponible pour cette taxonomie.</p>
{{- end -}}
</main>
{{ end }}