mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Fix taxonomies vs expired
In Hugo 0.57 we needed to delay the page metadata initialization until we had built the page graph. This introduced a regression in that we now created taxonomy entries for expired pages. This fixes that by moving the "should not build" filter before we assemble the taxonomies. Fixes #6213
This commit is contained in:
parent
ea9261e856
commit
9475f61a37
3 changed files with 43 additions and 8 deletions
|
@ -466,14 +466,6 @@ func (c *PageCollections) createWorkAllPages() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp := bucket.pages[:0]
|
|
||||||
for _, x := range bucket.pages {
|
|
||||||
if c.pagesMap.s.shouldBuild(x) {
|
|
||||||
tmp = append(tmp, x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bucket.pages = tmp
|
|
||||||
|
|
||||||
if bucket.isEmpty() {
|
if bucket.isEmpty() {
|
||||||
if bucket.owner.IsSection() && bucket.owner.File().IsZero() {
|
if bucket.owner.IsSection() && bucket.owner.File().IsZero() {
|
||||||
// Check for any nested section.
|
// Check for any nested section.
|
||||||
|
|
|
@ -100,6 +100,17 @@ func (m *pagesMap) initPageMetaFor(prefix string, bucket *pagesMapBucket) error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now that the metadata is initialized (with dates, draft set etc.)
|
||||||
|
// we can remove the pages that we for some reason should not include
|
||||||
|
// in this build.
|
||||||
|
tmp := bucket.pages[:0]
|
||||||
|
for _, x := range bucket.pages {
|
||||||
|
if m.s.shouldBuild(x) {
|
||||||
|
tmp = append(tmp, x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bucket.pages = tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -320,3 +320,35 @@ Content.
|
||||||
b.AssertFileContent("public/tags/index.html", `<li><a href="http://example.com/tags/rocks-i-say/">Rocks I say!</a> 10</li>`)
|
b.AssertFileContent("public/tags/index.html", `<li><a href="http://example.com/tags/rocks-i-say/">Rocks I say!</a> 10</li>`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 6213
|
||||||
|
func TestTaxonomiesNotForDrafts(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
b := newTestSitesBuilder(t)
|
||||||
|
b.WithContent("draft.md", `---
|
||||||
|
title: "Draft"
|
||||||
|
draft: true
|
||||||
|
categories: ["drafts"]
|
||||||
|
---
|
||||||
|
|
||||||
|
`,
|
||||||
|
"regular.md", `---
|
||||||
|
title: "Not Draft"
|
||||||
|
categories: ["regular"]
|
||||||
|
---
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
b.Build(BuildCfg{})
|
||||||
|
s := b.H.Sites[0]
|
||||||
|
|
||||||
|
b.Assert(b.CheckExists("public/categories/regular/index.html"), qt.Equals, true)
|
||||||
|
b.Assert(b.CheckExists("public/categories/drafts/index.html"), qt.Equals, false)
|
||||||
|
|
||||||
|
reg, _ := s.getPageNew(nil, "categories/regular")
|
||||||
|
dra, _ := s.getPageNew(nil, "categories/draft")
|
||||||
|
b.Assert(reg, qt.Not(qt.IsNil))
|
||||||
|
b.Assert(dra, qt.IsNil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue