Affiner les métadonnées d'en-tête des articles
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 -}}
|
||||
</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 -}}
|
||||
<span>·</span>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
{{- if $showReadingTime -}}
|
||||
<span>{{ .ReadingTime }} min</span>
|
||||
<span>{{ .ReadingTime }} min de lecture</span>
|
||||
{{- end -}}
|
||||
</p>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user