Fix site.GetPage, never do short lookups for paths with leadig slash

Fixes #12638
This commit is contained in:
Bjørn Erik Pedersen
2024-07-04 09:05:29 +02:00
parent 82af94d1f5
commit 8cf96f244a
2 changed files with 30 additions and 8 deletions

View File

@@ -413,6 +413,35 @@ layout: p2
b.AssertFileContent("public/s1/p2/index.html", "p1")
}
func TestGetPageNewsVsTagsNewsIssue12638(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['rss','section','sitemap']
[taxonomies]
tag = "tags"
-- content/p1.md --
---
title: p1
tags: [news]
---
-- layouts/index.html --
/tags/news: {{ with .Site.GetPage "/tags/news" }}{{ .Title }}{{ end }}|
news: {{ with .Site.GetPage "news" }}{{ .Title }}{{ end }}|
/news: {{ with .Site.GetPage "/news" }}{{ .Title }}{{ end }}|
`
b := Test(t, files)
b.AssertFileContent("public/index.html",
"/tags/news: News|",
"news: News|",
"/news: |",
)
}
func TestGetPageBundleToRegular(t *testing.T) {
files := `
-- hugo.toml --