mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
2d91b17c04
commit
640b8bed21
2 changed files with 37 additions and 4 deletions
|
@ -116,6 +116,7 @@ Content Page %02d
|
||||||
"Pag: Page 02")
|
"Pag: Page 02")
|
||||||
|
|
||||||
sections := h.findAllPagesByNodeType(NodeSection)
|
sections := h.findAllPagesByNodeType(NodeSection)
|
||||||
|
|
||||||
require.Len(t, sections, 2)
|
require.Len(t, sections, 2)
|
||||||
|
|
||||||
// Check taxonomy lists
|
// Check taxonomy lists
|
||||||
|
@ -352,8 +353,6 @@ menu:
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNodesWithAlias(t *testing.T) {
|
func TestNodesWithAlias(t *testing.T) {
|
||||||
//jww.SetStdoutThreshold(jww.LevelDebug)
|
|
||||||
//defer jww.SetStdoutThreshold(jww.LevelFatal)
|
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
writeLayoutsForNodeAsPageTests(t)
|
writeLayoutsForNodeAsPageTests(t)
|
||||||
|
@ -380,6 +379,30 @@ aliases:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNodesWithSectionWithIndexPageOnly(t *testing.T) {
|
||||||
|
testCommonResetState()
|
||||||
|
|
||||||
|
writeLayoutsForNodeAsPageTests(t)
|
||||||
|
|
||||||
|
writeSource(t, filepath.Join("content", "sect", "_index.md"), `---
|
||||||
|
title: MySection
|
||||||
|
---
|
||||||
|
My Section Content
|
||||||
|
`)
|
||||||
|
|
||||||
|
viper.Set("paginate", 1)
|
||||||
|
viper.Set("title", "Hugo Rocks!")
|
||||||
|
|
||||||
|
s := newSiteDefaultLang()
|
||||||
|
|
||||||
|
if err := buildAndRenderSite(s); err != nil {
|
||||||
|
t.Fatalf("Failed to build site: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assertFileContent(t, filepath.Join("public", "sect", "index.html"), true, "My Section")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func writeRegularPagesForNodeAsPageTests(t *testing.T) {
|
func writeRegularPagesForNodeAsPageTests(t *testing.T) {
|
||||||
writeRegularPagesForNodeAsPageTestsWithLang(t, "")
|
writeRegularPagesForNodeAsPageTestsWithLang(t, "")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1351,8 +1351,8 @@ func (s *Site) buildSiteMeta() (err error) {
|
||||||
// assembleSections: Needs pages (temp lookup)
|
// assembleSections: Needs pages (temp lookup)
|
||||||
s.assembleSections()
|
s.assembleSections()
|
||||||
|
|
||||||
// TODO(bep) np
|
// TODO(bep) np Site.LastMod
|
||||||
pages := s.findPagesByNodeType(NodePage)
|
pages := s.Nodes
|
||||||
s.Info.LastChange = pages[0].Lastmod
|
s.Info.LastChange = pages[0].Lastmod
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1541,11 +1541,21 @@ func (s *Site) resetBuildState() {
|
||||||
func (s *Site) assembleSections() {
|
func (s *Site) assembleSections() {
|
||||||
s.Sections = make(Taxonomy)
|
s.Sections = make(Taxonomy)
|
||||||
s.Info.Sections = s.Sections
|
s.Info.Sections = s.Sections
|
||||||
|
// TODO(bep) np check these vs the caches
|
||||||
regularPages := s.findPagesByNodeType(NodePage)
|
regularPages := s.findPagesByNodeType(NodePage)
|
||||||
|
sectionPages := s.findPagesByNodeType(NodeSection)
|
||||||
|
|
||||||
for i, p := range regularPages {
|
for i, p := range regularPages {
|
||||||
s.Sections.add(p.Section(), WeightedPage{regularPages[i].Weight, regularPages[i]}, s.Info.preserveTaxonomyNames)
|
s.Sections.add(p.Section(), WeightedPage{regularPages[i].Weight, regularPages[i]}, s.Info.preserveTaxonomyNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add sections without regular pages, but with a content page
|
||||||
|
for _, sectionPage := range sectionPages {
|
||||||
|
if _, ok := s.Sections[sectionPage.sections[0]]; !ok {
|
||||||
|
s.Sections[sectionPage.sections[0]] = WeightedPages{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for k := range s.Sections {
|
for k := range s.Sections {
|
||||||
s.Sections[k].Sort()
|
s.Sections[k].Sort()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue