Fix term template lookup when its backed by a content file - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit f27e578718e9ec9a7a8dbbf23134852455f9a667
(DIR) parent d310595a2ba672fa30dc9a9a2679542cfc919a35
(HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 25 Feb 2024 15:43:52 +0100
Fix term template lookup when its backed by a content file
Closes #12146
Diffstat:
M hugolib/content_map_page.go | 6 ++++--
M hugolib/taxonomy_test.go | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
@@ -1552,8 +1552,10 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
}
pages.InsertIntoValuesDimension(pi.Base(), n)
term = pages.Get(pi.Base())
- } else if term.(*pageState).m.term != v {
- term.(*pageState).m.term = v
+ } else {
+ m := term.(*pageState).m
+ m.term = v
+ m.singular = viewName.singular
}
if s == "" {
(DIR) diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
@@ -885,3 +885,29 @@ build:
b.AssertFileExists("public/tags/a/index.html", false)
b.AssertFileContent("public/index.html", "|0|")
}
+
+func TestTaxonomiesTermLookup(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+[taxonomies]
+tag = "tags"
+-- content/_index.md --
+---
+title: "Home"
+tags: ["a", "b"]
+---
+-- layouts/taxonomy/tag.html --
+Tag: {{ .Title }}|
+-- content/tags/a/_index.md --
+---
+title: tag-a-title-override
+---
+`
+
+ b := Test(t, files)
+
+ b.AssertFileContent("public/tags/a/index.html", "Tag: tag-a-title-override|")
+}