]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
hugolib: Apply titleCaseStyle to automatic section pages
authorJoe Mooring <joe.mooring@veriphor.com>
Mon, 9 Oct 2023 04:58:54 +0000 (21:58 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 4 Dec 2023 10:42:06 +0000 (11:42 +0100)
Fixes #11547

hugolib/integration_test.go
hugolib/page__meta.go

index 1109694b1f5b3f40bc0bdacaedff4c4ef8c02281..93468ecebbb1bb65052f3da768cdf5369122ce79 100644 (file)
@@ -114,3 +114,36 @@ func TestRenderStringBadMarkupOpt(t *testing.T) {
        }
 
 }
+
+// Issue #11547
+func TestTitleCaseStyleWithAutomaticSectionPages(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- config.toml --
+titleCaseStyle = 'none'
+-- content/books/book-1.md --
+---
+title: Book 1
+tags: [fiction]
+---
+-- content/films/_index.md --
+---
+title: Films
+---
+-- layouts/index.html --
+{{ (site.GetPage "/tags").Title }}
+{{ (site.GetPage "/tags/fiction").Title }}
+{{ (site.GetPage "/books").Title }}
+{{ (site.GetPage "/films").Title }}
+       `
+
+       b := hugolib.NewIntegrationTestBuilder(
+               hugolib.IntegrationTestConfig{
+                       T:           t,
+                       TxtarString: files,
+               },
+       )
+       b.Build()
+       b.AssertFileContent("public/index.html", "tags\nfiction\nbooks\nFilms")
+}
index 3781a847ad000f6a4e143cbe0fade1f902e87a93..eb1559fb113b4fdf3a3d492a2e112643d73c3904 100644 (file)
@@ -690,13 +690,10 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error {
                        } else {
                                sectionName = p.sections[0]
                        }
-
-                       sectionName = helpers.FirstUpper(sectionName)
                        if p.s.conf.PluralizeListTitles {
-                               p.title = flect.Pluralize(sectionName)
-                       } else {
-                               p.title = sectionName
+                               sectionName = flect.Pluralize(sectionName)
                        }
+                       p.title = p.s.conf.C.CreateTitle(sectionName)
                case kinds.KindTerm:
                        // TODO(bep) improve
                        key := p.sections[len(p.sections)-1]