hugolib: Enable nested sections

Fixes #465
This commit is contained in:
Bjørn Erik Pedersen
2017-04-09 10:33:04 +02:00
parent bef5048580
commit b39689393c
11 changed files with 633 additions and 181 deletions

View File

@@ -337,6 +337,11 @@ func (h *HugoSites) createMissingPages() error {
}
}
// Will create content-less root sections.
newSections := s.assembleSections()
s.Pages = append(s.Pages, newSections...)
newPages = append(newPages, newSections...)
// taxonomy list and terms pages
taxonomies := s.Language.GetStringMapString("taxonomies")
if len(taxonomies) > 0 {
@@ -384,33 +389,6 @@ func (h *HugoSites) createMissingPages() error {
}
}
}
if s.isEnabled(KindSection) {
sectionPages := s.findPagesByKind(KindSection)
if len(sectionPages) < len(s.Sections) {
for name, section := range s.Sections {
// A section may be created for the root content folder if a
// content file is placed there.
// We cannot create a section node for that, because
// that would overwrite the home page.
if name == "" {
continue
}
foundSection := false
for _, sectionPage := range sectionPages {
if sectionPage.sections[0] == name {
foundSection = true
break
}
}
if !foundSection {
n := s.newSectionPage(name, section)
s.Pages = append(s.Pages, n)
newPages = append(newPages, n)
}
}
}
}
}
if len(newPages) > 0 {