1

Page de statistiques

This commit is contained in:
2025-11-28 01:47:10 +01:00
parent 38926267a3
commit fd27dc7fb6
47 changed files with 3278 additions and 86 deletions

View File

@@ -0,0 +1,28 @@
{{- $key := .Get "key" | default (.Get 0) -}}
{{- if not $key -}}
{{- warnf "stats-var: key manquante" -}}
{{- else -}}
{{- $resource := .Page.Resources.GetMatch "data/stats.json" -}}
{{- if not $resource -}}
{{- warnf "stats-var: data/stats.json introuvable pour %s" .Page.File.Path -}}
{{- else -}}
{{- $data := $resource | transform.Unmarshal -}}
{{- $value := "" -}}
{{- if eq $key "generated_at" -}}
{{- with $data.generated_at -}}
{{- $value = time . | time.Format "02/01/2006 à 15:04" -}}
{{- end -}}
{{- else -}}
{{- range $section := $data.sections -}}
{{- range $stat := (default (slice) $section.statistics) -}}
{{- if eq $stat.key $key -}}
{{- $value = (default "" $stat.value) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $value -}}
{{- end -}}
{{- end -}}