Skip to content

Commit

Permalink
Fix _build.list.local logic
Browse files Browse the repository at this point in the history
Fixes #7089
  • Loading branch information
bep committed Mar 24, 2020
1 parent 971b289 commit 523d519
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
6 changes: 3 additions & 3 deletions hugolib/content_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,11 @@ func newContentTreeFilter(fn func(n *contentNode) bool) contentTreeNodeCallback
}

var (
contentTreeNoListFilter = func(s string, n *contentNode) bool {
contentTreeNoListAlwaysFilter = func(s string, n *contentNode) bool {
if n.p == nil {
return true
}
return n.p.m.noList()
return n.p.m.noListAlways()
}

contentTreeNoRenderFilter = func(s string, n *contentNode) bool {
Expand All @@ -814,7 +814,7 @@ var (
func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallback) {
filter := query.Filter
if filter == nil {
filter = contentTreeNoListFilter
filter = contentTreeNoListAlwaysFilter
}
if query.Prefix != "" {
c.WalkPrefix(query.Prefix, func(s string, v interface{}) bool {
Expand Down
4 changes: 2 additions & 2 deletions hugolib/content_map_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (m *pageMap) createListAllPages() page.Pages {
if n.p == nil {
panic(fmt.Sprintf("BUG: page not set for %q", s))
}
if contentTreeNoListFilter(s, n) {
if contentTreeNoListAlwaysFilter(s, n) {
return false
}
pages = append(pages, n.p)
Expand Down Expand Up @@ -613,7 +613,7 @@ type pageMapQuery struct {

func (m *pageMap) collectPages(query pageMapQuery, fn func(c *contentNode)) error {
if query.Filter == nil {
query.Filter = contentTreeNoListFilter
query.Filter = contentTreeNoListAlwaysFilter
}

m.pages.WalkQuery(query, func(s string, n *contentNode) bool {
Expand Down
7 changes: 3 additions & 4 deletions hugolib/disableKinds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,9 @@ title: Headless Local Lists Sub
sect := getPage(b, ref)
b.Assert(sect, qt.Not(qt.IsNil))
b.Assert(getPageInSitePages(b, ref), qt.IsNil)
b.Assert(getPageInSitePages(b, ref+"/headless-local-page"), qt.IsNil)
for i, p := range sect.RegularPages() {
fmt.Println("REG", i, p.(*pageState).sourceRef())
}

b.Assert(getPageInSitePages(b, "/headless-local/_index.md"), qt.IsNil)
b.Assert(getPageInSitePages(b, "/headless-local/headless-local-page.md"), qt.IsNil)

localPageRef := ref + "/headless-local-page.md"

Expand Down
4 changes: 2 additions & 2 deletions hugolib/page__meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
return nil
}

func (p *pageMeta) noList() bool {
return !p.buildConfig.ShouldList()
func (p *pageMeta) noListAlways() bool {
return p.buildConfig.List != pagemeta.Always
}

func (p *pageMeta) getListFilter(local bool) contentTreeNodeCallback {
Expand Down
4 changes: 0 additions & 4 deletions resources/page/pagemeta/pagemeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ func (b BuildConfig) IsZero() bool {
return !b.set
}

func (b *BuildConfig) ShouldList() bool {
return b.List == Always || b.List == ListLocally
}

func DecodeBuildConfig(m interface{}) (BuildConfig, error) {
b := defaultBuildConfig
if m == nil {
Expand Down

0 comments on commit 523d519

Please sign in to comment.