mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	| @@ -19,33 +19,16 @@ import ( | |||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/gohugoio/hugo/helpers" |  | ||||||
| 	radix "github.com/hashicorp/go-immutable-radix" | 	radix "github.com/hashicorp/go-immutable-radix" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Deprecated: Use .Site.Home.Sections. | // Sections returns the top level sections. | ||||||
| // TODO(bep) Hugo 0.23 = Reuse as an alias for home's sections. | func (s *SiteInfo) Sections() Pages { | ||||||
| func (s *SiteInfo) Sections() Taxonomy { | 	home, err := s.Home() | ||||||
|  | 	if err == nil { | ||||||
| 	helpText := `In Hugo 0.22 we introduced nested sections, so this method now returns an empty taxonomy. | 		return home.Sections() | ||||||
| 	 | 	} | ||||||
| To list sections with its pages, you can do something like this: | 	return nil | ||||||
|  |  | ||||||
| {{ 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{} |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // Home is a shortcut to the home page, equivalent to .Site.GetPage "home". | // Home is a shortcut to the home page, equivalent to .Site.GetPage "home". | ||||||
|   | |||||||
| @@ -246,6 +246,7 @@ PAG|{{ .Title }}|{{ $sect.InSection . }} | |||||||
| 	assert.NotNil(home) | 	assert.NotNil(home) | ||||||
|  |  | ||||||
| 	assert.Len(home.Sections(), 9) | 	assert.Len(home.Sections(), 9) | ||||||
|  | 	assert.Equal(home.Sections(), s.Info.Sections()) | ||||||
|  |  | ||||||
| 	rootPage := s.getPage(KindPage, "mypage.md") | 	rootPage := s.getPage(KindPage, "mypage.md") | ||||||
| 	assert.NotNil(rootPage) | 	assert.NotNil(rootPage) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user