mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 12:13:05 +00:00
parent
87b16abd93
commit
1d9dde82a0
2 changed files with 31 additions and 1 deletions
|
@ -448,7 +448,7 @@ categories: ["cool stuff"]
|
||||||
|
|
||||||
b := newTestSitesBuilder(t)
|
b := newTestSitesBuilder(t)
|
||||||
b.WithSimpleConfigFile().WithContent("page.md", pageContent)
|
b.WithSimpleConfigFile().WithContent("page.md", pageContent)
|
||||||
b.WithSimpleConfigFile().WithContent("blog/page.md", pageContent)
|
b.WithContent("blog/page.md", pageContent)
|
||||||
|
|
||||||
b.CreateSites().Build(BuildCfg{})
|
b.CreateSites().Build(BuildCfg{})
|
||||||
|
|
||||||
|
@ -470,6 +470,34 @@ categories: ["cool stuff"]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPageDatesSections(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
b := newTestSitesBuilder(t)
|
||||||
|
b.WithSimpleConfigFile().WithContent("no-index/page.md", `
|
||||||
|
---
|
||||||
|
title: Page
|
||||||
|
date: 2017-01-15
|
||||||
|
---
|
||||||
|
`)
|
||||||
|
b.WithSimpleConfigFile().WithContent("with-index-no-date/_index.md", `---
|
||||||
|
title: No Date
|
||||||
|
---
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
b.CreateSites().Build(BuildCfg{})
|
||||||
|
|
||||||
|
assert.Equal(1, len(b.H.Sites))
|
||||||
|
s := b.H.Sites[0]
|
||||||
|
|
||||||
|
assert.Equal(2017, s.getPage("/").Date().Year())
|
||||||
|
assert.Equal(2017, s.getPage("/no-index").Date().Year())
|
||||||
|
assert.True(s.getPage("/with-index-no-date").Date().IsZero())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateNewPage(t *testing.T) {
|
func TestCreateNewPage(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
|
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
|
||||||
|
|
|
@ -162,6 +162,7 @@ func (s *Site) assembleSections() pageStatePages {
|
||||||
if currentSection != nil {
|
if currentSection != nil {
|
||||||
// A new section
|
// A new section
|
||||||
currentSection.setPages(children)
|
currentSection.setPages(children)
|
||||||
|
currentSection.m.Dates = *dates
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSection = p
|
currentSection = p
|
||||||
|
@ -176,6 +177,7 @@ func (s *Site) assembleSections() pageStatePages {
|
||||||
p.parent = currentSection
|
p.parent = currentSection
|
||||||
children = append(children, p)
|
children = append(children, p)
|
||||||
dates.UpdateDateAndLastmodIfAfter(p)
|
dates.UpdateDateAndLastmodIfAfter(p)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue