mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
hugolib: Speed up GetPage
When we know to look into the index pages collection, do that: ``` benchmark old ns/op new ns/op delta BenchmarkGetPage-4 51483 7072 -86.26% benchmark old allocs new allocs delta BenchmarkGetPage-4 71 71 +0.00% benchmark old bytes new bytes delta BenchmarkGetPage-4 2648 2648 +0.00% ``` This commit also returns an error if .Site.GetPage is called with the regular Page Kind, as that is currently not supported. Fixes #3503
This commit is contained in:
@@ -1906,8 +1906,11 @@ func (s *Site) Stats() {
|
||||
// This will return nil when no page could be found.
|
||||
//
|
||||
// The valid page types are: home, section, taxonomy and taxonomyTerm
|
||||
func (s *SiteInfo) GetPage(typ string, path ...string) *Page {
|
||||
return s.getPage(typ, path...)
|
||||
func (s *SiteInfo) GetPage(typ string, path ...string) (*Page, error) {
|
||||
if typ == KindPage {
|
||||
return nil, errors.New("GetPage not supported for regular pages")
|
||||
}
|
||||
return s.getPage(typ, path...), nil
|
||||
}
|
||||
|
||||
func (s *Site) permalinkForOutputFormat(link string, f output.Format) (string, error) {
|
||||
|
Reference in New Issue
Block a user