node to page: Only return regular pages in home.Data.Pages
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 17 Nov 2016 09:29:11 +0000 (10:29 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 22 Nov 2016 08:57:03 +0000 (09:57 +0100)
Returning all types is both confusing and too breaking.

All page types can be fetched in .Site.Pages.

Updates #2297

hugolib/node_as_page_test.go
hugolib/page.go

index 19c3745722fbaf0d6b797ff4d3c8569a49492aba..a4fd7830b9133ec53c40bb239c54508e8111460b 100644 (file)
@@ -67,7 +67,7 @@ func TestNodesAsPage(t *testing.T) {
        assertFileContent(t, filepath.Join("public", "index.html"), false,
                "Index Title: Home Sweet Home!",
                "Home <strong>Content!</strong>",
-               "# Pages: 9",
+               "# Pages: 4",
                "Date: 2009-01-02",
                "Lastmod: 2009-01-03",
                "GetPage: Section1 ",
@@ -184,8 +184,8 @@ func TestNodesWithNoContentFile(t *testing.T) {
        require.Len(t, homePages, 1)
 
        homePage := homePages[0]
-       require.Len(t, homePage.Data["Pages"], 9)
-       require.Len(t, homePage.Pages, 9) // Alias
+       require.Len(t, homePage.Data["Pages"], 4)
+       require.Len(t, homePage.Pages, 4)
        require.True(t, homePage.Path() == "")
 
        assertFileContent(t, filepath.Join("public", "index.html"), false,
index ec99e383cf8926fce3d0956c45aaf7797c0bc3d8..6d549273cd6b4e6ee18c14973e978eb73876b056 100644 (file)
@@ -1466,7 +1466,7 @@ func (p *Page) prepareData(s *Site) error {
        switch p.Kind {
        case KindPage:
        case KindHome:
-               pages = s.findPagesByKindNotIn(KindHome, s.Pages)
+               pages = s.RegularPages
        case KindSection:
                sectionData, ok := s.Sections[p.sections[0]]
                if !ok {