diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-03-19 13:17:10 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-03-19 15:07:48 +0100 |
commit | 0750a9ec91bbd7fc1bf21d1a7b5a0710e967c645 (patch) | |
tree | 9662cf6c599832a5ba260660f56dab493c270547 /hugolib | |
parent | 90bc1f802aa3949452b9aaeb03a5a4e486c4a7f1 (diff) | |
download | hugo-0750a9ec91bbd7fc1bf21d1a7b5a0710e967c645.tar.gz hugo-0750a9ec91bbd7fc1bf21d1a7b5a0710e967c645.zip |
Fix regression for outputs defined in front matter for term pages
Fixes #12275
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/content_map_page.go | 5 | ||||
-rw-r--r-- | hugolib/hugo_sites_build.go | 12 | ||||
-rw-r--r-- | hugolib/site_output_test.go | 37 |
3 files changed, 49 insertions, 5 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 64a15a59a..f4ff2a9ee 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -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 } diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index c33f06bd5..cc8847f55 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -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 } diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go index a68555574..3d95709c5 100644 --- a/hugolib/site_output_test.go +++ b/hugolib/site_output_test.go @@ -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 +} |