summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-03-07 08:34:00 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-03-07 09:50:50 +0100
commit4271b6be0fe18ffdd8dd1bf74e996d339b2fb209 (patch)
tree14111feefbaceac62c1ca96ac4196bd2b22507f8
parent0567a3e6f1c03be45ee3dc9ae79e6f791dfa289f (diff)
Fix section page resource not published if resource filename partially matches content file name
Fixes #12198
-rw-r--r--hugolib/content_map_page.go2
-rw-r--r--hugolib/content_map_test.go32
2 files changed, 33 insertions, 1 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index ddc22bb66..f20a30abe 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -485,7 +485,7 @@ func (m *pageMap) forEachResourceInPage(
rw.Handle = func(resourceKey string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
if isBranch {
ownerKey, _ := m.treePages.LongestPrefixAll(resourceKey)
- if ownerKey != keyPage {
+ if ownerKey != keyPage && path.Dir(ownerKey) != path.Dir(resourceKey) {
// Stop walking downwards, someone else owns this resource.
rw.SkipPrefix(ownerKey + "/")
return false, nil
diff --git a/hugolib/content_map_test.go b/hugolib/content_map_test.go
index e043d9363..85e2c6056 100644
--- a/hugolib/content_map_test.go
+++ b/hugolib/content_map_test.go
@@ -326,3 +326,35 @@ R: {{ with $r }}{{ .Content }}{{ end }}|Len: {{ len $bundle.Resources }}|$
b.AssertFileContent("public/index.html", "R: Data 1.txt|", "Len: 1|")
}
}
+
+func TestBundleResourcesNoPublishedIssue12198(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['home','rss','sitemap','taxonomy','term']
+-- content/s1/p1.md --
+---
+title: p1
+---
+-- content/s1/foo.txt --
+foo.txt
+-- content/s1/p1.txt --
+p1.txt
+-- content/s1/p1-foo.txt --
+p1-foo.txt
+-- layouts/_default/list.html --
+{{.Title }}|
+-- layouts/_default/single.html --
+{{.Title }}|
+ `
+
+ b := Test(t, files)
+ b.Build()
+
+ b.AssertFileExists("public/s1/index.html", true)
+ b.AssertFileExists("public/s1/foo.txt", true)
+ b.AssertFileExists("public/s1/p1.txt", true) // failing test
+ b.AssertFileExists("public/s1/p1-foo.txt", true) // failing test
+ b.AssertFileExists("public/s1/p1/index.html", true)
+}