hugolib: Set .Parent in bundled pages to its owner - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 6792d86ad028571c684a776c5f00e0107838c955
DIR parent e7d87e2410fce27b3519bdb360e6d2f0ccfedb0e
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Fri, 6 Apr 2018 10:41:28 +0200
hugolib: Set .Parent in bundled pages to its owner
Fixes #4582
Diffstat:
M hugolib/page_bundler_handlers.go | 1 +
M hugolib/page_bundler_test.go | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
---
DIR diff --git a/hugolib/page_bundler_handlers.go b/hugolib/page_bundler_handlers.go
@@ -228,6 +228,7 @@ func (c *contentHandlers) parsePage(h contentHandler) contentHandler {
if res.resource != nil {
if pageResource, ok := res.resource.(*Page); ok {
pageResource.resourcePath = filepath.ToSlash(childCtx.target)
+ pageResource.parent = p
}
p.Resources = append(p.Resources, res.resource)
}
DIR diff --git a/hugolib/page_bundler_test.go b/hugolib/page_bundler_test.go
@@ -132,6 +132,10 @@ func TestPageBundlerSiteRegular(t *testing.T) {
assert.Contains(firstPage.Content, "TheContent")
assert.Equal(6, len(leafBundle1.Resources))
+ // https://github.com/gohugoio/hugo/issues/4582
+ assert.Equal(leafBundle1, firstPage.Parent())
+ assert.Equal(leafBundle1, secondPage.Parent())
+
assert.Equal(firstPage, pageResources.GetByPrefix("1"))
assert.Equal(secondPage, pageResources.GetByPrefix("2"))
assert.Nil(pageResources.GetByPrefix("doesnotexist"))