From 34ea4cc8bf6b90ffdc725851fe744acc1fee0f02 Mon Sep 17 00:00:00 2001 From: Christian Mahnke Date: Thu, 2 Jan 2025 21:16:37 +0100 Subject: [PATCH] Fix Names from Wikidata --- config.toml | 2 +- layouts/partials/data/functions/wikidata-label.html | 11 +++++++---- layouts/partials/data/wikidata.html | 3 ++- layouts/partials/schema.org/page.html | 3 --- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config.toml b/config.toml index 854a374e32..c219bc76f0 100644 --- a/config.toml +++ b/config.toml @@ -239,4 +239,4 @@ enableRobotsTXT = true [security] [security.http] - mediaTypes = ['^application/json$'] + mediaTypes = ['^application/json$', '^application/json; charset=[uU][tT][fF]-8$'] diff --git a/layouts/partials/data/functions/wikidata-label.html b/layouts/partials/data/functions/wikidata-label.html index e9bc511955..c5b13f3d2f 100644 --- a/layouts/partials/data/functions/wikidata-label.html +++ b/layouts/partials/data/functions/wikidata-label.html @@ -35,12 +35,15 @@ {{ errorf "Unable to get remote resource %q" $jsonURL }} {{- end -}} -{{- $entity := $data.entities.Get $id -}} +{{- $entity := index $data.entities $id -}} -{{- $label := "" -}} + + +{{- $label := $id -}} {{- range $defaultLangs -}} - {{- if isset $entity.labels.Get . -}} - {{- $label = ($entity.labels.Get .).label -}} + {{- if isset $entity.labels . -}} + {{ warnf "==> %#v" (index $entity.labels .) }} + {{- $label = (index $entity.labels .).value -}} {{- end -}} {{ end }} diff --git a/layouts/partials/data/wikidata.html b/layouts/partials/data/wikidata.html index 1955b24f94..9678f1c405 100644 --- a/layouts/partials/data/wikidata.html +++ b/layouts/partials/data/wikidata.html @@ -23,7 +23,8 @@ {{- $id := replaceRE `https://www.wikidata.org/wiki/` "" $url -}} {{- $uri := printf "%s%s" $entityBase $id -}}
  • - {{ i18n "WikidataEntry" }} + {{- $name := partial "data/functions/wikidata-label.html" (dict "url" $id) -}} + {{ printf "%s: " (i18n "WikidataEntry") }}{{ $name }}
  • {{- end -}} diff --git a/layouts/partials/schema.org/page.html b/layouts/partials/schema.org/page.html index cc67c65271..e212fb8d1e 100644 --- a/layouts/partials/schema.org/page.html +++ b/layouts/partials/schema.org/page.html @@ -76,10 +76,7 @@ {{- range $url, $relation := $entries -}} {{- $id := replaceRE `https://www.wikidata.org/wiki/` "" $url -}} {{- $uri := printf "%s%s" $entityBase $id -}} - {{- $name := $id -}} - {{/* Fails due to https://github.com/gohugoio/hugo/issues/11601 {{- $name := partial "data/functions/wikidata-label.html" (dict "url" $id) -}} - */}} {{- $thing := dict "@type" "Thing" "@id" $uri "name" $name -}} {{- $about = $about | append $thing -}} {{- end -}}