summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-03 15:43:28 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-03 16:30:10 +0100
commit46575baa02562e4ad05c89f4250287413e38627a (patch)
tree80a33f896a58dd224be332c439dddeaf3083e797
parent058f230a1be1abaf589b5a194ef6ec12d14c4021 (diff)
Preserve file/dir name case when loading data
Fixes #11979
-rw-r--r--hugolib/datafiles_test.go17
-rw-r--r--hugolib/hugo_sites.go2
-rw-r--r--hugolib/page_test.go2
-rw-r--r--source/fileInfo.go2
4 files changed, 20 insertions, 3 deletions
diff --git a/hugolib/datafiles_test.go b/hugolib/datafiles_test.go
index 48447414a..99cc5b407 100644
--- a/hugolib/datafiles_test.go
+++ b/hugolib/datafiles_test.go
@@ -47,3 +47,20 @@ d: {{ site.Data.d.v1 }}|
b.AssertFileContent("public/index.html", "a: a_v1|\nb: b_v1|\ncd: c_d_v1|\nd: d_v1_theme|")
})
}
+
+func TestDataMixedCaseFolders(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+-- data/MyFolder/MyData.toml --
+v1 = "my_v1"
+-- layouts/index.html --
+{{ site.Data }}
+v1: {{ site.Data.MyFolder.MyData.v1 }}|
+`
+ b := Test(t, files)
+
+ b.AssertFileContent("public/index.html", "v1: my_v1|")
+}
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 1b2840617..b40477c02 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -502,7 +502,7 @@ func (h *HugoSites) handleDataFile(r *source.File) error {
// Crawl in data tree to insert data
current = h.data
- dataPath := r.FileInfo().Meta().PathInfo.Dir()[1:]
+ dataPath := r.FileInfo().Meta().PathInfo.Unmormalized().Dir()[1:]
keyParts := strings.Split(dataPath, "/")
for _, key := range keyParts {
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index e003f2ee1..d17f3fbce 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1713,7 +1713,7 @@ Single: {{ .Title}}|{{ .RelPermalink }}|{{ .Path }}|
b := Test(t, files)
b.AssertFileContent("public/sect/p1/index.html", "Single: Page1|/sect/p1/|/sect/p1")
b.AssertFileContent("public/sect/PaGe2/index.html", "Single: Page2|/sect/PaGe2/|/sect/p2")
- b.AssertFileContent("public/sect2/page3/index.html", "Single: Page3|/sect2/page3/|/sect2/page3|")
+ b.AssertFileContent("public/sect2/PaGe3/index.html", "Single: Page3|/sect2/PaGe3/|/sect2/page3|")
b.AssertFileContent("public/sect3/Pag.E4/index.html", "Single: Pag.E4|/sect3/Pag.E4/|/sect3/p4|")
}
diff --git a/source/fileInfo.go b/source/fileInfo.go
index 20ddda647..6c67ba407 100644
--- a/source/fileInfo.go
+++ b/source/fileInfo.go
@@ -130,7 +130,7 @@ func (fi *File) pathToDir(s string) string {
}
func (fi *File) p() *paths.Path {
- return fi.fim.Meta().PathInfo
+ return fi.fim.Meta().PathInfo.Unmormalized()
}
func NewFileInfoFrom(path, filename string) *File {