mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
Fix issue where all pages appear on root level if children keyword is used on home page.
This commit is contained in:
parent
55b1b8ee83
commit
8cd64b1bc9
1 changed files with 59 additions and 55 deletions
|
@ -4,12 +4,19 @@
|
||||||
{{ $withDescription := .Get "description" | default false }}
|
{{ $withDescription := .Get "description" | default false }}
|
||||||
{{ $sortTerm := .Get "sort" | default "Weight" }}
|
{{ $sortTerm := .Get "sort" | default "Weight" }}
|
||||||
|
|
||||||
|
|
||||||
<ul class="children children-{{$style}}">
|
<ul class="children children-{{$style}}">
|
||||||
{{ .Scratch.Set "pages" .Page.Pages }}
|
{{ .Scratch.Set "pages" .Page.Pages }}
|
||||||
|
|
||||||
|
{{if .Page.IsHome}}
|
||||||
|
<!-- Add pages that are in root dir -->
|
||||||
|
{{ $rootPage := where .Page.Pages "Dir" "" }}
|
||||||
|
{{ .Scratch.Set "pages" (.Page.Sections | union $rootPage)}}
|
||||||
|
{{else}}
|
||||||
{{ if .Page.Sections}}
|
{{ if .Page.Sections}}
|
||||||
{{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
|
{{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{ $pages := (.Scratch.Get "pages") }}
|
{{ $pages := (.Scratch.Get "pages") }}
|
||||||
|
|
||||||
{{if eq $sortTerm "Weight"}}
|
{{if eq $sortTerm "Weight"}}
|
||||||
|
@ -33,8 +40,7 @@
|
||||||
{{ range .menu }}
|
{{ range .menu }}
|
||||||
{{ if and .Params.hidden (not $.showhidden) }}
|
{{ if and .Params.hidden (not $.showhidden) }}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
{{if not .IsHome}}
|
||||||
|
|
||||||
{{if hasPrefix $.style "h"}}
|
{{if hasPrefix $.style "h"}}
|
||||||
{{$num := sub ( int (trim $.style "h") ) 1 }}
|
{{$num := sub ( int (trim $.style "h") ) 1 }}
|
||||||
{{$numn := add $num $.count }}
|
{{$numn := add $num $.count }}
|
||||||
|
@ -49,10 +55,6 @@
|
||||||
{{(printf "</%s>" $.style)|safeHTML}}
|
{{(printf "</%s>" $.style)|safeHTML}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{if $.description}}
|
{{if $.description}}
|
||||||
{{if .Description}}
|
{{if .Description}}
|
||||||
<p>{{.Description}}</p>
|
<p>{{.Description}}</p>
|
||||||
|
@ -60,17 +62,19 @@
|
||||||
<p>{{.Summary}}</p>
|
<p>{{.Summary}}</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
|
||||||
{{ if lt $.count $.depth}}
|
{{ if lt $.count $.depth}}
|
||||||
|
|
||||||
{{if eq $.style "li"}}
|
{{if eq $.style "li"}}
|
||||||
<ul>
|
<ul>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ .Scratch.Set "pages" .Pages }}
|
|
||||||
{{ if .Sections}}
|
{{ if .Sections}}
|
||||||
{{ .Scratch.Set "pages" (.Pages | union .Sections) }}
|
{{ .Scratch.Set "pages" (.Pages | union .Sections) }}
|
||||||
|
{{else}}
|
||||||
|
{{ .Scratch.Set "pages" .Pages }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ $pages := (.Scratch.Get "pages") }}
|
{{ $pages := (.Scratch.Get "pages") }}
|
||||||
|
|
||||||
{{if eq $.sortTerm "Weight"}}
|
{{if eq $.sortTerm "Weight"}}
|
||||||
|
@ -86,11 +90,11 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
{{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if eq $.style "li"}}
|
{{if eq $.style "li"}}
|
||||||
</ul>
|
</ul>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
Loading…
Reference in a new issue