1
Files
2025/themes/2026/layouts/_partials/card.html

185 lines
5.8 KiB
HTML

{{- $page := . -}}
{{- $showSection := true -}}
{{- $linkSection := true -}}
{{- $showMeta := true -}}
{{- $showDossierBeforeTitle := false -}}
{{- $showInterestingLinksMeta := false -}}
{{- $thumbnailSize := "large" -}}
{{- $externalLinksReport := dict -}}
{{- if reflect.IsMap . -}}
{{- if isset . "Page" -}}
{{- $page = index . "Page" -}}
{{- end -}}
{{- if isset . "ShowSection" -}}
{{- $showSection = index . "ShowSection" -}}
{{- end -}}
{{- if isset . "LinkSection" -}}
{{- $linkSection = index . "LinkSection" -}}
{{- end -}}
{{- if isset . "ShowMeta" -}}
{{- $showMeta = index . "ShowMeta" -}}
{{- end -}}
{{- if isset . "ShowDossierBeforeTitle" -}}
{{- $showDossierBeforeTitle = index . "ShowDossierBeforeTitle" -}}
{{- end -}}
{{- if isset . "ShowInterestingLinksMeta" -}}
{{- $showInterestingLinksMeta = index . "ShowInterestingLinksMeta" -}}
{{- end -}}
{{- if isset . "ThumbnailSize" -}}
{{- $thumbnailSize = index . "ThumbnailSize" -}}
{{- end -}}
{{- if isset . "ExternalLinksReport" -}}
{{- $externalLinksReport = index . "ExternalLinksReport" -}}
{{- end -}}
{{- end -}}
{{- $thumbnailTransform := "700x394" -}}
{{- if eq $thumbnailSize "small" -}}
{{- $thumbnailTransform = "340x191" -}}
{{- else if eq $thumbnailSize "spotlight" -}}
{{- $thumbnailTransform = "900x506" -}}
{{- end -}}
{{- $thumbnailOptions := printf "%s webp q80" $thumbnailTransform -}}
{{- $coverPath := $page.Params.cover -}}
{{- $image := false -}}
{{- if $coverPath -}}
{{- if strings.HasSuffix $coverPath ".yaml" -}}
{{- $coverAbsPath := printf "%s%s" $page.File.Dir $coverPath -}}
{{- $coverRaw := readFile $coverAbsPath -}}
{{- $coverData := $coverRaw | transform.Unmarshal -}}
{{- with $coverData.file -}}
{{- $image = $page.Resources.GetMatch . -}}
{{- end -}}
{{- else -}}
{{- $image = $page.Resources.GetMatch $coverPath -}}
{{- end -}}
{{- end -}}
{{- $dossierTitle := "" -}}
{{- $dossierFirstPage := false -}}
{{- with $page.Params.dossier -}}
{{- with index . 0 -}}
{{- $dossierTitle = . -}}
{{- if $showDossierBeforeTitle -}}
{{- $dossierFirstPage = partial "dossier-first-page.html" $page -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $originLink := "" -}}
{{- $originHost := "" -}}
{{- $statusTone := "unknown" -}}
{{- $statusLabel := "État inconnu" -}}
{{- $statusTitle := "" -}}
{{- $statusChecked := "" -}}
{{- if and $showMeta $showInterestingLinksMeta -}}
{{- with $page.Params.links -}}
{{- range . -}}
{{- if and (eq $originLink "") (not .archive) -}}
{{- with .url -}}
{{- $originLink = . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- 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 -}}
{{- end -}}
<article class="card">
{{- if $showDossierBeforeTitle -}}
<header>
<a href="{{ $page.RelPermalink }}">
<figure>
{{- with $image -}}
{{- $resized := .Fill $thumbnailOptions -}}
<img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy">
{{- end -}}
</figure>
</a>
{{- with $dossierTitle -}}
{{- with $dossierFirstPage -}}
<p><a href="{{ .RelPermalink }}">{{ $dossierTitle }}</a></p>
{{- end -}}
{{- end -}}
<h3><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></h3>
</header>
{{- else -}}
<a href="{{ $page.RelPermalink }}">
<figure>
{{- with $image -}}
{{- $resized := .Fill $thumbnailOptions -}}
<img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy">
{{- end -}}
</figure>
<h3>{{ $page.Title }}</h3>
</a>
{{- end -}}
{{- with $page.Summary -}}
<p>{{ . | plainify | truncate 180 }}</p>
{{- end -}}
{{- if $showMeta -}}
{{- if $showInterestingLinksMeta -}}
<footer class="external-link-meta">
<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>
{{- else -}}
<p>
{{- with $page.Date -}}
<time datetime="{{ . }}">{{ . | time.Format "02/01/2006" }}</time>
{{- end -}}
{{- if $showSection -}}
{{- with $page.Parent -}}
<span>·</span>
{{- if $linkSection -}}
<a href="{{ .RelPermalink }}">{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}</a>
{{- else -}}
<span>{{ with .LinkTitle }}{{ . }}{{ else }}{{ .Title }}{{ end }}</span>
{{- end -}}
{{- end -}}
{{- end -}}
{{- if and (not $showDossierBeforeTitle) $dossierTitle -}}
<span>·</span>
<strong>{{ $dossierTitle }}</strong>
{{- end -}}
{{- if and (not $page.IsSection) (ge $page.ReadingTime 5) -}}
<span>· {{ $page.ReadingTime }} min</span>
{{- end -}}
</p>
{{- end -}}
{{- end -}}
</article>