Don't use the same value in .Data.Term.Title as in .Title

Fixes #12041
This commit is contained in:
Bjørn Erik Pedersen 2024-02-17 12:00:40 +01:00
parent 9679443c15
commit 5bdda0bdbf
3 changed files with 22 additions and 2 deletions

View file

@ -160,7 +160,7 @@ Draft5: {{ if (.Site.GetPage "blog/draftsection/sub/page") }}FOUND{{ end }}|
Sections: /blog/|/docs/|/overlap/|/overlap2/|:END Sections: /blog/|/docs/|/overlap/|/overlap2/|:END
Categories: /categories/funny/; Funny; 12|/categories/sad/; Sad; 2|:END Categories: /categories/funny/; Funny; 12|/categories/sad/; Sad; 2|:END
Category Terms: taxonomy: /categories/funny/; Funny; 12|/categories/sad/; Sad; 2|:END Category Terms: taxonomy: /categories/funny/; Funny; 12|/categories/sad/; Sad; 2|:END
Category Funny: term; Funny: /blog/subsection/page4/;|/blog/page3/;|/blog/subsection/;|/blog/page2/;|/blog/page1/;|/blog/subsection/page5/;|/docs/page6/;|/blog/bundle/;|/blog/draftsection/page/;|/blog/draftsection/sub/;|/blog/draftsection/sub/page/;|/overlap2/;|:END Category Funny: term; funny: /blog/subsection/page4/;|/blog/page3/;|/blog/subsection/;|/blog/page2/;|/blog/page1/;|/blog/subsection/page5/;|/docs/page6/;|/blog/bundle/;|/blog/draftsection/page/;|/blog/draftsection/sub/;|/blog/draftsection/sub/page/;|/overlap2/;|:END
Pag Num Pages: 9 Pag Num Pages: 9
Pag Blog Num Pages: 4 Pag Blog Num Pages: 4
Blog Num RegularPages: 4 Blog Num RegularPages: 4

View file

@ -44,7 +44,7 @@ func (p *pageData) Data() any {
p.data[name.singular] = term p.data[name.singular] = term
p.data["Singular"] = name.singular p.data["Singular"] = name.singular
p.data["Plural"] = name.plural p.data["Plural"] = name.plural
p.data["Term"] = p.Title() p.data["Term"] = p.m.term
case kinds.KindTaxonomy: case kinds.KindTaxonomy:
viewCfg := p.s.pageMap.cfg.getTaxonomyConfig(p.Path()) viewCfg := p.s.pageMap.cfg.getTaxonomyConfig(p.Path())
p.data["Singular"] = viewCfg.singular p.data["Singular"] = viewCfg.singular

View file

@ -815,3 +815,23 @@ Terms: {{ range site.Taxonomies.tags }}{{ .Page.Title }}: {{ .Count }}|{{ end }}
b.AssertFileContent("public/index.html", "Terms: A: 1|B: 1|C: 1|Hello World!: 1|$") b.AssertFileContent("public/index.html", "Terms: A: 1|B: 1|C: 1|Hello World!: 1|$")
} }
func TestTaxonomiesTermTitleAndTerm(t *testing.T) {
files := `
-- hugo.toml --
baseURL = "https://example.com"
[taxonomies]
tag = "tags"
-- content/_index.md --
---
title: "Home"
tags: ["hellO world"]
---
-- layouts/_default/term.html --
{{ .Title }}|{{ .Kind }}|{{ .Data.Singular }}|{{ .Data.Plural }}|{{ .Page.Data.Term }}|
`
b := Test(t, files)
b.AssertFileContent("public/tags/hello-world/index.html", "HellO World|term|tag|tags|hellO world|")
}