aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-03-19 13:17:10 +0100
committerBjørn Erik Pedersen <[email protected]>2024-03-19 15:07:48 +0100
commit0750a9ec91bbd7fc1bf21d1a7b5a0710e967c645 (patch)
tree9662cf6c599832a5ba260660f56dab493c270547 /hugolib
parent90bc1f802aa3949452b9aaeb03a5a4e486c4a7f1 (diff)
downloadhugo-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.go5
-rw-r--r--hugolib/hugo_sites_build.go12
-rw-r--r--hugolib/site_output_test.go37
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
+}