1

Affichage des mots-clés pour les taxonomies

This commit is contained in:
2025-11-11 01:28:40 +01:00
parent 446a62abc7
commit e533dc3fc1

View File

@@ -1,14 +1,71 @@
{{ define "main" }} {{ define "main" }}
{{ partial "hero-section.html" . }} {{ partial "hero-section.html" . }}
<main> <main>
{{ with .Content }}
<article class="article-body"> <article class="article-body">
{{ with .Content }}
{{ . }} {{ . }}
</article>
{{ end }} {{ end }}
{{- with .Pages }} {{- $pages := .Pages -}}
{{- partial "keywords.html" (.ByTitle) }} {{- if gt (len $pages) 0 -}}
{{- $sorted := $pages.ByTitle -}}
{{- $scratch := newScratch -}}
{{- $scratch.Set "group" "" -}}
{{- range $sorted -}}
{{- $title := strings.TrimSpace (default .Title .LinkTitle) -}}
{{- if $title -}}
{{- $firstChar := "" -}}
{{- if ne $title "" -}}
{{- $firstChar = slicestr $title 0 1 -}}
{{- end -}}
{{- $letterKey := "#" -}}
{{- if ne $firstChar "" -}}
{{- $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 -}}
{{- if gt (len (findRE "^[A-Z]$" $normalized)) 0 -}}
{{- $letterKey = $normalized -}}
{{- else -}}
{{- $letterKey = "#" -}}
{{- end -}}
{{- end -}}
{{- $current := $scratch.Get "group" -}}
{{- if ne $letterKey $current -}}
{{- if ne $current "" -}}
</ul>
</section>
{{- end -}}
<section>
<header>
<h2>{{ $letterKey }}</h2>
</header>
<ul class="keywords">
{{- $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 }} {{- end }}
</article>
</main> </main>
{{ end }} {{ end }}