29 lines
902 B
HTML
29 lines
902 B
HTML
{{- $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 -}}
|