Ajoute les articles relatifs et harmonise la page 404
This commit is contained in:
53
themes/2026/layouts/_partials/article-related.html
Normal file
53
themes/2026/layouts/_partials/article-related.html
Normal file
@@ -0,0 +1,53 @@
|
||||
{{- $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 -}}
|
||||
|
||||
{{- if gt (len $items) 0 -}}
|
||||
<section class="article-related">
|
||||
<header>
|
||||
<h2>Articles relatifs</h2>
|
||||
</header>
|
||||
{{- partial "articles-list.html" (dict
|
||||
"Pages" $items
|
||||
"ShowDossierBeforeTitle" true
|
||||
) -}}
|
||||
</section>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user