1
Files
2025/themes/2026/layouts/_partials/article-related.html

49 lines
1.4 KiB
HTML

{{- $excludePrefix := "interets/liens-interessants/" -}}
{{- $excludeCurrent := false -}}
{{- $currentHasDate := false -}}
{{- with .File -}}
{{- if strings.HasPrefix .Path $excludePrefix -}}
{{- $excludeCurrent = true -}}
{{- end -}}
{{- end -}}
{{- with .Params.date -}}
{{- $currentHasDate = true -}}
{{- end -}}
{{- if not $currentHasDate -}}
{{- $excludeCurrent = true -}}
{{- end -}}
{{- if not $excludeCurrent -}}
{{- $related := site.RegularPages.Related . -}}
{{- $items := slice -}}
{{- range $related -}}
{{- $excludeCandidate := false -}}
{{- $sameDossier := false -}}
{{- $candidateHasDate := false -}}
{{- with .File -}}
{{- if strings.HasPrefix .Path $excludePrefix -}}
{{- $excludeCandidate = true -}}
{{- end -}}
{{- end -}}
{{- with .Params.date -}}
{{- $candidateHasDate = true -}}
{{- end -}}
{{- if gt (len (intersect (default (slice) $.Params.dossier) (default (slice) .Params.dossier))) 0 -}}
{{- $sameDossier = true -}}
{{- end -}}
{{- if and $candidateHasDate (not $excludeCandidate) (not $sameDossier) (ne .RelPermalink $.RelPermalink) -}}
{{- $items = $items | append . -}}
{{- end -}}
{{- if ge (len $items) 3 -}}
{{- break -}}
{{- end -}}
{{- end -}}
{{- partial "article-pages-block.html" (dict
"Title" "Articles relatifs"
"Class" "article-related"
"Pages" $items
"ShowDossierBeforeTitle" true
) -}}
{{- end -}}