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:
|
||||
|
@ -20,6 +20,9 @@ articles-in-section:
|
|||
author:
|
||||
other: Autor
|
||||
|
||||
child-articles:
|
||||
other: Untergeordnete Artikel
|
||||
|
||||
child-topics:
|
||||
other: Unterbegriffe
|
||||
|
||||
|
@ -44,6 +47,9 @@ next:
|
|||
pages:
|
||||
other: Seiten
|
||||
|
||||
parent-articles:
|
||||
other: Übergeordnete Artikel
|
||||
|
||||
parent-topics:
|
||||
other: Oberbegriffe
|
||||
|
||||
|
@ -57,7 +63,10 @@ recentArticles:
|
|||
other: Aktuelle Artikel
|
||||
|
||||
related:
|
||||
other: Ähnliche Artikel
|
||||
other: Verwandte Artikel
|
||||
|
||||
related-articles:
|
||||
other: Verwandte Artikel
|
||||
|
||||
Teaser:
|
||||
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:
|
||||
|
@ -20,6 +20,9 @@ articles-in-section:
|
|||
author:
|
||||
other: Author
|
||||
|
||||
child-articles:
|
||||
other: Child Articles
|
||||
|
||||
child-topics:
|
||||
other: Child Topics
|
||||
|
||||
|
@ -48,6 +51,9 @@ pages:
|
|||
posts:
|
||||
other: Posts
|
||||
|
||||
parent-articles:
|
||||
other: Parent Articles
|
||||
|
||||
parent-topics:
|
||||
other: Parent Topics
|
||||
|
||||
|
@ -60,6 +66,9 @@ recentArticles:
|
|||
related:
|
||||
other: Related Posts
|
||||
|
||||
related-articles:
|
||||
other: Related Posts
|
||||
|
||||
Teaser:
|
||||
other: Teaser
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
<div class="home">
|
||||
|
||||
{{- $parents := .Params.Topics -}}
|
||||
{{- $mainWidth := or (and $parents "8") "12" -}}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-{{ $mainWidth }}">
|
||||
<div class="card mt-3 mb-3">
|
||||
<div class="card-header">
|
||||
<h2 class="card-text">{{ .Title }}</h2>
|
||||
|
@ -13,8 +15,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ partial "parent-topics.html" . }}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
{{ $section := or .Section .Site.Params.homeSection "posts" }}
|
||||
{{ $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>
|
||||
{{- end }}
|
||||
|
||||
{{ if not .Site.Params.hideRelatedArticles -}}
|
||||
{{- with .Params.Topics -}}
|
||||
{{ if not .Site.Params.hideParentArticles -}}
|
||||
{{- $related := where .Site.RegularPages "Params.pageid" "in" .Params.parents -}}
|
||||
{{- with $related -}}
|
||||
<div class="card mt-3">
|
||||
<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 class="card-body">
|
||||
<ul id="topics" class="list-inline">
|
||||
{{ range (where $site.RegularPages "Params.topics" "intersect" .) }}
|
||||
<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 }}
|
||||
{{- partial "list-item" $related -}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -64,28 +86,20 @@
|
|||
{{- end }}
|
||||
|
||||
{{ if not .Site.Params.hideSectionArticles -}}
|
||||
{{- $section := or .Section "posts" -}}
|
||||
{{- $related := first 20 (where .Site.RegularPages "Section" $section) -}}
|
||||
{{- with $related -}}
|
||||
<div class="card mt-3">
|
||||
{{- $section := or .Section "posts" -}}
|
||||
<div class="card-header">
|
||||
<h4 class="card-text">{{ or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") }}</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-inline">
|
||||
{{ range first 20 (where .Site.RegularPages "Section" $section) }}
|
||||
<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 id="articles-in-section" class="list-inline">
|
||||
{{- partial "list-item" $related -}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
|
||||
<div class="home">
|
||||
|
||||
{{- $site := .Site -}}
|
||||
{{- $parents := .Params.Topics -}}
|
||||
{{- $mainWidth := or (and $parents "8") "12" -}}
|
||||
{{- $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="{{ $mainWidth }}">
|
||||
<div class="col-md-{{ $mainWidth }}">
|
||||
<div class="card mt-3 mb-3">
|
||||
<div class="card-header">
|
||||
<h2 class="card-text">{{i18n .Data.Singular}}: {{ .Title }}</h2>
|
||||
|
@ -32,27 +30,7 @@
|
|||
</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 rounded-pill bg-secondary m-1">
|
||||
<a href="{{ $page.Permalink }}"
|
||||
class="text-decoration-none">{{ $page.Title }}
|
||||
</a>
|
||||
</span>
|
||||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
||||
|
||||
{{ partial "parent-topics.html" . }}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
Loading…
Add table
Reference in a new issue