1
Files
2025/themes/2026/layouts/_partials/dossier-first-page.html
2026-02-21 01:50:39 +01:00

32 lines
1.1 KiB
HTML

{{- $page := . -}}
{{- $firstPage := false -}}
{{- with $page.Params.dossier -}}
{{- $dossierID := index . 0 -}}
{{- if $dossierID -}}
{{- $group := where site.RegularPages "Params.dossier" "intersect" (slice $dossierID) -}}
{{- if gt (len $group) 0 -}}
{{- $weighted := slice -}}
{{- range $group -}}
{{- if isset .Params "weight" -}}
{{- $weighted = $weighted | append . -}}
{{- end -}}
{{- end -}}
{{- $candidates := $group -}}
{{- if gt (len $weighted) 0 -}}
{{- $sortedByWeight := sort $weighted "Weight" "asc" -}}
{{- $minWeight := (index $sortedByWeight 0).Weight -}}
{{- $candidates = where $sortedByWeight "Weight" $minWeight -}}
{{- end -}}
{{- $sortedByDate := sort $candidates "Date" "asc" -}}
{{- $firstDate := (index $sortedByDate 0).Date -}}
{{- $sameDate := where $sortedByDate "Date" $firstDate -}}
{{- $firstPage = index (sort $sameDate "RelPermalink" "asc") 0 -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $firstPage -}}