Repository: gohugoio/hugo (language: go)

Issue:
Check (stable) sort order for duplicate resource names



Discussion / hints:
/cc @jmooring this is re your "now it works, now it doesn't" but; we should at least get the sort order stable, so I will check this tomorrow.

Fix patch:
diff --git a/hugofs/component_fs.go b/hugofs/component_fs.go
index c55f1595729..62d977ae889 100644
--- a/hugofs/component_fs.go
+++ b/hugofs/component_fs.go
@@ -147,13 +147,13 @@ func (f *componentFsDir) ReadDir(count int) ([]iofs.DirEntry, error) {
 	})
 
 	if f.fs.opts.Component == files.ComponentFolderContent {
-		// Finally filter out any duplicate content files, e.g. page.md and page.html.
+		// Finally filter out any duplicate content or resource files, e.g. page.md and page.html.
 		n := 0
 		seen := map[hstrings.Tuple]bool{}
 		for _, fi := range fis {
 			fim := fi.(FileMetaInfo)
 			pi := fim.Meta().PathInfo
-			keep := fim.IsDir() || !pi.IsContent()
+			keep := fim.IsDir()
 
 			if !keep {
 				baseLang := hstrings.Tuple{First: pi.Base(), Second: fim.Meta().Lang}


Test patch:
diff --git a/hugolib/content_map_test.go b/hugolib/content_map_test.go
index 7843ad28589..c666e2a45f1 100644
--- a/hugolib/content_map_test.go
+++ b/hugolib/content_map_test.go
@@ -299,3 +299,30 @@ R: {{ with $r }}{{ .Content }}{{ end }}|
 
 	b.AssertFileContent("public/index.html", "R: Data.")
 }
+
+// Issue #11946.
+func TestBundleResourcesGetDuplicateSortOrder(t *testing.T) {
+	files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+-- content/bundle/index.md --
+-- content/bundle/data-1.txt --
+data-1.txt
+-- content/bundle/data 1.txt --
+data 1.txt
+-- content/bundle/Data 1.txt --
+Data 1.txt
+-- content/bundle/Data-1.txt --
+Data-1.txt
+-- layouts/index.html --
+{{ $bundle := site.GetPage "bundle" }}
+{{ $r := $bundle.Resources.Get "data-1.txt" }}
+R: {{ with $r }}{{ .Content }}{{ end }}|Len: {{ len $bundle.Resources }}|$
+
+`
+
+	for i := 0; i < 3; i++ {
+		b := Test(t, files)
+		b.AssertFileContent("public/index.html", "R: Data 1.txt|", "Len: 1|")
+	}
+}