aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--hugofs/rootmapping_fs.go5
-rw-r--r--hugolib/datafiles_test.go18
2 files changed, 19 insertions, 4 deletions
diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go
index 04c5b4a72..a5bf9aadf 100644
--- a/hugofs/rootmapping_fs.go
+++ b/hugofs/rootmapping_fs.go
@@ -43,7 +43,6 @@ var _ ReverseLookupProvder = (*RootMappingFs)(nil)
func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) {
rootMapToReal := radix.New()
realMapToRoot := radix.New()
- var virtualRoots []RootMapping
addMapping := func(key string, rm RootMapping, to *radix.Tree) {
var mappings []RootMapping
@@ -154,11 +153,8 @@ func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) {
addMapping(rev, rm, realMapToRoot)
- virtualRoots = append(virtualRoots, rm)
}
- rootMapToReal.Insert(filepathSeparator, virtualRoots)
-
rfs := &RootMappingFs{
Fs: fs,
rootMapToReal: rootMapToReal,
@@ -414,6 +410,7 @@ func (fs *RootMappingFs) getRoots(key string) (string, []RootMapping) {
for {
var found bool
ss, vv, found := tree.LongestPrefix(key)
+
if !found || (levels < 2 && ss == key) {
break
}
diff --git a/hugolib/datafiles_test.go b/hugolib/datafiles_test.go
index 99cc5b407..657e6020c 100644
--- a/hugolib/datafiles_test.go
+++ b/hugolib/datafiles_test.go
@@ -64,3 +64,21 @@ v1: {{ site.Data.MyFolder.MyData.v1 }}|
b.AssertFileContent("public/index.html", "v1: my_v1|")
}
+
+// Issue #12133
+func TestDataNoAssets(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['page','rss','section','sitemap','taxonomy','term']
+-- assets/data/foo.toml --
+content = "I am assets/data/foo.toml"
+-- layouts/index.html --
+|{{ site.Data.foo.content }}|
+ `
+
+ b := Test(t, files)
+
+ b.AssertFileContent("public/index.html", "||")
+}