192 lines
7.1 KiB
HTML
192 lines
7.1 KiB
HTML
{{- $page := .Page -}}
|
||
{{- $coverPath := .Params.cover -}}
|
||
{{- $isInterestingLink := strings.HasPrefix .RelPermalink "/interets/liens-interessants/" -}}
|
||
{{- $showCover := and $coverPath (not $isInterestingLink) -}}
|
||
{{- $linksParam := .Params.links -}}
|
||
{{- $links := slice -}}
|
||
{{- if $linksParam -}}
|
||
{{- $type := printf "%T" $linksParam -}}
|
||
{{- if hasPrefix $type "[]" -}}
|
||
{{- $links = $linksParam -}}
|
||
{{- else -}}
|
||
{{- $links = slice $linksParam -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
|
||
{{- $originLink := dict -}}
|
||
{{- if $isInterestingLink -}}
|
||
{{- range $links -}}
|
||
{{- if and (eq (len $originLink) 0) .url -}}
|
||
{{- $rawLabel := default "" (default .name .text) -}}
|
||
{{- $normalizedLabel := lower (replace (replace (printf "%v" $rawLabel) "'" "") "’" "") -}}
|
||
{{- if eq $normalizedLabel "page dorigine" -}}
|
||
{{- $originLink = . -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- if and (eq (len $originLink) 0) (gt (len $links) 0) -}}
|
||
{{- range $links -}}
|
||
{{- if and (eq (len $originLink) 0) .url -}}
|
||
{{- $originLink = . -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
|
||
{{- $originURL := "" -}}
|
||
{{- $originLabel := "Page d'origine" -}}
|
||
{{- if gt (len $originLink) 0 -}}
|
||
{{- $originURL = default "" (index $originLink "url") -}}
|
||
{{- with (default (index $originLink "name") (index $originLink "text")) -}}
|
||
{{- $originLabel = . -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- $originIsExternal := strings.HasPrefix $originURL "http" -}}
|
||
|
||
{{- $remainingLinks := $links -}}
|
||
{{- if and $isInterestingLink (ne $originURL "") -}}
|
||
{{- $remainingLinks = slice -}}
|
||
{{- range $links -}}
|
||
{{- if and .url (ne .url $originURL) -}}
|
||
{{- $remainingLinks = $remainingLinks | append . -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
|
||
{{- $coverData := dict -}}
|
||
{{- if $coverPath -}}
|
||
{{- $coverName := path.Base $coverPath | replaceRE "\\.[^.]+$" "" -}}
|
||
{{- $coverDataFile := $page.Resources.Get (printf "data/images/%s.yaml" $coverName) -}}
|
||
{{- if not $coverDataFile -}}
|
||
{{- $coverDataFile = $page.Resources.Get (printf "data/%s.yaml" $coverName) -}}
|
||
{{- end -}}
|
||
{{- if $coverDataFile -}}
|
||
{{- $coverData = $coverDataFile.Content | transform.Unmarshal -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
|
||
{{- $coverImage := false -}}
|
||
{{- $coverDisplay := false -}}
|
||
{{- if $showCover -}}
|
||
{{- $coverImage = $page.Resources.GetMatch $coverPath -}}
|
||
{{- if $coverImage -}}
|
||
{{- $coverDisplay = $coverImage -}}
|
||
{{- if ne $coverDisplay.MediaType.SubType "svg" -}}
|
||
{{- $coverWidth := $coverDisplay.Width -}}
|
||
{{- if gt $coverDisplay.Width 1480 -}}
|
||
{{- $coverWidth = 1480 -}}
|
||
{{- end -}}
|
||
{{- $coverDisplay = $coverImage.Resize (printf "%dx webp q80" $coverWidth) -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
|
||
{{- $coverImageTitle := default .Title (index $coverData "title") -}}
|
||
{{- $coverTitle := index $coverData "title" -}}
|
||
{{- $coverDescription := index $coverData "description" -}}
|
||
{{- $coverAttribution := index $coverData "attribution" -}}
|
||
{{- $coverPrompt := index $coverData "prompt" -}}
|
||
{{- $hasCoverImage := and $showCover $coverImage -}}
|
||
{{- $hasCoverMeta := or $coverTitle $coverDescription $coverAttribution $coverPrompt -}}
|
||
{{- $showReadingTime := ge .ReadingTime 5 -}}
|
||
{{- $hasPublication := $showReadingTime -}}
|
||
{{- with .Date -}}
|
||
{{- $hasPublication = true -}}
|
||
{{- end -}}
|
||
{{- $breadcrumbsMarkup := partial "breadcrumbs.html" . -}}
|
||
{{- $hasBreadcrumbs := ne (strings.TrimSpace $breadcrumbsMarkup) "" -}}
|
||
{{- $pageLinksMarkup := partial "page-links.html" (dict
|
||
"Page" .
|
||
"LinkClass" "ui-button"
|
||
"Links" $remainingLinks
|
||
) -}}
|
||
{{- $hasPageLinks := ne (strings.TrimSpace $pageLinksMarkup) "" -}}
|
||
{{- $hasOriginCallout := and $isInterestingLink (ne $originURL "") -}}
|
||
{{- $hasMetaMain := or $hasBreadcrumbs $hasPublication $hasPageLinks $hasOriginCallout -}}
|
||
{{- $showCoverMeta := and (not $isInterestingLink) $coverPath $hasCoverMeta -}}
|
||
{{- $hasMetaBlock := or $hasCoverImage $hasMetaMain $showCoverMeta -}}
|
||
|
||
<header class="article-header{{ if $isInterestingLink }} article-header--interesting-link{{ end }}">
|
||
{{ partialCached "header-brand.html" .Site .Site.Title (.Site.Params.logo | default "logo-large.png") }}
|
||
<h1>{{ .Title }}</h1>
|
||
|
||
{{- if $hasMetaBlock -}}
|
||
<section class="article-meta-block{{ if not $hasCoverImage }} article-meta-block--without-cover{{ end }}">
|
||
{{- if $hasCoverImage -}}
|
||
<figure class="article-cover">
|
||
<a href="{{ $coverImage.RelPermalink }}" title="Cliquez pour agrandir l'image d'en-tête">
|
||
<img src="{{ $coverDisplay.RelPermalink }}" alt="{{ $coverImageTitle }}" title="{{ $coverImageTitle }}">
|
||
</a>
|
||
</figure>
|
||
{{- end -}}
|
||
|
||
<section class="article-meta">
|
||
<section class="article-meta-main">
|
||
{{- if $hasBreadcrumbs -}}
|
||
{{- $breadcrumbsMarkup | safeHTML -}}
|
||
{{- end -}}
|
||
|
||
{{- if $hasPublication -}}
|
||
<p class="article-publication">
|
||
{{ with .Date }}
|
||
{{- $timePart := . | time.Format "15:04:05" -}}
|
||
<time datetime="{{ . }}">
|
||
{{- if eq $timePart "00:00:00" -}}
|
||
{{ . | time.Format "02/01/2006" }}
|
||
{{- else -}}
|
||
{{ . | time.Format "02/01/2006 à 15:04" }}
|
||
{{- end -}}
|
||
</time>
|
||
{{- if $showReadingTime -}}
|
||
<span>·</span>
|
||
{{- end -}}
|
||
{{ end }}
|
||
{{- if $showReadingTime -}}
|
||
<span>{{ .ReadingTime }} min</span>
|
||
{{- end -}}
|
||
</p>
|
||
{{- end -}}
|
||
|
||
{{- if $hasOriginCallout -}}
|
||
<section class="article-origin-link" aria-label="Lien d'origine">
|
||
<p class="article-origin-link-kicker">À lire avant mon commentaire</p>
|
||
<p class="article-origin-link-hint">Ce billet n'est qu'une note de lecture. Lisez d'abord la source pour avoir le contexte complet.</p>
|
||
<p class="article-origin-link-button">
|
||
<a href="{{ $originURL }}" class="ui-button{{ if $originIsExternal }} link-external{{ end }}"{{ if $originIsExternal }} rel="noreferrer noopener"{{ end }} title="Lire la page d'origine">
|
||
<span class="article-origin-link-button-label">{{ $originLabel }}</span>
|
||
<span class="article-origin-link-button-url">{{ $originURL }}</span>
|
||
</a>
|
||
</p>
|
||
</section>
|
||
{{- end -}}
|
||
|
||
{{- if $hasPageLinks -}}
|
||
{{- $pageLinksMarkup | safeHTML -}}
|
||
{{- end -}}
|
||
</section>
|
||
|
||
{{- if $showCoverMeta -}}
|
||
<section class="cover-meta">
|
||
<h2>Image d'en-tête</h2>
|
||
{{- with $coverTitle -}}
|
||
<p class="cover-title">{{ . | markdownify }}</p>
|
||
{{- end -}}
|
||
{{- with $coverDescription -}}
|
||
<p class="cover-description">{{ . | markdownify }}</p>
|
||
{{- end -}}
|
||
{{- with $coverAttribution -}}
|
||
<p class="cover-attribution"><strong>Attribution:</strong> <span>{{ . | markdownify }}</span></p>
|
||
{{- end -}}
|
||
{{- with $coverPrompt -}}
|
||
<details>
|
||
<summary>Prompt</summary>
|
||
<p>{{ . | markdownify }}</p>
|
||
</details>
|
||
{{- end -}}
|
||
</section>
|
||
{{- end -}}
|
||
</section>
|
||
</section>
|
||
{{- end -}}
|
||
</header>
|