1
Files
2025/themes/2026/layouts/_partials/list-layout.html
2026-02-21 01:50:39 +01:00

137 lines
4.4 KiB
HTML

{{- $pages := .Pages -}}
{{- $context := .Context -}}
{{- $spotlightTitle := default "À la une" .SpotlightTitle -}}
{{- $showInterestingLinksMeta := false -}}
{{- $excludeInterestingLinks := false -}}
{{- $groupBySubSections := false -}}
{{- $subSections := slice -}}
{{- $externalLinksReport := dict -}}
{{- if fileExists "tools/cache/external_links.yaml" -}}
{{- $externalLinksReport = transform.Unmarshal (readFile "tools/cache/external_links.yaml") -}}
{{- end -}}
{{- with $context -}}
{{- if eq (strings.TrimSuffix "/" .RelPermalink) "/interets" -}}
{{- $excludeInterestingLinks = true -}}
{{- end -}}
{{- if and (eq .Kind "section") (gt (len .Sections) 0) -}}
{{- $groupBySubSections = true -}}
{{- range .Sections -}}
{{- $subSections = $subSections | append . -}}
{{- end -}}
{{- end -}}
{{- if eq .RelPermalink "/interets/liens-interessants/" -}}
{{- $showInterestingLinksMeta = true -}}
{{- end -}}
{{- end -}}
{{- if $excludeInterestingLinks -}}
{{- $filteredPages := slice -}}
{{- range $pages -}}
{{- if not (strings.HasPrefix .RelPermalink "/interets/liens-interessants/") -}}
{{- $filteredPages = $filteredPages | append . -}}
{{- end -}}
{{- end -}}
{{- $pages = $filteredPages -}}
{{- end -}}
{{- $spotlightPages := first 8 $pages -}}
{{- $spotlightPermalinks := slice -}}
{{- range $spotlightPages -}}
{{- $spotlightPermalinks = $spotlightPermalinks | append .RelPermalink -}}
{{- end -}}
{{- $remainingPages := $pages -}}
{{- if gt (len $spotlightPermalinks) 0 -}}
{{- $remainingPages = where $pages "RelPermalink" "not in" $spotlightPermalinks -}}
{{- end -}}
{{- if gt (len $spotlightPages) 0 -}}
<section class="listing-spotlight">
<header>
<h2>{{ $spotlightTitle }}</h2>
</header>
{{ partial "spotlight-block.html" (dict
"Cards" $spotlightPages
"FeedPages" $spotlightPages
"ShowFeedTitle" false
"FeedRich" true
"ShowSection" true
"AsideFirst" false
) }}
</section>
{{- end -}}
{{- if gt (len $remainingPages) 0 -}}
{{- if and $groupBySubSections (gt (len $subSections) 0) -}}
{{- $groupedPermalinks := slice -}}
{{- $groupedSections := slice -}}
{{- range $subSections -}}
{{- $subSection := . -}}
{{- $subSectionPages := slice -}}
{{- range $remainingPages -}}
{{- if strings.HasPrefix .RelPermalink $subSection.RelPermalink -}}
{{- $subSectionPages = $subSectionPages | append . -}}
{{- $groupedPermalinks = $groupedPermalinks | append .RelPermalink -}}
{{- end -}}
{{- end -}}
{{- if gt (len $subSectionPages) 0 -}}
{{- $latestDateKey := "00000000000000" -}}
{{- with index $subSectionPages 0 -}}
{{- $latestDateKey = .Date.Format "20060102150405" -}}
{{- end -}}
{{- $groupedSections = $groupedSections | append (dict
"Section" $subSection
"Pages" $subSectionPages
"LatestDateKey" $latestDateKey
) -}}
{{- end -}}
{{- end -}}
{{- $groupedSections = sort $groupedSections "LatestDateKey" "desc" -}}
{{- range $groupedSections -}}
{{- $subSection := index . "Section" -}}
{{- $subSectionPages := index . "Pages" -}}
<section class="listing-articles">
<header>
<h2>{{ with $subSection.LinkTitle }}{{ . }}{{ else }}{{ $subSection.Title }}{{ end }}</h2>
</header>
{{ partial "articles-list.html" (dict
"Pages" $subSectionPages
"Context" $context
"ShowDossierBeforeTitle" true
"ShowInterestingLinksMeta" $showInterestingLinksMeta
"ExternalLinksReport" $externalLinksReport
) }}
</section>
{{- end -}}
{{- $ungroupedPages := $remainingPages -}}
{{- if gt (len $groupedPermalinks) 0 -}}
{{- $ungroupedPages = where $remainingPages "RelPermalink" "not in" $groupedPermalinks -}}
{{- end -}}
{{- if gt (len $ungroupedPages) 0 -}}
<section class="listing-articles">
<header>
<h2>Autres articles</h2>
</header>
{{ partial "articles-list.html" (dict
"Pages" $ungroupedPages
"Context" $context
"ShowDossierBeforeTitle" true
"ShowInterestingLinksMeta" $showInterestingLinksMeta
"ExternalLinksReport" $externalLinksReport
) }}
</section>
{{- end -}}
{{- else -}}
<section class="listing-articles">
<header>
<h2>Tous les articles</h2>
</header>
{{ partial "articles-list.html" (dict
"Pages" $remainingPages
"Context" $context
"ShowDossierBeforeTitle" true
"ShowInterestingLinksMeta" $showInterestingLinksMeta
"ExternalLinksReport" $externalLinksReport
) }}
</section>
{{- end -}}
{{- end -}}