diff --git a/exampleSite/content/shortcodes/children/_index.en.md b/exampleSite/content/shortcodes/children/_index.en.md index 15742f2e4b..490f1efeed 100644 --- a/exampleSite/content/shortcodes/children/_index.en.md +++ b/exampleSite/content/shortcodes/children/_index.en.md @@ -16,7 +16,7 @@ Use the children shortcode to list the child pages of a page and the further des | 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 | -| sort | none | Sort children by **Weight** - to sort on menu order, **Name** - to sort alphabetically on menu label, **Identifier** - to sort alphabetically on identifier set in frontmatter, and **URL** - to sort by URL | +| sort | [ordersectionsby]({{% relref "basics/configuration#global-site-parameters" %}}) | Sort children by **weight** - to sort on menu order, **title** - to sort alphabetically on menu label | ## Demo diff --git a/exampleSite/content/shortcodes/children/children-1/_index.en.md b/exampleSite/content/shortcodes/children/children-1/_index.en.md index 5df9eef83c..76b027f34c 100644 --- a/exampleSite/content/shortcodes/children/children-1/_index.en.md +++ b/exampleSite/content/shortcodes/children/children-1/_index.en.md @@ -2,6 +2,7 @@ alwaysopen = false description = "This is a demo child page" title = "page 1" +weight = 10 +++ This is a demo child page. \ No newline at end of file diff --git a/exampleSite/content/shortcodes/children/children-2/_index.en.md b/exampleSite/content/shortcodes/children/children-2/_index.en.md index 3e83249dd4..1468f8515a 100644 --- a/exampleSite/content/shortcodes/children/children-2/_index.en.md +++ b/exampleSite/content/shortcodes/children/children-2/_index.en.md @@ -1,6 +1,7 @@ +++ alwaysopen = false title = "page 2" +weight = 20 +++ This is a demo child page with no description. diff --git a/exampleSite/content/shortcodes/children/children-3/_index.en.md b/exampleSite/content/shortcodes/children/children-3/_index.en.md index b6558b3ad2..4fa3d9dcf9 100644 --- a/exampleSite/content/shortcodes/children/children-3/_index.en.md +++ b/exampleSite/content/shortcodes/children/children-3/_index.en.md @@ -1,6 +1,7 @@ +++ description = "This is a demo child page" title = "page 3" +weight = 30 +++ This is a demo child page. \ No newline at end of file diff --git a/exampleSite/content/shortcodes/children/children-4/_index.en.md b/exampleSite/content/shortcodes/children/children-4/_index.en.md index 41f79a5bea..25b8559486 100644 --- a/exampleSite/content/shortcodes/children/children-4/_index.en.md +++ b/exampleSite/content/shortcodes/children/children-4/_index.en.md @@ -3,6 +3,7 @@ alwaysopen = false description = "This is a hidden demo child page" hidden = true title = "page 4 (hidden)" +weight = 40 +++ This is a **hidden** demo child page. This page and all its children are hidden in the menu, arrow navigation and children shortcode as long as you aren't viewing this page or its children directly. \ No newline at end of file diff --git a/exampleSite/content/shortcodes/children/test.en.md b/exampleSite/content/shortcodes/children/test.en.md index a7cb6ecf4b..c8e5805e6d 100644 --- a/exampleSite/content/shortcodes/children/test.en.md +++ b/exampleSite/content/shortcodes/children/test.en.md @@ -1,6 +1,7 @@ +++ description = "This is a plain page test" title = "plain page test" +weight = 1 +++ This is a plain demo child page. \ No newline at end of file diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html index d1c4a24d7e..b551931387 100644 --- a/layouts/shortcodes/children.html +++ b/layouts/shortcodes/children.html @@ -3,10 +3,10 @@ {{ $style := .Get "style" | default "li" }} {{ $depth := .Get "depth" | default 1 }} {{ $withDescription := .Get "description" | default false }} -{{ $sortTerm := .Get "sort" | default "Weight" }} +{{ $sortTerm := .Get "sort" | default (.Site.Params.ordersectionsby | default "weight") | lower }} {{ $containerstyle := .Get "containerstyle" | default "ul" }} -{{(printf "<%s class=\"children children-%s\">" $containerstyle $style)|safeHTML}} +{{(printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML}} {{ .Scratch.Set "pages" .Page.Pages }} {{if .Page.IsHome}} @@ -21,15 +21,15 @@ {{ $pages := (.Scratch.Get "pages") }} - {{if eq $sortTerm "Weight"}} + {{if eq $sortTerm "weight"}} {{template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}} - {{else if eq $sortTerm "Name"}} + {{else if or (eq $sortTerm "name") (eq $sortTerm "title")}} {{template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}} - {{else if eq $sortTerm "PublishDate"}} + {{else if eq $sortTerm "publishdate"}} {{template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}} - {{else if eq $sortTerm "Date"}} + {{else if eq $sortTerm "date"}} {{template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}} - {{else if eq $sortTerm "Length"}} + {{else if eq $sortTerm "length"}} {{template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}} {{else}} {{template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}} @@ -77,15 +77,15 @@ {{ $pages := (.Scratch.Get "pages") }} - {{if eq $.sortTerm "Weight"}} + {{if eq $.sortTerm "weight"}} {{template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}} - {{else if eq $.sortTerm "Name"}} + {{else if or (eq $.sortTerm "name") (eq $.sortTerm "title")}} {{template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}} - {{else if eq $.sortTerm "PublishDate"}} + {{else if eq $.sortTerm "publishdate"}} {{template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}} - {{else if eq $.sortTerm "Date"}} + {{else if eq $.sortTerm "date"}} {{template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}} - {{else if eq $.sortTerm "Length"}} + {{else if eq $.sortTerm "length"}} {{template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}} {{else}} {{template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}