{{- $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 -}} {{- with $coverDataFile.Content | transform.Unmarshal -}} {{- $coverData = . -}} {{- end -}} {{- end -}} {{- end -}} {{- $coverImage := false -}} {{- $coverDisplay := false -}} {{- if $showCover -}} {{- $coverResourcePath := (urls.Parse $coverPath).Path -}} {{- if ne $coverResourcePath "" -}} {{- $coverPathLower := lower $coverResourcePath -}} {{- if or (strings.HasSuffix $coverPathLower ".yaml") (strings.HasSuffix $coverPathLower ".yml") -}} {{- $coverMetaFile := $page.Resources.Get $coverResourcePath -}} {{- if $coverMetaFile -}} {{- with $coverMetaFile.Content | transform.Unmarshal -}} {{- with index . "file" -}} {{- $coverFilePath := strings.TrimSpace (printf "%v" .) -}} {{- if ne $coverFilePath "" -}} {{- $coverImage = $page.Resources.Get $coverFilePath -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- else -}} {{- $coverImage = $page.Resources.Get $coverResourcePath -}} {{- end -}} {{- end -}} {{- if $coverImage -}} {{- $coverDisplay = $coverImage -}} {{- if ne $coverDisplay.MediaType.SubType "svg" -}} {{- $coverWidth := $coverDisplay.Width -}} {{- if gt $coverDisplay.Width 1480 -}} {{- $coverWidth = 1480 -}} {{- end -}} {{- $coverDisplay = partial "media/process-image.html" (dict "image" $coverImage "action" "Resize" "spec" (printf "%dx" $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" -}} {{- $weather := .Params.weather -}} {{- $weatherIcon := "" -}} {{- $weatherLabel := "Météo" -}} {{- $weatherTitle := "" -}} {{- if and $weather (gt (len $weather) 0) -}} {{- $hour := (time .Date).Hour -}} {{- $isNight := false -}} {{- if or (lt $hour 6) (ge $hour 18) -}} {{- $isNight = true -}} {{- end -}} {{- if $isNight -}} {{- $weatherIcon = "clear-night.svg" -}} {{- else -}} {{- $weatherIcon = "clear-day.svg" -}} {{- end -}} {{- if $weather.precipitations -}} {{- $weatherIcon = "rain.svg" -}} {{- else if and $weather.wind_speed (ge $weather.wind_speed 45) -}} {{- $weatherIcon = "wind.svg" -}} {{- else if and $weather.humidity (ge $weather.humidity 90) (or (not $weather.illuminance) (lt $weather.illuminance 80)) -}} {{- $weatherIcon = "fog.svg" -}} {{- else if and $weather.humidity (ge $weather.humidity 75) -}} {{- if $isNight -}} {{- $weatherIcon = "partly-cloudy-night.svg" -}} {{- else -}} {{- $weatherIcon = "cloudy.svg" -}} {{- end -}} {{- end -}} {{- if eq $weatherIcon "clear-day.svg" -}}{{- $weatherLabel = "Grand soleil" -}}{{- end -}} {{- if eq $weatherIcon "clear-night.svg" -}}{{- $weatherLabel = "Ciel dégagé" -}}{{- end -}} {{- if eq $weatherIcon "partly-cloudy-day.svg" -}}{{- $weatherLabel = "Partiellement nuageux" -}}{{- end -}} {{- if eq $weatherIcon "partly-cloudy-night.svg" -}}{{- $weatherLabel = "Partiellement nuageux" -}}{{- end -}} {{- if eq $weatherIcon "cloudy.svg" -}}{{- $weatherLabel = "Nuageux" -}}{{- end -}} {{- if eq $weatherIcon "drizzle.svg" -}}{{- $weatherLabel = "Bruine" -}}{{- end -}} {{- if eq $weatherIcon "rain.svg" -}}{{- $weatherLabel = "Pluvieux" -}}{{- end -}} {{- if eq $weatherIcon "snow.svg" -}}{{- $weatherLabel = "Neige" -}}{{- end -}} {{- if eq $weatherIcon "thunderstorms-day.svg" -}}{{- $weatherLabel = "Orage" -}}{{- end -}} {{- if eq $weatherIcon "fog.svg" -}}{{- $weatherLabel = "Brouillard" -}}{{- end -}} {{- if eq $weatherIcon "wind.svg" -}}{{- $weatherLabel = "Vent fort" -}}{{- end -}} {{- $weatherTitleParts := slice -}} {{- with $weather.temperature -}} {{- $weatherTitleParts = $weatherTitleParts | append (printf "%.1f℃" (mul . 1.0)) -}} {{- end -}} {{- with $weather.humidity -}} {{- $weatherTitleParts = $weatherTitleParts | append (printf "%.0f%%" (mul . 1.0)) -}} {{- end -}} {{- $weatherTitle = delimit $weatherTitleParts " | " -}} {{- end -}} {{- $hasWeatherIcon := ne $weatherIcon "" -}} {{- $weatherAriaLabel := $weatherLabel -}} {{- if ne $weatherTitle "" -}} {{- $weatherAriaLabel = printf "Météo : %s" $weatherTitle -}} {{- end -}} {{- $hasCoverImage := and $showCover $coverImage -}} {{- $hasCoverMeta := or $coverTitle $coverDescription $coverAttribution $coverPrompt -}} {{- $showReadingTime := ge .ReadingTime 5 -}} {{- $hasPublication := or $showReadingTime $hasWeatherIcon -}} {{- 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 -}}
{{ partialCached "header-brand.html" .Site .Site.Title (.Site.Params.logo | default "logo-large.png") }}

{{ .Title }}

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