]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix global resource isn't published when using an uncommon code construct
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 07:55:19 +0000 (08:55 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 08:50:50 +0000 (09:50 +0100)
Fixes #12190

tpl/resources/resources_integration_test.go

index d72b1350729dece883e231c415d2462ecc5b5606..38ff790558b0c59e5972314b54ba2888a13c67bd 100644 (file)
@@ -143,3 +143,31 @@ ByType: /401K%20Prospectus.txt|http://example.com/401K%20Prospectus.txt|
 
                `)
 }
+
+func TestGlobalResourcesNotPublishedRegressionIssue12190(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['page','rss','section','sitemap','taxonomy','term']
+-- assets/a.txt --
+I am a.txt
+-- assets/b.txt --
+I am b.txt
+-- layouts/index.html --
+{{ with resources.ByType "text" }}
+  {{ with .Get "a.txt" }}
+    {{ .Publish }}
+  {{ end }}
+  {{ with .GetMatch "*b*" }}
+    {{ .Publish }}
+  {{ end }}
+{{ end }}
+`
+
+       b := hugolib.Test(t, files)
+
+       b.AssertFileExists("public/index.html", true)
+       b.AssertFileExists("public/a.txt", true) // failing test
+       b.AssertFileExists("public/b.txt", true) // failing test
+}