Add .RegularPagesRecursive

Fixes #6411
This commit is contained in:
Bjørn Erik Pedersen
2020-03-16 11:37:57 +01:00
parent 94fb4dc3dd
commit 03b93bb988
8 changed files with 100 additions and 2 deletions

View File

@@ -383,3 +383,42 @@ func TestShouldDoSimpleLookup(t *testing.T) {
c.Assert(shouldDoSimpleLookup("docs/foo.md"), qt.Equals, false)
}
func TestRegularPagesRecursive(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithConfigFile("yaml", `
baseURL: "http://example.org/"
title: "My New Hugo Site"
`)
b.WithContent(
"docs/1.md", "\n---title: docs1\n---",
"docs/sect1/_index.md", "\n---title: docs_sect1\n---",
"docs/sect1/ps1.md", "\n---title: docs_sect1_ps1\n---",
"docs/sect1/ps2.md", "\n---title: docs_sect1_ps2\n---",
"docs/sect1/sect1_s2/_index.md", "\n---title: docs_sect1_s2\n---",
"docs/sect1/sect1_s2/ps2_1.md", "\n---title: docs_sect1_s2_1\n---",
"docs/sect2/_index.md", "\n---title: docs_sect2\n---",
"docs/sect2/ps1.md", "\n---title: docs_sect2_ps1\n---",
"docs/sect2/ps2.md", "\n---title: docs_sect2_ps2\n---",
"news/1.md", "\n---title: news1\n---",
)
b.WithTemplates("index.html", `
{{ $sect1 := site.GetPage "sect1" }}
Sect1 RegularPagesRecursive: {{ range $sect1.RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
`)
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", `
Sect1 RegularPagesRecursive: page:/docs/sect1/ps1/|page:/docs/sect1/ps2/|page:/docs/sect1/sect1_s2/ps2_1/||End.
`)
}