{{- $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 and (ne $coverDisplay.MediaType.SubType "svg") (gt $coverDisplay.Width 1480) -}} {{- $coverDisplay = $coverImage.Resize "1480x" -}} {{- 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" . "CommentsURL" .Params.comments_url "CommentsLabel" "Commentaires" "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 -}}
{{ partialCached "header-brand.html" .Site .Site.Title (.Site.Params.logo | default "logo-large.png") }}

{{ .Title }}

{{- if $hasMetaBlock -}}
{{- if $hasCoverImage -}}
{{ $coverImageTitle }}
{{- end -}}
{{- end -}}