From 8839ff3cad8b7c72911f2f7ce7a36ecfd454f526 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 26 Oct 2023 16:33:37 +0200 Subject: [PATCH] control rendering of children via parameter showChildArticles --- layouts/_default/single.html | 9 +++++++-- layouts/cards/single.html | 7 +------ layouts/partials/embed.html | 7 +++++++ layouts/shortcodes/embed.html | 1 - 4 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 layouts/partials/embed.html diff --git a/layouts/_default/single.html b/layouts/_default/single.html index c179236..22a894b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -31,14 +31,19 @@ {{- end }} -{{ if eq .Site.Params.showChildArticles "cards" -}} +{{- $showChildren := .Param "showChildArticles" -}} +{{ if $showChildren -}}
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}} {{ range sort (sort $related "Date" "desc") "Weight" }} + {{- if eq $showChildren "cards" -}} {{ partial "card.html" . }} + {{- else -}} + {{ partial $showChildren . }} + {{- end -}} {{ end }}
-{{ end }} +{{- end }}
diff --git a/layouts/cards/single.html b/layouts/cards/single.html index 9e9d470..2b68329 100644 --- a/layouts/cards/single.html +++ b/layouts/cards/single.html @@ -27,12 +27,7 @@ {{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}} {{ range sort (sort $related "Date" "desc") "Weight" }} -
-

{{ .Title }}

- {{ with .Content -}} -
{{ . }}
- {{- end }} -
+ {{ partial "embed" . }} {{ end }} diff --git a/layouts/partials/embed.html b/layouts/partials/embed.html new file mode 100644 index 0000000..0f21df3 --- /dev/null +++ b/layouts/partials/embed.html @@ -0,0 +1,7 @@ +
+

{{ .Title }}

+ {{ with .Content -}} +
{{ . }}
+ {{- end }} +
+ diff --git a/layouts/shortcodes/embed.html b/layouts/shortcodes/embed.html index d65baea..bbe6ce0 100644 --- a/layouts/shortcodes/embed.html +++ b/layouts/shortcodes/embed.html @@ -1,7 +1,6 @@ {{- $pid := or (.Get "pid") (.Get "page") -}} {{- $this := $.Page -}} {{- $title := .Get "title" -}} -{{- $noTitle := .Get "notitle" -}} {{- $linkid := or ($this.Scratch.Get "linkid") 1 -}} {{- $this.Scratch.Set "linkid" (add $linkid 1) -}} {{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}