From 1fda1d869272a0be70adb578ad90af49ea2c8856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Wed, 25 Aug 2021 14:45:01 +0200 Subject: [PATCH] children: add parameter for container style #53 --- .../content/shortcodes/children/_index.en.md | 11 ++++--- layouts/shortcodes/children.html | 33 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/exampleSite/content/shortcodes/children/_index.en.md b/exampleSite/content/shortcodes/children/_index.en.md index e716f6bca9..a702f7d0aa 100644 --- a/exampleSite/content/shortcodes/children/_index.en.md +++ b/exampleSite/content/shortcodes/children/_index.en.md @@ -11,7 +11,8 @@ Use the children shortcode to list the child pages of a page and the further des | Parameter | Default | Description | |:--|:--|:--| | page | _current_ | Specify the page name (section name) to display children for | -| style | "li" | Choose the style used to display descendants. It could be any HTML tag name | +| containerstyle | "ul" | Choose the style used to group all children. It could be any HTML tag name | +| style | "li" | Choose the style used to display each descendant. It could be any HTML tag name | | showhidden | "false" | When true, child pages hidden from the menu will be displayed | | description | "false" | Allows you to include a short text under each page in the list. When no description exists for the page, children shortcode takes the first 70 words of your content. [Read more info about summaries on gohugo.io](https://gohugo.io/content/summaries/) | | depth | 1 | Enter a number to specify the depth of descendants to display. For example, if the value is 2, the shortcode will display 2 levels of child pages. **Tips:** set 999 to get all descendants | @@ -38,13 +39,13 @@ Use the children shortcode to list the child pages of a page and the further des {{% children depth="3" showhidden="true" %}} ````go -{{%/* children style="h2" depth="3" description="true" */%}} +{{%/* children containerstyle="div" style="h2" depth="3" description="true" */%}} ```` -{{% children style="h2" depth="3" description="true" %}} +{{% children containerstyle="div" style="h2" depth="3" description="true" %}} ````go -{{%/* children style="div" depth="999" */%}} +{{%/* children containerstyle="div" style="div" depth="999" */%}} ```` -{{% children style="div" depth="999" %}} +{{% children containerstyle="div" style="div" depth="999" %}} diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html index 16688f2579..899fce2b89 100644 --- a/layouts/shortcodes/children.html +++ b/layouts/shortcodes/children.html @@ -4,8 +4,9 @@ {{ $depth := .Get "depth" | default 1 }} {{ $withDescription := .Get "description" | default false }} {{ $sortTerm := .Get "sort" | default "Weight" }} +{{ $containerstyle := .Get "containerstyle" | default "ul" }} - +{{(printf "" $containerstyle)|safeHTML}} {{ define "childs" }} {{ range .menu }} @@ -65,7 +66,7 @@ {{ if lt $.count $.depth}} {{if eq $.style "li"}} - +{{(printf "" $.containerstyle)|safeHTML}} {{end}} {{end}} {{end}}