From dc262bdd97e2c7cbf157da7165d095a5ed70cf3a Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Wed, 25 Mar 2026 22:03:09 +0100 Subject: [PATCH] =?UTF-8?q?Affiner=20les=20m=C3=A9tadonn=C3=A9es=20d'en-t?= =?UTF-8?q?=C3=AAte=20des=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/2026/assets/css/article-header.css | 17 +++++ .../layouts/_partials/article-header.html | 66 ++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/themes/2026/assets/css/article-header.css b/themes/2026/assets/css/article-header.css index 40d8c019..e7974e79 100644 --- a/themes/2026/assets/css/article-header.css +++ b/themes/2026/assets/css/article-header.css @@ -111,12 +111,29 @@ display: flex; flex-wrap: wrap; gap: var(--space-1); + align-items: center; } .article-header .article-publication > time { color: inherit; } +.article-header .article-weather { + display: inline-flex; + align-items: center; + justify-content: center; + width: 1.5rem; + height: 1.5rem; + line-height: 1; +} + +.article-header .article-weather > img { + display: block; + width: 100%; + height: 100%; + opacity: 0.72; +} + .article-header .page-links { margin-top: var(--article-meta-vertical-space); } diff --git a/themes/2026/layouts/_partials/article-header.html b/themes/2026/layouts/_partials/article-header.html index ee63953c..beb2890a 100644 --- a/themes/2026/layouts/_partials/article-header.html +++ b/themes/2026/layouts/_partials/article-header.html @@ -110,10 +110,67 @@ {{- $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 := $showReadingTime -}} +{{- $hasPublication := or $showReadingTime $hasWeatherIcon -}} {{- with .Date -}} {{- $hasPublication = true -}} {{- end -}} @@ -161,12 +218,17 @@ {{ . | time.Format "02/01/2006 à 15:04" }} {{- end -}} + {{- if $hasWeatherIcon -}} + + + + {{- end -}} {{- if $showReadingTime -}} · {{- end -}} {{ end }} {{- if $showReadingTime -}} - {{ .ReadingTime }} min + {{ .ReadingTime }} min de lecture {{- end -}}

{{- end -}}