1

Affiner les métadonnées d'en-tête des articles

This commit is contained in:
2026-03-25 22:03:09 +01:00
parent 9595558c55
commit dc262bdd97
2 changed files with 81 additions and 2 deletions

View File

@@ -111,12 +111,29 @@
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: var(--space-1); gap: var(--space-1);
align-items: center;
} }
.article-header .article-publication > time { .article-header .article-publication > time {
color: inherit; 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 { .article-header .page-links {
margin-top: var(--article-meta-vertical-space); margin-top: var(--article-meta-vertical-space);
} }

View File

@@ -110,10 +110,67 @@
{{- $coverDescription := index $coverData "description" -}} {{- $coverDescription := index $coverData "description" -}}
{{- $coverAttribution := index $coverData "attribution" -}} {{- $coverAttribution := index $coverData "attribution" -}}
{{- $coverPrompt := index $coverData "prompt" -}} {{- $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 -}} {{- $hasCoverImage := and $showCover $coverImage -}}
{{- $hasCoverMeta := or $coverTitle $coverDescription $coverAttribution $coverPrompt -}} {{- $hasCoverMeta := or $coverTitle $coverDescription $coverAttribution $coverPrompt -}}
{{- $showReadingTime := ge .ReadingTime 5 -}} {{- $showReadingTime := ge .ReadingTime 5 -}}
{{- $hasPublication := $showReadingTime -}} {{- $hasPublication := or $showReadingTime $hasWeatherIcon -}}
{{- with .Date -}} {{- with .Date -}}
{{- $hasPublication = true -}} {{- $hasPublication = true -}}
{{- end -}} {{- end -}}
@@ -161,12 +218,17 @@
{{ . | time.Format "02/01/2006 à 15:04" }} {{ . | time.Format "02/01/2006 à 15:04" }}
{{- end -}} {{- end -}}
</time> </time>
{{- if $hasWeatherIcon -}}
<span class="article-weather" role="img" aria-label="{{ $weatherAriaLabel }}"{{ with $weatherTitle }} title="{{ . }}"{{ end }}>
<img src="/icons/weather/{{ $weatherIcon }}" alt="" aria-hidden="true">
</span>
{{- end -}}
{{- if $showReadingTime -}} {{- if $showReadingTime -}}
<span>·</span> <span>·</span>
{{- end -}} {{- end -}}
{{ end }} {{ end }}
{{- if $showReadingTime -}} {{- if $showReadingTime -}}
<span>{{ .ReadingTime }} min</span> <span>{{ .ReadingTime }} min de lecture</span>
{{- end -}} {{- end -}}
</p> </p>
{{- end -}} {{- end -}}