hugolib: Fix dates for sections with dates in front matter

Fixes #5854
This commit is contained in:
Bjørn Erik Pedersen
2019-04-13 18:58:06 +02:00
parent f2795d4d2c
commit 701486728e
2 changed files with 23 additions and 5 deletions

View File

@@ -162,12 +162,18 @@ func (s *Site) assembleSections() pageStatePages {
if currentSection != nil {
// A new section
currentSection.setPages(children)
currentSection.m.Dates = *dates
if dates != nil {
currentSection.m.Dates = *dates
}
}
currentSection = p
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
@@ -176,15 +182,18 @@ func (s *Site) assembleSections() pageStatePages {
// Regular page
p.parent = currentSection
children = append(children, p)
dates.UpdateDateAndLastmodIfAfter(p)
if dates != nil {
dates.UpdateDateAndLastmodIfAfter(p)
}
return false
})
if currentSection != nil {
currentSection.setPages(children)
currentSection.m.Dates = *dates
if dates != nil {
currentSection.m.Dates = *dates
}
}
// Build the sections hierarchy