aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/content_map_page.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-02-28 11:39:10 +0100
committerBjørn Erik Pedersen <[email protected]>2024-02-28 16:43:19 +0100
commit6a8b25e291a3ab539c966c3057b3561596532011 (patch)
treee8fca693a64caab1631c6818856fb028250edb0f /hugolib/content_map_page.go
parenta322282e70c2935c79f9c0f5c593bfdd032eb964 (diff)
downloadhugo-6a8b25e291a3ab539c966c3057b3561596532011.tar.gz
hugo-6a8b25e291a3ab539c966c3057b3561596532011.zip
Fix .Page.Pages with similary named sections
Fixes #12169
Diffstat (limited to 'hugolib/content_map_page.go')
-rw-r--r--hugolib/content_map_page.go35
1 files changed, 16 insertions, 19 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index 89df951e9..1114428df 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -348,31 +348,28 @@ func (m *pageMap) getPagesInSection(q pageMapQueryPagesInSection) page.Pages {
w := &doctree.NodeShiftTreeWalker[contentNodeI]{
Tree: m.treePages,
Prefix: prefix,
- Handle: func(key string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
- if q.Recursive {
- if p, ok := n.(*pageState); ok && include(p) {
- pas = append(pas, p)
- }
- return false, nil
- }
-
- // We store both leafs and branches in the same tree, so for non-recursive walks,
- // we need to walk until the end, but can skip
- // any not belonging to child branches.
- if otherBranch != "" && strings.HasPrefix(key, otherBranch) {
- return false, nil
- }
+ }
+ w.Handle = func(key string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
+ if q.Recursive {
if p, ok := n.(*pageState); ok && include(p) {
pas = append(pas, p)
}
+ return false, nil
+ }
- if n.isContentNodeBranch() {
- otherBranch = key + "/"
- }
+ if p, ok := n.(*pageState); ok && include(p) {
+ pas = append(pas, p)
+ }
- return false, nil
- },
+ if n.isContentNodeBranch() {
+ currentBranch := key + "/"
+ if otherBranch == "" || otherBranch != currentBranch {
+ w.SkipPrefix(currentBranch)
+ }
+ otherBranch = currentBranch
+ }
+ return false, nil
}
err := w.Walk(context.Background())