Skip to content

Commit bb7b3d3

Browse files
committed
Fix cascade with overlapping sections
Fixes #12465
1 parent 873a5cd commit bb7b3d3

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

hugolib/cascade_test.go

+41
Original file line numberDiff line numberDiff line change
@@ -876,3 +876,44 @@ Background: {{ .Params.background }}|
876876
b.AssertFileContent("public/p1/index.html", "Background: yosemite.jpg")
877877
}
878878
}
879+
880+
// Issue #12465.
881+
func TestCascadeOverlap(t *testing.T) {
882+
t.Parallel()
883+
884+
files := `
885+
-- hugo.toml --
886+
disableKinds = ['home','rss','sitemap','taxonomy','term']
887+
-- layouts/_default/list.html --
888+
{{ .Title }}
889+
-- layouts/_default/single.html --
890+
{{ .Title }}
891+
-- content/s/_index.md --
892+
---
893+
title: s
894+
cascade:
895+
_build:
896+
render: never
897+
---
898+
-- content/s/p1.md --
899+
---
900+
title: p1
901+
---
902+
-- content/sx/_index.md --
903+
---
904+
title: sx
905+
---
906+
-- content/sx/p2.md --
907+
---
908+
title: p2
909+
---
910+
`
911+
912+
b := Test(t, files)
913+
914+
b.AssertFileExists("public/s/index.html", false)
915+
b.AssertFileExists("public/s/p1/index.html", false)
916+
917+
b.AssertFileExists("public/sx/index.html", true) // failing
918+
b.AssertFileExists("public/sx/p2/index.html", true) // failing
919+
}

hugolib/content_map_page.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ func (sa *sitePagesAssembler) applyAggregates() error {
13971397
pw.WalkContext.Data().Insert(keyPage, cascade)
13981398
}
13991399
} else {
1400-
_, data := pw.WalkContext.Data().LongestPrefix(keyPage)
1400+
_, data := pw.WalkContext.Data().LongestPrefix(paths.Dir(keyPage))
14011401
if data != nil {
14021402
cascade = data.(*maps.Ordered[page.PageMatcher, maps.Params])
14031403
}

0 commit comments

Comments
 (0)