Skip to content

Commit 11bc51a

Browse files
reidmvchalin
authored andcommitted
bugfix: nested sidebar_root_for
Previously, when attempting to use nested sidebar_root_for directives, the sidebar root displayed would be inconsistent for nested "self" directives, and ineffective for nested "children" directives. Investigation pointed to searching the ancestors collection in reverse order. Hugo documentation for the Ancestors method states: > Hugo orders the ancestors from closest to furthest. See https://gohugo.io/methods/page/ancestors/. The list returned by the Anscestors list is already in "reverse" order; calling Reverse on it gives a list with the root first, meaning that we will find the highest-level sidebar_root_for page, rather than the lowest level. This commit removes the Reverse directive. sidebar_root_for directives can now be nested correctly.
1 parent 6f8f85a commit 11bc51a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

layouts/_partials/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{ $sidebarRoot = . -}}
1818
{{ else -}}
1919
{{/* Check ancestors for sidebar_root_for (any value) */ -}}
20-
{{ range .Ancestors.Reverse -}}
20+
{{ range .Ancestors -}}
2121
{{ if not .IsSection -}}
2222
{{ continue -}}
2323
{{ end -}}

0 commit comments

Comments
 (0)