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

@@ -166,19 +166,14 @@ func (c *pageFinder) getContentNodeForRef(context page.Page, isReflink, hadExten
// Given the above, for regular pages we use the containing folder.
var baseDir string
if pi := context.PathInfo(); pi != nil {
if pi.IsBranchBundle() || (hadExtension) {
if pi.IsBranchBundle() || (hadExtension && strings.HasPrefix(ref, "../")) {
baseDir = pi.Dir()
} else {
baseDir = pi.ContainerDir()
}
}
rel := path.Join(baseDir, inRef)
if !hadExtension && !paths.HasExt(rel) {
// See comment above.
rel += defaultContentExt
}
rel := path.Join(baseDir, ref)
relPath := contentPathParser.Parse(files.ComponentFolderContent, rel)