mirror of
https://github.com/McShelby/hugo-theme-relearn
synced 2025-05-10 16:57:47 +08:00
nav: fix breadcrumb for huge installations #446
This commit is contained in:
parent
26988d262b
commit
5ed690f68b
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…
x
Reference in New Issue
Block a user