hubolib: Headless bundles should not be listed in .Pages

Fixes #6492
This commit is contained in:
Bjørn Erik Pedersen 2019-11-10 13:36:33 +01:00
parent 70a1aa345b
commit d1d1f240a2
3 changed files with 21 additions and 8 deletions

View file

@ -579,6 +579,12 @@ HEADLESS {{< myShort >}}
// But the bundled resources needs to be published // But the bundled resources needs to be published
th.assertFileContent(filepath.FromSlash(workDir+"/public/s2/l1.png"), "PNG") 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) { func TestMultiSiteBundles(t *testing.T) {

View file

@ -490,14 +490,15 @@ func (c *PageCollections) createWorkAllPages() error {
} }
if !bucket.view { 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 { for _, p := range bucket.pages {
ps := p.(*pageState) ps := p.(*pageState)
ps.parent = bucket.owner 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 { if homeDates != nil {
homeDates.UpdateDateAndLastmodIfAfter(ps) homeDates.UpdateDateAndLastmodIfAfter(ps)

View file

@ -107,8 +107,13 @@ func (m *pagesMap) initPageMetaFor(prefix string, bucket *pagesMapBucket) error
tmp := bucket.pages[:0] tmp := bucket.pages[:0]
for _, x := range bucket.pages { for _, x := range bucket.pages {
if m.s.shouldBuild(x) { if m.s.shouldBuild(x) {
if x.(*pageState).m.headless {
bucket.headlessPages = append(bucket.headlessPages, x)
} else {
tmp = append(tmp, x) tmp = append(tmp, x)
} }
}
} }
bucket.pages = tmp bucket.pages = tmp
} }
@ -412,6 +417,7 @@ type pagesMapBucket struct {
pagesInit sync.Once pagesInit sync.Once
pages page.Pages pages page.Pages
headlessPages page.Pages
pagesAndSectionsInit sync.Once pagesAndSectionsInit sync.Once
pagesAndSections page.Pages pagesAndSections page.Pages