add parent/child articles (pages) functionality
This commit is contained in:
parent
a30b80b837
commit
e6023afb86
7 changed files with 106 additions and 58 deletions
13
i18n/de.yaml
13
i18n/de.yaml
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# de.yaml 2021-11-11
|
# de.yaml 2021-11-15
|
||||||
#
|
#
|
||||||
|
|
||||||
about:
|
about:
|
||||||
|
@ -20,6 +20,9 @@ articles-in-section:
|
||||||
author:
|
author:
|
||||||
other: Autor
|
other: Autor
|
||||||
|
|
||||||
|
child-articles:
|
||||||
|
other: Untergeordnete Artikel
|
||||||
|
|
||||||
child-topics:
|
child-topics:
|
||||||
other: Unterbegriffe
|
other: Unterbegriffe
|
||||||
|
|
||||||
|
@ -44,6 +47,9 @@ next:
|
||||||
pages:
|
pages:
|
||||||
other: Seiten
|
other: Seiten
|
||||||
|
|
||||||
|
parent-articles:
|
||||||
|
other: Übergeordnete Artikel
|
||||||
|
|
||||||
parent-topics:
|
parent-topics:
|
||||||
other: Oberbegriffe
|
other: Oberbegriffe
|
||||||
|
|
||||||
|
@ -57,7 +63,10 @@ recentArticles:
|
||||||
other: Aktuelle Artikel
|
other: Aktuelle Artikel
|
||||||
|
|
||||||
related:
|
related:
|
||||||
other: Ähnliche Artikel
|
other: Verwandte Artikel
|
||||||
|
|
||||||
|
related-articles:
|
||||||
|
other: Verwandte Artikel
|
||||||
|
|
||||||
Teaser:
|
Teaser:
|
||||||
other: Hintergrund
|
other: Hintergrund
|
||||||
|
|
11
i18n/en.yaml
11
i18n/en.yaml
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# en.yaml 2021-11-11
|
# en.yaml 2021-11-15
|
||||||
#
|
#
|
||||||
|
|
||||||
about:
|
about:
|
||||||
|
@ -20,6 +20,9 @@ articles-in-section:
|
||||||
author:
|
author:
|
||||||
other: Author
|
other: Author
|
||||||
|
|
||||||
|
child-articles:
|
||||||
|
other: Child Articles
|
||||||
|
|
||||||
child-topics:
|
child-topics:
|
||||||
other: Child Topics
|
other: Child Topics
|
||||||
|
|
||||||
|
@ -48,6 +51,9 @@ pages:
|
||||||
posts:
|
posts:
|
||||||
other: Posts
|
other: Posts
|
||||||
|
|
||||||
|
parent-articles:
|
||||||
|
other: Parent Articles
|
||||||
|
|
||||||
parent-topics:
|
parent-topics:
|
||||||
other: Parent Topics
|
other: Parent Topics
|
||||||
|
|
||||||
|
@ -60,6 +66,9 @@ recentArticles:
|
||||||
related:
|
related:
|
||||||
other: Related Posts
|
other: Related Posts
|
||||||
|
|
||||||
|
related-articles:
|
||||||
|
other: Related Posts
|
||||||
|
|
||||||
Teaser:
|
Teaser:
|
||||||
other: Teaser
|
other: Teaser
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
<div class="home">
|
<div class="home">
|
||||||
|
|
||||||
|
{{- $parents := .Params.Topics -}}
|
||||||
|
{{- $mainWidth := or (and $parents "8") "12" -}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-{{ $mainWidth }}">
|
||||||
<div class="card mt-3 mb-3">
|
<div class="card mt-3 mb-3">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="card-text">{{ .Title }}</h2>
|
<h2 class="card-text">{{ .Title }}</h2>
|
||||||
|
@ -13,8 +15,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{ partial "parent-topics.html" . }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ $section := or .Section .Site.Params.homeSection "posts" }}
|
{{ $section := or .Section .Site.Params.homeSection "posts" }}
|
||||||
{{ $paginator := .Paginate (where .Site.RegularPages "Section" $section) }}
|
{{ $paginator := .Paginate (where .Site.RegularPages "Section" $section) }}
|
||||||
|
|
12
layouts/partials/list-item.html
Normal file
12
layouts/partials/list-item.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{{ range . -}}
|
||||||
|
<li>
|
||||||
|
<a href="{{ .Permalink }}"
|
||||||
|
class="text-decoration-none">{{ .Title }}
|
||||||
|
{{ if .Date -}}
|
||||||
|
<small>{{ .Date.Format (i18n "dateFormat") }}</small>
|
||||||
|
{{- else if .Params.Teaser -}}<small>{{ .Params.Teaser }}</small>
|
||||||
|
{{- else -}}<small>{{ .Summary }}</small>
|
||||||
|
{{- end }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{- end }}
|
22
layouts/partials/parent-topics.html
Normal file
22
layouts/partials/parent-topics.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{{- $site := .Site -}}
|
||||||
|
{{- $parents := .Params.Topics -}}
|
||||||
|
{{ with $parents -}}
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="card mt-3 mb-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 rounded-pill bg-secondary m-1">
|
||||||
|
<a href="{{ $page.Permalink }}"
|
||||||
|
class="text-decoration-none">{{ $page.Title }}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
{{- end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{- end }}
|
||||||
|
|
|
@ -37,26 +37,48 @@
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{ if not .Site.Params.hideRelatedArticles -}}
|
{{ if not .Site.Params.hideParentArticles -}}
|
||||||
{{- with .Params.Topics -}}
|
{{- $related := where .Site.RegularPages "Params.pageid" "in" .Params.parents -}}
|
||||||
|
{{- with $related -}}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h4 class="card-text">{{ i18n "related" }}</h4>
|
<h4 class="card-text">{{ i18n "parent-articles" }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<ul id="parents" class="list-inline">
|
||||||
|
{{- partial "list-item" $related -}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{ if not .Site.Params.hideChildArticles -}}
|
||||||
|
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
|
||||||
|
{{- with $related -}}
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-text">{{ i18n "child-articles" }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<ul id="children" class="list-inline">
|
||||||
|
{{- partial "list-item" $related -}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{ if not .Site.Params.hideRelatedArticles -}}
|
||||||
|
{{- $related := .Site.RegularPages.RelatedIndices . "topics" -}}
|
||||||
|
{{- with $related -}}
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-text">{{ i18n "related-articles" }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<ul id="topics" class="list-inline">
|
<ul id="topics" class="list-inline">
|
||||||
{{ range (where $site.RegularPages "Params.topics" "intersect" .) }}
|
{{- partial "list-item" $related -}}
|
||||||
<li>
|
|
||||||
<a href="{{ .Permalink }}"
|
|
||||||
class="text-decoration-none">{{ .Title }}
|
|
||||||
{{ if .Date -}}
|
|
||||||
<small>{{ .Date.Format (i18n "dateFormat") }}</small>
|
|
||||||
{{- else if .Params.Teaser -}}<small>{{ .Params.Teaser }}</small>
|
|
||||||
{{- else -}}<small>{{ .Summary }}</small>
|
|
||||||
{{- end }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{ end }}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -64,28 +86,20 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{ if not .Site.Params.hideSectionArticles -}}
|
{{ if not .Site.Params.hideSectionArticles -}}
|
||||||
|
{{- $section := or .Section "posts" -}}
|
||||||
|
{{- $related := first 20 (where .Site.RegularPages "Section" $section) -}}
|
||||||
|
{{- with $related -}}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
{{- $section := or .Section "posts" -}}
|
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h4 class="card-text">{{ or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") }}</h4>
|
<h4 class="card-text">{{ or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<ul class="list-inline">
|
<ul id="articles-in-section" class="list-inline">
|
||||||
{{ range first 20 (where .Site.RegularPages "Section" $section) }}
|
{{- partial "list-item" $related -}}
|
||||||
<li>
|
|
||||||
<a href="{{ .Permalink }}"
|
|
||||||
class="text-decoration-none">{{ .Title }}
|
|
||||||
{{ if .Date -}}
|
|
||||||
<small>{{ .Date.Format (i18n "dateFormat") }}</small>
|
|
||||||
{{- else if .Params.Teaser -}}<small>{{ .Params.Teaser }}</small>
|
|
||||||
{{- else -}}<small>{{ .Summary }}</small>
|
|
||||||
{{- end }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{ end }}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,15 +2,13 @@
|
||||||
|
|
||||||
<div class="home">
|
<div class="home">
|
||||||
|
|
||||||
{{- $site := .Site -}}
|
|
||||||
{{- $parents := .Params.Topics -}}
|
{{- $parents := .Params.Topics -}}
|
||||||
|
{{- $mainWidth := or (and $parents "8") "12" -}}
|
||||||
{{- $children := (where
|
{{- $children := (where
|
||||||
(where .Site.Pages "Section" "topics")
|
(where .Site.Pages "Section" "topics")
|
||||||
"Params.topics" "intersect" (slice .Name)) -}}
|
"Params.topics" "intersect" (slice .Name)) -}}
|
||||||
{{- $mainWidth := or (and $parents "col-md-8") "col-md-12" -}}
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-md-{{ $mainWidth }}">
|
||||||
<div class="{{ $mainWidth }}">
|
|
||||||
<div class="card mt-3 mb-3">
|
<div class="card mt-3 mb-3">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="card-text">{{i18n .Data.Singular}}: {{ .Title }}</h2>
|
<h2 class="card-text">{{i18n .Data.Singular}}: {{ .Title }}</h2>
|
||||||
|
@ -32,27 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{ partial "parent-topics.html" . }}
|
||||||
{{ 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 rounded-pill bg-secondary m-1">
|
|
||||||
<a href="{{ $page.Permalink }}"
|
|
||||||
class="text-decoration-none">{{ $page.Title }}
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
{{- end }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Add table
Reference in a new issue