mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
@@ -505,6 +505,14 @@ date: 2017-01-15
|
|||||||
title: No Date
|
title: No Date
|
||||||
---
|
---
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
// https://github.com/gohugoio/hugo/issues/5854
|
||||||
|
b.WithSimpleConfigFile().WithContent("with-index-date/_index.md", `---
|
||||||
|
title: Date
|
||||||
|
date: 2018-01-15
|
||||||
|
---
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
b.CreateSites().Build(BuildCfg{})
|
b.CreateSites().Build(BuildCfg{})
|
||||||
@@ -515,6 +523,7 @@ title: No Date
|
|||||||
assert.Equal(2017, s.getPage("/").Date().Year())
|
assert.Equal(2017, s.getPage("/").Date().Year())
|
||||||
assert.Equal(2017, s.getPage("/no-index").Date().Year())
|
assert.Equal(2017, s.getPage("/no-index").Date().Year())
|
||||||
assert.True(s.getPage("/with-index-no-date").Date().IsZero())
|
assert.True(s.getPage("/with-index-no-date").Date().IsZero())
|
||||||
|
assert.Equal(2018, s.getPage("/with-index-date").Date().Year())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -162,12 +162,18 @@ 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
|
if dates != nil {
|
||||||
|
currentSection.m.Dates = *dates
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSection = p
|
currentSection = p
|
||||||
children = make(page.Pages, 0)
|
children = make(page.Pages, 0)
|
||||||
dates = &resource.Dates{}
|
dates = nil
|
||||||
|
// Use section's dates from front matter if set.
|
||||||
|
if resource.IsZeroDates(currentSection) {
|
||||||
|
dates = &resource.Dates{}
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -176,15 +182,18 @@ func (s *Site) assembleSections() pageStatePages {
|
|||||||
// Regular page
|
// Regular page
|
||||||
p.parent = currentSection
|
p.parent = currentSection
|
||||||
children = append(children, p)
|
children = append(children, p)
|
||||||
dates.UpdateDateAndLastmodIfAfter(p)
|
if dates != nil {
|
||||||
|
dates.UpdateDateAndLastmodIfAfter(p)
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
if currentSection != nil {
|
if currentSection != nil {
|
||||||
currentSection.setPages(children)
|
currentSection.setPages(children)
|
||||||
currentSection.m.Dates = *dates
|
if dates != nil {
|
||||||
|
currentSection.m.Dates = *dates
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the sections hierarchy
|
// Build the sections hierarchy
|
||||||
|
Reference in New Issue
Block a user