diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-11-10 13:36:33 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-11-10 18:57:31 +0100 |
commit | d1d1f240a25945b37eebe8a9a3f439f290832b33 (patch) | |
tree | d15f75056a9a7246b37895642f34f5874dab4981 | |
parent | 70a1aa345b95bcf325f19c6e7184bcd6f885e454 (diff) | |
download | hugo-d1d1f240a25945b37eebe8a9a3f439f290832b33.tar.gz hugo-d1d1f240a25945b37eebe8a9a3f439f290832b33.zip |
hubolib: Headless bundles should not be listed in .Pages
Fixes #6492
-rw-r--r-- | hugolib/pagebundler_test.go | 6 | ||||
-rw-r--r-- | hugolib/pagecollections.go | 11 | ||||
-rw-r--r-- | hugolib/pages_map.go | 12 |
3 files changed, 21 insertions, 8 deletions
diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go index d4d89bd85..eb36700a2 100644 --- a/hugolib/pagebundler_test.go +++ b/hugolib/pagebundler_test.go @@ -579,6 +579,12 @@ HEADLESS {{< myShort >}} // But the bundled resources needs to be published th.assertFileContent(filepath.FromSlash(workDir+"/public/s2/l1.png"), "PNG") + // No headless bundles here, please. + // https://github.com/gohugoio/hugo/issues/6492 + c.Assert(s.RegularPages(), qt.HasLen, 1) + c.Assert(s.home.RegularPages(), qt.HasLen, 1) + c.Assert(s.home.Pages(), qt.HasLen, 1) + } func TestMultiSiteBundles(t *testing.T) { diff --git a/hugolib/pagecollections.go b/hugolib/pagecollections.go index 4711d3de3..7e9682e90 100644 --- a/hugolib/pagecollections.go +++ b/hugolib/pagecollections.go @@ -490,14 +490,15 @@ func (c *PageCollections) createWorkAllPages() error { } if !bucket.view { + for _, p := range bucket.headlessPages { + ps := p.(*pageState) + ps.parent = bucket.owner + c.headlessPages = append(c.headlessPages, ps) + } for _, p := range bucket.pages { ps := p.(*pageState) ps.parent = bucket.owner - if ps.m.headless { - c.headlessPages = append(c.headlessPages, ps) - } else { - c.workAllPages = append(c.workAllPages, ps) - } + c.workAllPages = append(c.workAllPages, ps) if homeDates != nil { homeDates.UpdateDateAndLastmodIfAfter(ps) diff --git a/hugolib/pages_map.go b/hugolib/pages_map.go index c7a74c4c1..aba1aa4bf 100644 --- a/hugolib/pages_map.go +++ b/hugolib/pages_map.go @@ -107,7 +107,12 @@ func (m *pagesMap) initPageMetaFor(prefix string, bucket *pagesMapBucket) error tmp := bucket.pages[:0] for _, x := range bucket.pages { if m.s.shouldBuild(x) { - tmp = append(tmp, x) + if x.(*pageState).m.headless { + bucket.headlessPages = append(bucket.headlessPages, x) + } else { + tmp = append(tmp, x) + } + } } bucket.pages = tmp @@ -410,8 +415,9 @@ type pagesMapBucket struct { parent *pagesMapBucket bucketSections []*pagesMapBucket - pagesInit sync.Once - pages page.Pages + pagesInit sync.Once + pages page.Pages + headlessPages page.Pages pagesAndSectionsInit sync.Once pagesAndSections page.Pages |