display parent and child topics on topic pages

This commit is contained in:
Helmut Merz 2021-11-11 15:23:04 +01:00
parent 32c9150232
commit ee944b02a1
4 changed files with 61 additions and 9 deletions

View file

@ -1,5 +1,5 @@
#
# de.yaml 2020-06-19
# de.yaml 2021-11-11
#
about:
@ -20,6 +20,9 @@ articles-in-section:
author:
other: Autor
child-topics:
other: Unterbegriffe
contact:
other: Kontakt
@ -41,6 +44,9 @@ next:
pages:
other: Seiten
parent-topics:
other: Oberbegriffe
posts:
other: Artikel

View file

@ -1,5 +1,5 @@
#
# en.yaml 2020-05-10
# en.yaml 2021-11-11
#
about:
@ -20,6 +20,9 @@ articles-in-section:
author:
other: Author
child-topics:
other: Child Topics
contact:
other: Contact
@ -45,6 +48,9 @@ pages:
posts:
other: Posts
parent-topics:
other: Parent Topics
prev:
other: Previous

View file

@ -28,8 +28,8 @@
</div>
<div class="card-body">
{{ range . -}}
{{ $page := $site.GetPage (printf "/topics/%s" .) }}
<span class="badge badge-pill badge-secondary">
{{- $page := $site.GetPage (printf "/topics/%s" .) -}}
<span class="badge badge-pill badge-secondary m-1">
<a href="{{ $page.Permalink }}">{{ $page.Title }}</a>
</span>
{{- end }}

View file

@ -2,17 +2,57 @@
<div class="home">
{{- $site := .Site -}}
{{- $parents := .Params.Topics -}}
{{- $children := (where
(where .Site.Pages "Section" "topics")
"Params.topics" "intersect" (slice .Name)) -}}
{{- $mainWidth := or (and $parents "col-md-8") "col-md-12" -}}
<div class="row">
<div class="col-md-12">
<div class="{{ $mainWidth }}">
<div class="card mt-3 mb-3">
<div class="card-body bg-light">
<div class="card-header">
<h2 class="card-text">{{i18n .Data.Singular}}: {{ .Title }}</h2>
</div>
{{ with .Content -}}
<div class="card-body"><p class="card-text">{{ . }}</p></div>
{{- end }}
<div class="card-body">
{{ with .Content -}}
<div class="card-text">{{ . }}</div>
{{- end }}
{{ with $children -}}
<p class="card-text">
{{- i18n "child-topics" -}}:
{{ range . -}}
<span class="badge badge-pill badge-secondary mr-1">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</span>
{{- end }}
</p>
{{- end }}
</div>
</div>
</div>
{{ with $parents -}}
<div class="col-md-4">
<div class="card mt-3">
<div class="card-header">
<h4 class="card-text">{{i18n "parent-topics"}}</h4>
</div>
<div class="card-body">
{{ range . -}}
{{- $page := $site.GetPage (printf "/topics/%s" .) -}}
<span class="badge badge-pill badge-secondary mr-1 mb-1">
<a href="{{ $page.Permalink }}"
class="text-decoration-none">{{ $page.Title }}
</a>
</span>
{{- end }}
</div>
</div>
</div>
{{- end }}
</div>
<div class="row">