hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 6792d86ad028571c684a776c5f00e0107838c955
parent e7d87e2410fce27b3519bdb360e6d2f0ccfedb0e
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:
Mhugolib/page_bundler_handlers.go | 1+
Mhugolib/page_bundler_test.go | 4++++
2 files changed, 5 insertions(+), 0 deletions(-)
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)
 				}
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"))