allow embedding of child articles via showChildArticles site or page parameter

This commit is contained in:
Helmut Merz 2023-10-26 19:26:00 +02:00
parent 8839ff3cad
commit d2d1c29e2d

View file

@ -1,4 +1,9 @@
{{ define "main" -}} {{ define "main" -}}
{{- $showChildren := .Param "showChildArticles" -}}
{{- $children := slice -}}
{{- if $showChildren -}}
{{- $children = .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- end -}}
<div class="row"> <div class="row">
{{- $mainwidth := or (and .Params.noSidebar "12") "8" -}} {{- $mainwidth := or (and .Params.noSidebar "12") "8" -}}
@ -24,6 +29,11 @@
{{ with .Content -}} {{ with .Content -}}
<div class="post-content card-body" itemprop="articleBody">{{ . }}</div> <div class="post-content card-body" itemprop="articleBody">{{ . }}</div>
{{- end }} {{- end }}
{{- if eq $showChildren "embed" -}}
{{ range sort (sort $children "Date" "desc") "Weight" }}
{{ partial "embed" . }}
{{ end }}
{{- end -}}
</article> </article>
</div> </div>
{{ if not .Params.noSidebar -}} {{ if not .Params.noSidebar -}}
@ -31,16 +41,10 @@
{{- end }} {{- end }}
</div> </div>
{{- $showChildren := .Param "showChildArticles" -}}
{{ if $showChildren -}}
<div class="row">
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{ range sort (sort $related "Date" "desc") "Weight" }}
{{- if eq $showChildren "cards" -}} {{- if eq $showChildren "cards" -}}
<div class="row">
{{ range sort (sort $children "Date" "desc") "Weight" }}
{{ partial "card.html" . }} {{ partial "card.html" . }}
{{- else -}}
{{ partial $showChildren . }}
{{- end -}}
{{ end }} {{ end }}
</div> </div>
{{- end }} {{- end }}