mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
nav: fix breadcrumb for huge installations #446
This commit is contained in:
parent
26988d262b
commit
5ed690f68b
2 changed files with 11 additions and 1 deletions
9
layouts/partials/get-page-depth.hugo
Normal file
9
layouts/partials/get-page-depth.hugo
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{{- /* https://discourse.gohugo.io/t/how-to-know-the-section-depth/37302/4 */ -}}
|
||||||
|
{{- $page := .page }}
|
||||||
|
{{- $depth := .depth | default 0 }}
|
||||||
|
{{- with $page.Parent }}
|
||||||
|
{{- $depth = add $depth 1 }}
|
||||||
|
{{- partial "get-page-depth.hugo" (dict "page" . "depth" $depth) }}
|
||||||
|
{{- else }}
|
||||||
|
{{- $depth }}
|
||||||
|
{{- end }}
|
|
@ -144,7 +144,8 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $to := .to }}
|
{{- $to := .to }}
|
||||||
{{- $breadcrumb = $breadcrumb | append $to }}
|
{{- $breadcrumb = $breadcrumb | append $to }}
|
||||||
{{- range seq (len .to.Site.AllPages) }}
|
{{- $depth := int (partial "get-page-depth.hugo" (dict "page" $page)) }}
|
||||||
|
{{- range seq $depth }}
|
||||||
{{- $to = $to.Parent }}
|
{{- $to = $to.Parent }}
|
||||||
{{- if $to }}
|
{{- if $to }}
|
||||||
{{- $breadcrumb = $breadcrumb | append $to }}
|
{{- $breadcrumb = $breadcrumb | append $to }}
|
||||||
|
|
Loading…
Reference in a new issue