hugolib: Add capitalizeListTitles config option

Whether to capitalize automatic page titles, applicable to section,
taxonomy, and term pages. Default is true.

Closes #9793
Closes #12115
This commit is contained in:
Joe Mooring
2024-02-22 11:51:22 -08:00
committed by Bjørn Erik Pedersen
parent ea0ba9751d
commit 36bf3cb98c
4 changed files with 78 additions and 4 deletions

View File

@@ -446,7 +446,7 @@ title: "My Title"
params:
build: "My Build"
---
´
´
`
}
@@ -746,15 +746,26 @@ func (p *pageMeta) applyDefaultValues() error {
if p.s.conf.PluralizeListTitles {
sectionName = flect.Pluralize(sectionName)
}
p.pageConfig.Title = p.s.conf.C.CreateTitle(sectionName)
if p.s.conf.CapitalizeListTitles {
sectionName = p.s.conf.C.CreateTitle(sectionName)
}
p.pageConfig.Title = sectionName
case kinds.KindTerm:
if p.term != "" {
p.pageConfig.Title = p.s.conf.C.CreateTitle(p.term)
if p.s.conf.CapitalizeListTitles {
p.pageConfig.Title = p.s.conf.C.CreateTitle(p.term)
} else {
p.pageConfig.Title = p.term
}
} else {
panic("term not set")
}
case kinds.KindTaxonomy:
p.pageConfig.Title = strings.Replace(p.s.conf.C.CreateTitle(p.pathInfo.Unnormalized().BaseNameNoIdentifier()), "-", " ", -1)
if p.s.conf.CapitalizeListTitles {
p.pageConfig.Title = strings.Replace(p.s.conf.C.CreateTitle(p.pathInfo.Unnormalized().BaseNameNoIdentifier()), "-", " ", -1)
} else {
p.pageConfig.Title = strings.Replace(p.pathInfo.Unnormalized().BaseNameNoIdentifier(), "-", " ", -1)
}
case kinds.KindStatus404:
p.pageConfig.Title = "404 Page not found"
}