Fix RegularPagesRecursive for the home page

Fixes #11396
This commit is contained in:
Bjørn Erik Pedersen 2023-08-30 10:25:43 +02:00
parent b2a02c3c5a
commit 15d3e48cec
2 changed files with 20 additions and 1 deletions

View file

@ -254,7 +254,7 @@ func (p *pageState) RegularPagesRecursive() page.Pages {
p.regularPagesRecursiveInit.Do(func() {
var pages page.Pages
switch p.Kind() {
case kinds.KindSection:
case kinds.KindSection, kinds.KindHome:
pages = p.getPagesRecursive()
default:
pages = p.RegularPages()

View file

@ -432,3 +432,22 @@ Sect1 RegularPagesRecursive: page:/docs/sect1/ps1/|page:/docs/sect1/ps2/|page:/d
`)
}
func TestRegularPagesRecursiveHome(t *testing.T) {
files := `
-- hugo.toml --
-- content/p1.md --
-- content/post/p2.md --
-- layouts/index.html --
RegularPagesRecursive: {{ range .RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
}).Build()
b.AssertFileContent("public/index.html", `RegularPagesRecursive: page:/p1/|page:/post/p2/||End.`)
}