ref: 6792d86ad028571c684a776c5f00e0107838c955
parent: e7d87e2410fce27b3519bdb360e6d2f0ccfedb0e
author: Bjørn Erik Pedersen <[email protected]>
date: Fri Apr 6 06:41:28 EDT 2018
hugolib: Set .Parent in bundled pages to its owner Fixes #4582
--- a/hugolib/page_bundler_handlers.go
+++ b/hugolib/page_bundler_handlers.go
@@ -228,6 +228,7 @@
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)
}
--- a/hugolib/page_bundler_test.go
+++ b/hugolib/page_bundler_test.go
@@ -132,6 +132,10 @@
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"))