diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 788bb651..5fef548d 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -1,7 +1,8 @@ {{- define "main" }}
- {{ partialCached "hb/modules/docs/nav" . .FirstSection }} + {{ $rootSection := partialCached "hb/modules/docs/functions/root-section" . . }} + {{ partialCached "hb/modules/docs/nav" . $rootSection }}
{{ partial "hugopress/functions/render-hooks" (dict "Page" . "Name" "hb-docs-main-begin") }} diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 2b05fbb1..4470e9e0 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1,7 +1,8 @@ {{- define "main" }}
- {{ partialCached "hb/modules/docs/nav" . .FirstSection }} + {{ $rootSection := partialCached "hb/modules/docs/functions/root-section" . . }} + {{ partialCached "hb/modules/docs/nav" . $rootSection }}
{{ partial "hugopress/functions/render-hooks" (dict "Page" . "Name" "hb-docs-main-begin") }} diff --git a/layouts/partials/hb/modules/docs/functions/root-section.html b/layouts/partials/hb/modules/docs/functions/root-section.html new file mode 100644 index 00000000..428345d6 --- /dev/null +++ b/layouts/partials/hb/modules/docs/functions/root-section.html @@ -0,0 +1,11 @@ +{{- $section := .FirstSection }} +{{- if not (default true $section.Params.docs_root_section) }} + {{- with index .Ancestors.Reverse 2 }} + {{- $section = . }} + {{- else }} + {{- if .IsSection }} + {{- $section = . }} + {{- end }} + {{- end }} +{{- end }} +{{- return $section }} diff --git a/layouts/partials/hb/modules/docs/functions/tree.html b/layouts/partials/hb/modules/docs/functions/tree.html index 5405e6f7..551663bd 100644 --- a/layouts/partials/hb/modules/docs/functions/tree.html +++ b/layouts/partials/hb/modules/docs/functions/tree.html @@ -1,3 +1,3 @@ -{{/* Returns the pages tree of first section of current page. */}} -{{- $tree := partial "hb/modules/docs/functions/walk-section" .FirstSection }} +{{/* Returns the pages tree of the root section of current page. */}} +{{- $tree := partial "hb/modules/docs/functions/walk-section" . }} {{- return $tree -}} diff --git a/layouts/partials/hb/modules/docs/nav.html b/layouts/partials/hb/modules/docs/nav.html index bbcb9856..fbb3b508 100644 --- a/layouts/partials/hb/modules/docs/nav.html +++ b/layouts/partials/hb/modules/docs/nav.html @@ -1,4 +1,5 @@ -{{- $tree := partialCached "hb/modules/docs/functions/tree" . .FirstSection }} +{{- $rootSection := partialCached "hb/modules/docs/functions/root-section" . . }} +{{- $tree := partialCached "hb/modules/docs/functions/tree" $rootSection $rootSection }}