Skip to content

Commit

Permalink
Include Wikidata linker
Browse files Browse the repository at this point in the history
  • Loading branch information
cmahnke committed Jan 2, 2025
1 parent ab519b6 commit 62ed561
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions assets/scss/wikidata.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.wikidata {
display: none !important;
margin: 0;
font-size: x-small;
width: max-content;
Expand Down
23 changes: 17 additions & 6 deletions layouts/partials/data/wikidata.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
{{- $defaultRelation := "related" -}}
{{- with .Params.wikidata -}}
{{- $entries := slice -}}
{{- if not (reflect.IsSlice .) -}}
{{- $entries = slice . -}}
{{- else -}}
{{- $entries := dict -}}
{{- if not (reflect.IsMap .) -}}
{{- $list := slice -}}
{{- if not (reflect.IsSlice .) -}}
{{- $list = slice . -}}
{{- else -}}
{{- $list = . -}}
{{- end -}}
{{- range $list -}}
{{- $entries = merge $entries (dict . $defaultRelation) -}}
{{- end -}}
{{- else -}}
{{- $entries = . -}}
{{- end -}}

<ul class="wikidata">
<div class="wikidata-title">{{ i18n "WikidataEntries" }}</div>
{{- range $entries -}}
{{- range $url, $relation := $entries -}}
{{ $id := replaceRE `https://www.wikidata.org/wiki/` "" $url }}
<li class="wikidata-entry">
<a href="{{ . }}" title="" rel="wikidata">{{ i18n "WikidataEntry" }}</a>
<a href="{{ $url }}" title="{{ $id}}" rel="{{ $relation }}">{{ i18n "WikidataEntry" }}</a>
</li>
{{- end -}}
</ul>
Expand Down
2 changes: 2 additions & 0 deletions layouts/partials/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ <h1 class="post-title">{{ .Title }}</h1>
</div>
{{- end -}}

{{- partial "data/wikidata.html" . -}}

{{- if not .Params.metaPage -}}
<div class="meta">
<div class="tags-heading">{{ i18n "Tags" }}</div>
Expand Down

0 comments on commit 62ed561

Please sign in to comment.