partial for related cards; + siblings card

This commit is contained in:
Helmut Merz 2021-11-24 17:14:18 +01:00
parent e6023afb86
commit 2de24d3049
4 changed files with 38 additions and 52 deletions

View file

@ -1,5 +1,5 @@
#
# de.yaml 2021-11-15
# de.yaml 2021-11-24
#
about:
@ -66,6 +66,9 @@ related:
other: Verwandte Artikel
related-articles:
other: Thematisch verwandte Artikel
sibling-articles:
other: Verwandte Artikel
Teaser:

View file

@ -1,5 +1,5 @@
#
# en.yaml 2021-11-15
# en.yaml 2021-11-24
#
about:
@ -69,6 +69,9 @@ related:
related-articles:
other: Related Posts
sibling-articles:
other: Sibling Posts
Teaser:
other: Teaser

View file

@ -0,0 +1,13 @@
{{- $params := . -}}
{{- with $params.related -}}
<div class="card mt-3">
<div class="card-header">
<h4 class="card-text">{{ $params.header }}</h4>
</div>
<div class="card-body">
<ul id="{{ $params.id }}" class="list-inline">
{{- partial "list-item" $params.related -}}
</ul>
</div>
</div>
{{- end -}}

View file

@ -38,68 +38,35 @@
{{- end }}
{{ 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 "parent-articles" }}</h4>
</div>
<div class="card-body">
<ul id="parents" class="list-inline">
{{- partial "list-item" $related -}}
</ul>
</div>
</div>
{{- end -}}
{{- $related := where .Site.RegularPages "Params.pageid" "in" .Params.parents -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "parent-articles") "id" "parents") -}}
{{- 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 -}}
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "child-articles") "id" "children") -}}
{{- 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">
{{- partial "list-item" $related -}}
</ul>
</div>
</div>
{{- end -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "related-articles") "id" "related") -}}
{{- end }}
{{ if not .Site.Params.hideSiblingArticles -}}
{{- $related := .Site.RegularPages.RelatedIndices . "parents" -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "sibling-articles") "id" "siblings") -}}
{{- end }}
{{ if not .Site.Params.hideSectionArticles -}}
{{- $section := or .Section "posts" -}}
{{- $header := or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") -}}
{{- $related := first 20 (where .Site.RegularPages "Section" $section) -}}
{{- with $related -}}
<div class="card mt-3">
<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 id="articles-in-section" class="list-inline">
{{- partial "list-item" $related -}}
</ul>
</div>
</div>
{{- end }}
{{- partial "card-related"
(dict "related" $related "header" $header "id" "articles-in-section") -}}
{{- end }}
</div>