Skip to content

Commit

Permalink
Fix Names from Wikidata
Browse files Browse the repository at this point in the history
  • Loading branch information
cmahnke committed Jan 2, 2025
1 parent 63153b9 commit 34ea4cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,4 @@ enableRobotsTXT = true

[security]
[security.http]
mediaTypes = ['^application/json$']
mediaTypes = ['^application/json$', '^application/json; charset=[uU][tT][fF]-8$']
11 changes: 7 additions & 4 deletions layouts/partials/data/functions/wikidata-label.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/data/wikidata.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
{{- $id := replaceRE `https://www.wikidata.org/wiki/` "" $url -}}
{{- $uri := printf "%s%s" $entityBase $id -}}
<li class="wikidata-entry">
<a href="{{ $uri }}" title="{{ $id }}" rel="{{ $relation }}">{{ i18n "WikidataEntry" }}</a>
{{- $name := partial "data/functions/wikidata-label.html" (dict "url" $id) -}}
<a href="{{ $uri }}" title="{{ $id }}" rel="{{ $relation }}">{{ printf "%s: " (i18n "WikidataEntry") }}{{ $name }}</a>
</li>
{{- end -}}
</ul>
Expand Down
3 changes: 0 additions & 3 deletions layouts/partials/schema.org/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down

0 comments on commit 34ea4cc

Please sign in to comment.