Affichage des mots-clés pour les taxonomies
This commit is contained in:
@@ -1,14 +1,71 @@
|
||||
{{ define "main" }}
|
||||
{{ partial "hero-section.html" . }}
|
||||
<main>
|
||||
{{ with .Content }}
|
||||
<article class="article-body">
|
||||
{{ with .Content }}
|
||||
{{ . }}
|
||||
</article>
|
||||
{{ end }}
|
||||
|
||||
{{- with .Pages }}
|
||||
{{- partial "keywords.html" (.ByTitle) }}
|
||||
{{- $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 := "" -}}
|
||||
{{- 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 }}
|
||||
</article>
|
||||
</main>
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user