mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
@ -166,19 +166,14 @@ func (c *pageFinder) getContentNodeForRef(context page.Page, isReflink, hadExten
|
|||||||
// Given the above, for regular pages we use the containing folder.
|
// Given the above, for regular pages we use the containing folder.
|
||||||
var baseDir string
|
var baseDir string
|
||||||
if pi := context.PathInfo(); pi != nil {
|
if pi := context.PathInfo(); pi != nil {
|
||||||
if pi.IsBranchBundle() || (hadExtension) {
|
if pi.IsBranchBundle() || (hadExtension && strings.HasPrefix(ref, "../")) {
|
||||||
baseDir = pi.Dir()
|
baseDir = pi.Dir()
|
||||||
} else {
|
} else {
|
||||||
baseDir = pi.ContainerDir()
|
baseDir = pi.ContainerDir()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rel := path.Join(baseDir, inRef)
|
rel := path.Join(baseDir, ref)
|
||||||
|
|
||||||
if !hadExtension && !paths.HasExt(rel) {
|
|
||||||
// See comment above.
|
|
||||||
rel += defaultContentExt
|
|
||||||
}
|
|
||||||
|
|
||||||
relPath := contentPathParser.Parse(files.ComponentFolderContent, rel)
|
relPath := contentPathParser.Parse(files.ComponentFolderContent, rel)
|
||||||
|
|
||||||
|
@ -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")
|
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) {
|
func TestGetPageBundleToRegular(t *testing.T) {
|
||||||
files := `
|
files := `
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
|
Reference in New Issue
Block a user