hugolib: Fix a .Page.GetPage from bundle case

Fixes #12120
This commit is contained in:
Bjørn Erik Pedersen
2024-02-23 09:37:05 +01:00
parent c4fe45ff4c
commit f521336c81
2 changed files with 29 additions and 7 deletions

View File

@@ -386,6 +386,33 @@ Home. {{ with .Page.GetPage "p1.xyz" }}{{ else }}OK 1{{ end }} {{ with .Site.Get
b.AssertFileContent("public/index.html", "Home. OK 1 OK 2")
}
func TestGetPageIssue12120(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
-- content/s1/p1/index.md --
---
title: p1
layout: p1
---
-- content/s1/p2.md --
---
title: p2
layout: p2
---
-- layouts/_default/p1.html --
{{ (.GetPage "p2.md").Title }}|
-- layouts/_default/p2.html --
{{ (.GetPage "p1").Title }}|
`
b := Test(t, files)
b.AssertFileContent("public/s1/p1/index.html", "p2") // failing test
b.AssertFileContent("public/s1/p2/index.html", "p1")
}
func TestGetPageBundleToRegular(t *testing.T) {
files := `
-- hugo.toml --