return &PageCollections{rawAllPages: pages}
}
-func (c *PageCollections) getPage(typ string, path ...string) *Page {
- pages := c.findPagesByKindIn(typ, c.Pages)
+func (c *PageCollections) getFirstPageMatchIn(ps Pages, typ string, path ...string) *Page {
+ pages := c.findPagesByKindIn(typ, ps)
if len(pages) == 0 {
return nil
}
return nil
+
+}
+
+func (c *PageCollections) getPage(typ string, path ...string) *Page {
+ var pages Pages
+
+ if typ == KindPage {
+ pages = c.RegularPages
+ } else {
+ pages = c.indexPages
+ }
+
+ return c.getFirstPageMatchIn(pages, typ, path...)
+
}
func (*PageCollections) findPagesByKindIn(kind string, inPages Pages) Pages {
// 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) {