Fix regression for outputs defined in front matter for term pages

Fixes #12275
This commit is contained in:
Bjørn Erik Pedersen 2024-03-19 13:17:10 +01:00
parent 90bc1f802a
commit 0750a9ec91
3 changed files with 49 additions and 5 deletions

View file

@ -1678,6 +1678,11 @@ func (sa *sitePagesAssembler) assemblePagesStep2() error {
if err := sa.applyAggregatesToTaxonomiesAndTerms(); err != nil {
return err
}
return nil
}
func (sa *sitePagesAssembler) assemblePagesStepFinal() error {
if err := sa.assembleResources(); err != nil {
return err
}

View file

@ -282,11 +282,6 @@ func (h *HugoSites) assemble(ctx context.Context, l logg.LevelLogger, bcfg *Buil
return err
}
}
h.renderFormats = output.Formats{}
for _, s := range h.Sites {
s.s.initRenderFormats()
h.renderFormats = append(h.renderFormats, s.renderFormats...)
}
for _, s := range assemblers {
if err := s.assemblePagesStep2(); err != nil {
@ -296,9 +291,16 @@ func (h *HugoSites) assemble(ctx context.Context, l logg.LevelLogger, bcfg *Buil
h.renderFormats = output.Formats{}
for _, s := range h.Sites {
s.s.initRenderFormats()
h.renderFormats = append(h.renderFormats, s.renderFormats...)
}
for _, s := range assemblers {
if err := s.assemblePagesStepFinal(); err != nil {
return err
}
}
return nil
}

View file

@ -646,3 +646,40 @@ WordCount: {{ .WordCount }}
b.AssertFileContent("public/outputs-empty/index.html", "HTML:", "Word1. Word2.")
b.AssertFileContent("public/outputs-string/index.html", "O1:", "Word1. Word2.")
}
func TestOuputFormatFrontMatterTermIssue12275(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','page','rss','section','sitemap','taxonomy']
-- content/p1.md --
---
title: p1
tags:
- tag-a
- tag-b
---
-- content/tags/tag-a/_index.md --
---
title: tag-a
outputs:
- html
- json
---
-- content/tags/tag-b/_index.md --
---
title: tag-b
---
-- layouts/_default/term.html --
{{ .Title }}
-- layouts/_default/term.json --
{{ jsonify (dict "title" .Title) }}
`
b := Test(t, files)
b.AssertFileContent("public/tags/tag-a/index.html", "tag-a")
b.AssertFileContent("public/tags/tag-b/index.html", "tag-b")
b.AssertFileContent("public/tags/tag-a/index.json", `{"title":"tag-a"}`) // failing test
}