aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/pagecollections_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-06-02 12:54:14 +0200
committerBjørn Erik Pedersen <[email protected]>2024-06-02 13:30:52 +0200
commit917199a94ea4d67eb911d3e7e26cd7c828fae323 (patch)
treea2cbd49da9ca1b41040b0b742e92746cc6db508a /hugolib/pagecollections_test.go
parentc8dac67defbb512877e974814e196782989b8214 (diff)
downloadhugo-917199a94ea4d67eb911d3e7e26cd7c828fae323.tar.gz
hugo-917199a94ea4d67eb911d3e7e26cd7c828fae323.zip
content adapter: Fix site.GetPage using the base part of the path
Fixes #12561
Diffstat (limited to 'hugolib/pagecollections_test.go')
-rw-r--r--hugolib/pagecollections_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/hugolib/pagecollections_test.go b/hugolib/pagecollections_test.go
index be81c3a66..96f1afe3d 100644
--- a/hugolib/pagecollections_test.go
+++ b/hugolib/pagecollections_test.go
@@ -693,3 +693,36 @@ draft: true
b.AssertFileContent("public/s1-foo/index.html", "/s1-foo/: Pages: /s1-foo/p2/|/s1-foo/s2-foo/|/s1-foo/s2/|$")
b.AssertFileContent("public/s1-foo/s2/index.html", "/s1-foo/s2/: Pages: /s1-foo/s2/p3/|$")
}
+
+func TestGetPageContentAdapterBaseIssue12561(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['rss','section','sitemap','taxonomy','term']
+-- layouts/index.html --
+Test A: {{ (site.GetPage "/s1/p1").Title }}
+Test B: {{ (site.GetPage "p1").Title }}
+Test C: {{ (site.GetPage "/s2/p2").Title }}
+Test D: {{ (site.GetPage "p2").Title }}
+-- layouts/_default/single.html --
+{{ .Title }}
+-- content/s1/p1.md --
+---
+title: p1
+---
+-- content/s2/_content.gotmpl --
+{{ .AddPage (dict "path" "p2" "title" "p2") }}
+`
+
+ b := Test(t, files)
+
+ b.AssertFileExists("public/s1/p1/index.html", true)
+ b.AssertFileExists("public/s2/p2/index.html", true)
+ b.AssertFileContent("public/index.html",
+ "Test A: p1",
+ "Test B: p1",
+ "Test C: p2",
+ "Test D: p2", // fails
+ )
+}