control rendering of children via parameter showChildArticles

This commit is contained in:
Helmut Merz 2023-10-26 16:33:37 +02:00
parent 6a84403aff
commit 8839ff3cad
4 changed files with 15 additions and 9 deletions

View file

@ -31,14 +31,19 @@
{{- end }} {{- end }}
</div> </div>
{{ if eq .Site.Params.showChildArticles "cards" -}} {{- $showChildren := .Param "showChildArticles" -}}
{{ if $showChildren -}}
<div class="row"> <div class="row">
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}} {{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{ range sort (sort $related "Date" "desc") "Weight" }} {{ range sort (sort $related "Date" "desc") "Weight" }}
{{- if eq $showChildren "cards" -}}
{{ partial "card.html" . }} {{ partial "card.html" . }}
{{- else -}}
{{ partial $showChildren . }}
{{- end -}}
{{ end }} {{ end }}
</div> </div>
{{ end }} {{- end }}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">

View file

@ -27,12 +27,7 @@
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}} {{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{ range sort (sort $related "Date" "desc") "Weight" }} {{ range sort (sort $related "Date" "desc") "Weight" }}
<div class="card-body"> {{ partial "embed" . }}
<h3 class="post-title" itemprop="name headline">{{ .Title }}</h3>
{{ with .Content -}}
<div itemprop="articleBody">{{ . }}</div>
{{- end }}
</div>
{{ end }} {{ end }}
</article> </article>

View file

@ -0,0 +1,7 @@
<div class="card-body">
<h3 class="post-title" itemprop="name headline">{{ .Title }}</h3>
{{ with .Content -}}
<div itemprop="articleBody">{{ . }}</div>
{{- end }}
</div>

View file

@ -1,7 +1,6 @@
{{- $pid := or (.Get "pid") (.Get "page") -}} {{- $pid := or (.Get "pid") (.Get "page") -}}
{{- $this := $.Page -}} {{- $this := $.Page -}}
{{- $title := .Get "title" -}} {{- $title := .Get "title" -}}
{{- $noTitle := .Get "notitle" -}}
{{- $linkid := or ($this.Scratch.Get "linkid") 1 -}} {{- $linkid := or ($this.Scratch.Get "linkid") 1 -}}
{{- $this.Scratch.Set "linkid" (add $linkid 1) -}} {{- $this.Scratch.Set "linkid" (add $linkid 1) -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}} {{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}