mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
children: default sorting ignores ordersectionsby #62
This commit is contained in:
parent
dff23d89b4
commit
39957388d4
7 changed files with 18 additions and 13 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
alwaysopen = false
|
||||
description = "This is a demo child page"
|
||||
title = "page 1"
|
||||
weight = 10
|
||||
+++
|
||||
|
||||
This is a demo child page.
|
|
@ -1,6 +1,7 @@
|
|||
+++
|
||||
alwaysopen = false
|
||||
title = "page 2"
|
||||
weight = 20
|
||||
+++
|
||||
|
||||
This is a demo child page with no description.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
+++
|
||||
description = "This is a demo child page"
|
||||
title = "page 3"
|
||||
weight = 30
|
||||
+++
|
||||
|
||||
This is a demo child page.
|
|
@ -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.
|
|
@ -1,6 +1,7 @@
|
|||
+++
|
||||
description = "This is a plain page test"
|
||||
title = "plain page test"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
This is a plain demo child page.
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in a new issue