{{- $w := .Params.weather -}} {{- if or (not $w) (eq (len $w) 0) -}} {{- /* No weather data */ -}} {{- return -}} {{- end -}} {{- $date := .Date -}} {{- $hour := (time $date).Hour -}} {{- $isNight := or (lt $hour 6) (ge $hour 18) -}} {{- $precip := $w.precipitations -}} {{- $wind := $w.wind_speed -}} {{- $humidity := $w.humidity -}} {{- $illum := $w.illuminance -}} {{- $icon := cond $isNight "clear-night.svg" "clear-day.svg" -}} {{- $labels := dict "clear-day.svg" "Grand soleil" "clear-night.svg" "Ciel dégagé" "partly-cloudy-day.svg" "Partiellement nuageux" "partly-cloudy-night.svg" "Partiellement nuageux" "cloudy.svg" "Nuageux" "drizzle.svg" "Bruine" "rain.svg" "Pluvieux" "snow.svg" "Neige" "thunderstorms-day.svg" "Orage" "fog.svg" "Brouillard" "wind.svg" "Vent fort" }} {{- if $precip -}} {{- $icon = "rain.svg" -}} {{- else if and $wind (ge $wind 45) -}} {{- $icon = "wind.svg" -}} {{- else if and $humidity (ge $humidity 90) (or (not $illum) (lt $illum 80)) -}} {{- $icon = "fog.svg" -}} {{- else if and $humidity (ge $humidity 75) -}} {{- $icon = cond $isNight "partly-cloudy-night.svg" "cloudy.svg" -}} {{- else -}} {{- $icon = cond $isNight "clear-night.svg" "clear-day.svg" -}} {{- end -}} {{- $sources := slice -}} {{- with $w.source -}} {{- if (reflect.IsSlice .) -}} {{- $sources = . -}} {{- else -}} {{- $sources = (slice .) -}} {{- end -}} {{- end -}}
{{- $label := index $labels $icon | default "Météo" -}} {{ $label }}
{{ printf "%s — %s" (time.Format ":date_long" $date) (time.Format ":time_short" $date) }}
{{- with $w.temperature }} {{ printf "%.1f" (mul . 1.0) }} °C {{- end }} {{- with $w.humidity }} {{ printf "%.0f" (mul . 1.0) }} % {{- end }} {{- with $w.pressure }} {{ printf "%.0f" (mul . 1.0) }} hPa {{- end }} {{- with $w.illuminance }} {{ printf "%.0f" (mul . 1.0) }} lx {{- end }} {{- if or $w.wind_speed $w.wind_direction }} {{- if $w.wind_direction -}} {{- $rawDeg := mul $w.wind_direction 1.0 -}} {{- $arrowDeg := math.Mod (add $rawDeg 180) 360 -}} {{- end -}} {{- if $w.wind_speed -}} {{ printf "%.1f" (mul $w.wind_speed 1.0) }} km/h {{- end -}} {{- end }}
{{- if gt (len $sources) 0 }}
{{- range $sources }} {{ . }} {{- end }}
{{- end }}