Skip to content

Commit

Permalink
hubolib: Headless bundles should not be listed in .Pages
Browse files Browse the repository at this point in the history
Fixes #6492
  • Loading branch information
bep committed Nov 10, 2019
1 parent 70a1aa3 commit d1d1f24
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions hugolib/pagebundler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions hugolib/pagecollections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions hugolib/pages_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d1d1f24

Please sign in to comment.