Skip to content

Commit

Permalink
Adjust Page.GetPage to navigate similar to GitHub for links with exte…
Browse files Browse the repository at this point in the history
…nsion
  • Loading branch information
bep committed Jan 17, 2024
1 parent ab286ae commit 58e8813
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hugolib/pagecollections.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *pageFinder) getContentNode(context page.Page, isReflink bool, ref strin
}

if paths.HasExt(ref) {
return c.getContentNodeForRef(context, isReflink, inRef, ref)
return c.getContentNodeForRef(context, isReflink, true, inRef, ref)
}

var refs []string
Expand All @@ -143,7 +143,7 @@ func (c *pageFinder) getContentNode(context page.Page, isReflink bool, ref strin
}

for _, ref := range refs {
n, err := c.getContentNodeForRef(context, isReflink, inRef, ref)
n, err := c.getContentNodeForRef(context, isReflink, false, inRef, ref)
if n != nil || err != nil {
return n, err
}
Expand All @@ -152,7 +152,7 @@ func (c *pageFinder) getContentNode(context page.Page, isReflink bool, ref strin
return nil, nil
}

func (c *pageFinder) getContentNodeForRef(context page.Page, isReflink bool, inRef, ref string) (contentNodeI, error) {
func (c *pageFinder) getContentNodeForRef(context page.Page, isReflink, hadExtension bool, inRef, ref string) (contentNodeI, error) {
contentParser := c.pageMap.s.Conf.PathParser()

if context != nil && !strings.HasPrefix(ref, "/") {
Expand All @@ -163,7 +163,7 @@ func (c *pageFinder) getContentNodeForRef(context page.Page, isReflink bool, inR
// Given the above, for regular pages we use the containing folder.
var baseDir string
if pi := context.PathInfo(); pi != nil {
if pi.IsBranchBundle() {
if hadExtension || pi.IsBranchBundle() {
baseDir = pi.Dir()
} else {
baseDir = pi.ContainerDir()
Expand Down

0 comments on commit 58e8813

Please sign in to comment.