1
Files
2025/themes/2026/layouts/home.html
2026-03-06 15:31:03 +01:00

426 lines
15 KiB
HTML

{{- define "main" -}}
{{- $site := .Site -}}
{{- $allArticles := $site.RegularPages.ByDate.Reverse -}}
{{- $recettesPrefix := "/interets/recettes/" -}}
{{- $interestsArticles := slice -}}
{{- $recettesArticles := slice -}}
{{- $critiquesArticles := slice -}}
{{- $veilleArticles := slice -}}
{{- range $allArticles -}}
{{- if eq (partial "is-dossier-lead.html" .) "true" -}}
{{- if strings.Contains .RelPermalink "/interets/liens-interessants/" -}}
{{- $veilleArticles = $veilleArticles | append . -}}
{{- else if strings.Contains .RelPermalink $recettesPrefix -}}
{{- $recettesArticles = $recettesArticles | append . -}}
{{- else if and (strings.Contains .RelPermalink "/interets/") (not (strings.Contains .RelPermalink $recettesPrefix)) -}}
{{- $interestsArticles = $interestsArticles | append . -}}
{{- else if strings.Contains .RelPermalink "/critiques/" -}}
{{- $critiquesArticles = $critiquesArticles | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $interestsSections := slice -}}
{{- with $site.GetPage "/interets" -}}
{{- range .Sections -}}
{{- if and (not (strings.Contains .RelPermalink "/interets/liens-interessants/")) (not (strings.Contains .RelPermalink $recettesPrefix)) -}}
{{- $interestsSections = $interestsSections | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $veilleRoot := $site.GetPage "/interets/liens-interessants" -}}
{{- $recettesRoot := $site.GetPage "/interets/recettes" -}}
{{- $collectionsRoot := $site.GetPage "/collections" -}}
{{- $critiquesRoot := $site.GetPage "/critiques" -}}
{{- $externalLinksReport := dict -}}
{{- if fileExists "tools/cache/external_links.yaml" -}}
{{- $externalLinksReport = transform.Unmarshal (readFile "tools/cache/external_links.yaml") -}}
{{- end -}}
{{- partial "hero.html" . -}}
{{- $interestsUsed := slice -}}
{{- $interestsSpotlight := first 8 $interestsArticles -}}
{{- range $interestsSpotlight -}}
{{- $interestsUsed = $interestsUsed | append .File.Path -}}
{{- end -}}
{{- $interestsDeep := slice -}}
{{- range $interestsArticles -}}
{{- if and (lt (len $interestsDeep) 15) (not (in $interestsUsed .File.Path)) -}}
{{- $interestsDeep = $interestsDeep | append . -}}
{{- $interestsUsed = $interestsUsed | append .File.Path -}}
{{- end -}}
{{- end -}}
{{- $interestsSectionEntries := slice -}}
{{- range $interestsSections -}}
{{- $section := . -}}
{{- $sectionPages := slice -}}
{{- $publishedCount := 0 -}}
{{- range $section.RegularPagesRecursive.ByDate.Reverse -}}
{{- if eq (partial "is-dossier-lead.html" .) "true" -}}
{{- $publishedCount = add $publishedCount 1 -}}
{{- if and (lt (len $sectionPages) 5) (not (in $interestsUsed .File.Path)) -}}
{{- $sectionPages = $sectionPages | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if gt (len $sectionPages) 0 -}}
{{- $latestDateKey := "00000000000000" -}}
{{- with index $sectionPages 0 -}}
{{- $latestDateKey = .Date.Format "20060102150405" -}}
{{- end -}}
{{- $interestsSectionEntries = $interestsSectionEntries | append (dict
"Section" $section
"Pages" $sectionPages
"PublishedCount" $publishedCount
"LatestDateKey" $latestDateKey
) -}}
{{- end -}}
{{- end -}}
{{- $interestsSectionEntries = sort $interestsSectionEntries "LatestDateKey" "desc" -}}
{{- $recettesSpotlight := first 8 $recettesArticles -}}
{{- $collectionsEntries := slice -}}
{{- with $collectionsRoot -}}
{{- range .Sections -}}
{{- $section := . -}}
{{- $items := $section.RegularPagesRecursive.ByDate.Reverse -}}
{{- $latestItems := $items -}}
{{- $latestDateKey := "00000000000000" -}}
{{- if gt (len $items) 0 -}}
{{- with index $items 0 -}}
{{- $latestDateKey = .Date.Format "20060102150405" -}}
{{- end -}}
{{- end -}}
{{- $collectionsEntries = $collectionsEntries | append (dict
"Section" $section
"Items" (len $items)
"LatestItems" $latestItems
"LatestDateKey" $latestDateKey
) -}}
{{- end -}}
{{- end -}}
{{- $collectionsEntries = sort $collectionsEntries "LatestDateKey" "desc" -}}
{{- $critiquesCategoryDefs := slice -}}
{{- $critiquesCategoryDefs = $critiquesCategoryDefs | append (dict "Path" "/critiques/films") -}}
{{- $critiquesCategoryDefs = $critiquesCategoryDefs | append (dict "Path" "/critiques/series") -}}
{{- $critiquesCategoryDefs = $critiquesCategoryDefs | append (dict "Path" "/critiques/jeux-video") -}}
{{- $critiquesCategoryDefs = $critiquesCategoryDefs | append (dict "Path" "/critiques/livres") -}}
{{- $critiquesCategoryEntries := slice -}}
{{- range $critiqueDef := $critiquesCategoryDefs -}}
{{- $critiquePath := index $critiqueDef "Path" -}}
{{- $critiqueSection := $site.GetPage $critiquePath -}}
{{- $critiquePages := slice -}}
{{- with $critiqueSection -}}
{{- range .RegularPagesRecursive.ByDate.Reverse -}}
{{- if eq (partial "is-dossier-lead.html" .) "true" -}}
{{- $critiquePages = $critiquePages | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if gt (len $critiquePages) 0 -}}
{{- $latestDateKey := "00000000000000" -}}
{{- with index $critiquePages 0 -}}
{{- $latestDateKey = .Date.Format "20060102150405" -}}
{{- end -}}
{{- $critiquesCategoryEntries = $critiquesCategoryEntries | append (dict
"Section" $critiqueSection
"Pages" (first 8 $critiquePages)
"LatestDateKey" $latestDateKey
) -}}
{{- end -}}
{{- end -}}
{{- $critiquesCategoryEntries = sort $critiquesCategoryEntries "LatestDateKey" "desc" -}}
<main class="home-main">
{{- if gt (len $interestsSpotlight) 0 -}}
<section class="home-spotlight">
<header>
<h2>À la une</h2>
</header>
{{ partial "spotlight-block.html" (dict
"Cards" $interestsSpotlight
"FeedPages" $interestsSpotlight
"FeedTitle" "Fil de publication"
"ShowFeedTitle" false
"FeedRich" true
"ShowSection" true
"AsideFirst" false
) }}
</section>
{{- end -}}
{{- if gt (len $interestsDeep) 0 -}}
<section class="home-deep">
<header>
<h2>Articles de fond</h2>
</header>
{{ partial "articles-list.html" (dict "Pages" $interestsDeep "Context" . "ShowDossierBeforeTitle" true) }}
</section>
{{- end -}}
<section class="home-books">
<header>
<h2>Mes livres</h2>
<p>Si vous aimez ce blog, vous apprécierez mes livres. En les achetant, vous m'aidez à continuer de le faire vivre.</p>
</header>
<div>
{{ partial "oeuvres/l-anankeisme.html" . }}
{{ partial "oeuvres/l-humain-cette-espece-primitive.html" . }}
</div>
</section>
{{- if gt (len $interestsSectionEntries) 0 -}}
<section class="home-rubrics">
<header>
<h2>Rubriques</h2>
</header>
<div>
{{- range $interestsSectionEntries -}}
{{- $section := index . "Section" -}}
{{- $sectionPages := index . "Pages" -}}
{{- $publishedCount := index . "PublishedCount" -}}
{{- if gt (len $sectionPages) 0 -}}
<article>
<header>
<h3><a href="{{ $section.RelPermalink }}">{{ with $section.LinkTitle }}{{ . }}{{ else }}{{ $section.Title }}{{ end }}</a></h3>
<p>{{ $publishedCount }} {{ if eq $publishedCount 1 }}article{{ else }}articles{{ end }}</p>
</header>
<ul>
{{- range $sectionPages -}}
{{- $page := . -}}
{{- $dossierTitle := "" -}}
{{- $dossierFirstPage := false -}}
{{- with $page.Params.dossier -}}
{{- with index . 0 -}}
{{- $dossierTitle = . -}}
{{- $dossierFirstPage = partial "dossier-first-page.html" $page -}}
{{- end -}}
{{- end -}}
<li>
{{- with $dossierFirstPage -}}
{{- with $dossierTitle -}}
<p><a href="{{ $dossierFirstPage.RelPermalink }}">{{ $dossierTitle }}</a></p>
{{- end -}}
{{- end -}}
<a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a>
{{- with $page.Date -}}<time datetime="{{ . }}">{{ . | time.Format "02/01/2006" }}</time>{{- end -}}
</li>
{{- end -}}
</ul>
</article>
{{- end -}}
{{- end -}}
</div>
</section>
{{- end -}}
{{- if gt (len $critiquesArticles) 0 -}}
<section class="home-critiques-title">
<header>
<h2>
{{- with $critiquesRoot -}}
<a href="{{ .RelPermalink }}">{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}</a>
{{- else -}}
Critiques
{{- end -}}
</h2>
</header>
</section>
{{- end -}}
{{- range $critiqueIndex, $critiqueEntry := $critiquesCategoryEntries -}}
{{- $critiqueSection := index $critiqueEntry "Section" -}}
{{- $critiqueSpotlight := index $critiqueEntry "Pages" -}}
{{- if gt (len $critiqueSpotlight) 0 -}}
<section class="home-critiques-category">
<header>
<h2>
{{- with $critiqueSection -}}
<a href="{{ .RelPermalink }}">{{- with .LinkTitle -}}{{ . }}{{- else -}}{{ .Title }}{{- end -}}</a>
{{- else -}}
Critiques
{{- end -}}
</h2>
</header>
{{ partial "spotlight-block.html" (dict
"Cards" $critiqueSpotlight
"FeedPages" $critiqueSpotlight
"FeedTitle" "Dernières critiques"
"ShowFeedTitle" false
"FeedRich" true
"ShowSection" false
"AsideFirst" (eq (mod $critiqueIndex 2) 1)
) }}
</section>
{{- end -}}
{{- end -}}
{{- if gt (len $veilleArticles) 0 -}}
<aside class="home-watch">
<header>
<h2>
{{- with $veilleRoot -}}
<a href="{{ .RelPermalink }}">Veille</a>
{{- else -}}
Veille
{{- end -}}
</h2>
</header>
<div>
{{- range first 10 $veilleArticles -}}
{{- $page := . -}}
{{- $originLink := "" -}}
{{- with $page.Params.links -}}
{{- range . -}}
{{- if and (eq $originLink "") (not .archive) -}}
{{- with .url -}}
{{- $originLink = . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $originHost := "" -}}
{{- $statusTone := "unknown" -}}
{{- $statusLabel := "État inconnu" -}}
{{- $statusTitle := "" -}}
{{- $statusChecked := "" -}}
{{- with partial "external-link-status.html" (dict "URL" $originLink "Report" $externalLinksReport) -}}
{{- with index . "Host" -}}
{{- $originHost = . -}}
{{- end -}}
{{- with index . "Tone" -}}
{{- $statusTone = . -}}
{{- end -}}
{{- with index . "Label" -}}
{{- $statusLabel = . -}}
{{- end -}}
{{- with index . "Title" -}}
{{- $statusTitle = . -}}
{{- end -}}
{{- with index . "CheckedAt" -}}
{{- $statusChecked = . -}}
{{- end -}}
{{- end -}}
{{- $image := false -}}
{{- with $page.Params.cover -}}
{{- $image = $page.Resources.GetMatch . -}}
{{- end -}}
<article>
<a href="{{ $page.RelPermalink }}">
<figure>
{{- with $image -}}
{{- $resized := .Fill "166x91 webp q80" -}}
<img src="{{ $resized.RelPermalink }}" alt="Capture du lien {{ $page.Title }}" loading="lazy">
{{- end -}}
</figure>
</a>
<div>
<h3><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></h3>
{{- with $page.Summary -}}
<p>{{ . | plainify | truncate 140 }}</p>
{{- end -}}
<footer>
<p>
{{- with $page.Date -}}<time datetime="{{ . }}">{{ . | time.Format "02/01/2006" }}</time>{{- end -}}
{{- if and $page.Date $originHost -}}<span>·</span>{{- end -}}
{{- with $originHost -}}
{{- if $originLink -}}
<a href="{{ $originLink }}" title="Ouvrir le lien externe {{ . }}" rel="noopener noreferrer nofollow">{{ . }}</a>
{{- else -}}
<span>{{ . }}</span>
{{- end -}}
{{- end -}}
</p>
<p>
<strong data-state="{{ $statusTone }}"{{ with $statusTitle }} title="{{ . }}"{{ end }}>{{ $statusLabel }}</strong>
{{- with $statusChecked -}}<span>·</span><time datetime="{{ . }}">Vérifié {{ . | time.Format "02/01/2006" }}</time>{{- end -}}
</p>
</footer>
</div>
</article>
{{- end -}}
</div>
</aside>
{{- end -}}
{{- if gt (len $recettesSpotlight) 0 -}}
<section class="home-recipes">
<header>
<h2>
{{- with $recettesRoot -}}
<a href="{{ .RelPermalink }}">{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}</a>
{{- else -}}
Recettes
{{- end -}}
</h2>
</header>
{{ partial "spotlight-block.html" (dict
"Cards" $recettesSpotlight
"FeedPages" $recettesSpotlight
"FeedTitle" "Dernières recettes"
"ShowFeedTitle" false
"FeedRich" true
"ShowSection" false
"AsideFirst" false
) }}
</section>
{{- end -}}
{{- if gt (len $collectionsEntries) 0 -}}
<section class="home-collections collections-section">
<header>
<h2>
{{- with $collectionsRoot -}}
<a href="{{ .RelPermalink }}">{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}</a>
{{- else -}}
Collections
{{- end -}}
</h2>
</header>
<div>
{{- range $collectionsEntries -}}
{{- $section := index . "Section" -}}
{{- $latestItems := index . "LatestItems" -}}
<article>
<h3><a href="{{ $section.RelPermalink }}" title="{{ with $section.LinkTitle }}{{ . }}{{ else }}{{ $section.Title }}{{ end }}">{{ with $section.LinkTitle }}{{ . }}{{ else }}{{ $section.Title }}{{ end }}</a></h3>
{{- if gt (len $latestItems) 0 -}}
<ul>
{{- range $latestItems -}}
{{- $item := . -}}
{{- $itemImage := false -}}
{{- with $item.Params.cover -}}
{{- $itemImage = $item.Resources.GetMatch . -}}
{{- end -}}
<li>
<a href="{{ $item.RelPermalink }}" title="{{ $item.Title }}">
<figure>
{{- with $itemImage -}}
{{- $resized := .Resize "x128 webp q80" -}}
<img src="{{ $resized.RelPermalink }}" alt="{{ $item.Title }}" title="{{ $item.Title }}" loading="lazy">
{{- end -}}
</figure>
</a>
</li>
{{- end -}}
</ul>
{{- end -}}
<p>
<span>{{ index . "Items" }} objets</span>
{{- range $section.Sections.ByTitle -}}
<a href="{{ .RelPermalink }}" title="{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}">{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}</a>
{{- end -}}
</p>
</article>
{{- end -}}
</div>
</section>
{{- end -}}
</main>
{{- end -}}