summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-07-02 18:20:14 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-07-04 09:11:49 +0200
commitdd9b1baab0cb860a3eb32fd9043bac18cab3f9f0 (patch)
tree75094e56a0be7bffb5f7647dc7855f5aa0400a4f /hugolib
parent1039356edf747f044c989a5bc0e85d792341ed5d (diff)
hugolib: Make .Site.Sections return the top level sections
See #3591
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/site_sections.go31
-rw-r--r--hugolib/site_sections_test.go1
2 files changed, 8 insertions, 24 deletions
diff --git a/hugolib/site_sections.go b/hugolib/site_sections.go
index f8d9c9d1f..1dd010092 100644
--- a/hugolib/site_sections.go
+++ b/hugolib/site_sections.go
@@ -19,33 +19,16 @@ import (
"strconv"
"strings"
- "github.com/gohugoio/hugo/helpers"
radix "github.com/hashicorp/go-immutable-radix"
)
-// Deprecated: Use .Site.Home.Sections.
-// TODO(bep) Hugo 0.23 = Reuse as an alias for home's sections.
-func (s *SiteInfo) Sections() Taxonomy {
-
- helpText := `In Hugo 0.22 we introduced nested sections, so this method now returns an empty taxonomy.
-
-To list sections with its pages, you can do something like this:
-
-{{ range $.Site.Home.Sections }}
- Section: {{ .Title }}
- {{ range .Pages }}
- Section Page: {{ .Title }}
- {{ end }}
-{{ end }}
-
-To get a specific section, you can do this:
-
-{{ $section := $.Site.GetPage "section" "blog" }}
-`
-
- helpers.Deprecated("Site", "Sections", helpText, true)
-
- return Taxonomy{}
+// Sections returns the top level sections.
+func (s *SiteInfo) Sections() Pages {
+ home, err := s.Home()
+ if err == nil {
+ return home.Sections()
+ }
+ return nil
}
// Home is a shortcut to the home page, equivalent to .Site.GetPage "home".
diff --git a/hugolib/site_sections_test.go b/hugolib/site_sections_test.go
index 7479c45fc..77a85099c 100644
--- a/hugolib/site_sections_test.go
+++ b/hugolib/site_sections_test.go
@@ -246,6 +246,7 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
assert.NotNil(home)
assert.Len(home.Sections(), 9)
+ assert.Equal(home.Sections(), s.Info.Sections())
rootPage := s.getPage(KindPage, "mypage.md")
assert.NotNil(rootPage)