Handle rebuilds when resources passed to transform.Unmarshal etc. changes

Fixes #12065
This commit is contained in:
Bjørn Erik Pedersen
2024-02-19 11:32:28 +01:00
parent 5ada27bf65
commit 5dbc29dc6c
4 changed files with 57 additions and 1 deletions

View File

@@ -77,6 +77,27 @@ func TestRebuildEditTextFileInLeafBundle(t *testing.T) {
b.AssertRenderCountContent(1)
}
func TestRebuiEditUnmarshaledYamlFileInLeafBundle(t *testing.T) {
files := `
-- hugo.toml --
baseURL = "https://example.com"
disableLiveReload = true
disableKinds = ["taxonomy", "term", "sitemap", "robotsTXT", "404", "rss"]
-- content/mybundle/index.md --
-- content/mybundle/mydata.yml --
foo: bar
-- layouts/_default/single.html --
MyData: {{ .Resources.Get "mydata.yml" | transform.Unmarshal }}|
`
b := TestRunning(t, files)
b.AssertFileContent("public/mybundle/index.html", "MyData: map[foo:bar]")
b.EditFileReplaceAll("content/mybundle/mydata.yml", "bar", "bar edited").Build()
b.AssertFileContent("public/mybundle/index.html", "MyData: map[foo:bar edited]")
}
func TestRebuildEditTextFileInHomeBundle(t *testing.T) {
b := TestRunning(t, rebuildFilesSimple)
b.AssertFileContent("public/index.html", "Home Content.")