Fix handling of "outputs" from content adapter pages

Fixes #13689
This commit is contained in:
Bjørn Erik Pedersen
2025-05-06 09:09:05 +02:00
parent 80f0595311
commit 363ab48a24
6 changed files with 66 additions and 27 deletions

View File

@@ -779,3 +779,45 @@ Single.
b.AssertFileContent("public/tags/index.html", "Terms: mytag: 1|§s")
}
func TestContentAdapterOutputsIssue13689(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
[outputs]
page = ['html','json']
-- layouts/page.html --
html: {{ .Title }}
-- layouts/page.json --
json: {{ .Title }}
-- content/p1.md --
---
title: p1
---
-- content/p2.md --
---
title: p2
outputs:
- html
---
-- content/_content.gotmpl --
{{ $page := dict "path" "p3" "title" "p3" }}
{{ $.AddPage $page }}
{{ $page := dict "path" "p4" "title" "p4" "outputs" (slice "html") }}
{{ $.AddPage $page }}
`
b := hugolib.Test(t, files)
b.AssertFileExists("public/p1/index.html", true)
b.AssertFileExists("public/p1/index.json", true)
b.AssertFileExists("public/p2/index.html", true)
b.AssertFileExists("public/p2/index.json", false)
b.AssertFileExists("public/p3/index.html", true)
b.AssertFileExists("public/p3/index.json", true)
b.AssertFileExists("public/p4/index.html", true)
b.AssertFileExists("public/p4/index.json", false) // currently returns true
}