hugolib: Fix Related when called from shortcode

Fixes #5071
This commit is contained in:
Bjørn Erik Pedersen
2018-08-14 18:11:36 +02:00
parent 5c5384916e
commit 0dd06bdac0
2 changed files with 19 additions and 7 deletions

View File

@@ -145,15 +145,16 @@ func (p *Page) Eq(other interface{}) bool {
}
func unwrapPage(in interface{}) (*Page, error) {
if po, ok := in.(*PageOutput); ok {
in = po.Page
}
pp, ok := in.(*Page)
if !ok {
switch v := in.(type) {
case *Page:
return v, nil
case *PageOutput:
return v.Page, nil
case *PageWithoutContent:
return v.Page, nil
default:
return nil, fmt.Errorf("%T not supported", in)
}
return pp, nil
}
// Sections returns this section's subsections, if any.