URI: 
       hugolib: Fix Related when called from shortcode - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 0dd06bdac008aa81ec2e8f29ad8110dac0227011
   DIR parent 5c5384916e8f954f3ea66148ecceb3732584588e
  HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Tue, 14 Aug 2018 18:11:36 +0200
       
       hugolib: Fix Related when called from shortcode
       
       Fixes #5071
       
       Diffstat:
         M hugolib/shortcode_test.go           |      11 +++++++++++
         M hugolib/site_sections.go            |      15 ++++++++-------
       
       2 files changed, 19 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
       @@ -150,6 +150,17 @@ func TestPositionalParamIndexOutOfBounds(t *testing.T) {
                CheckShortCodeMatch(t, "{{< video 47238zzb >}}", "Playing Video Missing", wt)
        }
        
       +// #5071
       +func TestShortcodeRelated(t *testing.T) {
       +        t.Parallel()
       +        wt := func(tem tpl.TemplateHandler) error {
       +                tem.AddTemplate("_internal/shortcodes/a.html", `{{ len (.Site.RegularPages.Related .Page) }}`)
       +                return nil
       +        }
       +
       +        CheckShortCodeMatch(t, "{{< a >}}", "0", wt)
       +}
       +
        // some repro issues for panics in Go Fuzz testing
        
        func TestNamedParamSC(t *testing.T) {
   DIR diff --git a/hugolib/site_sections.go b/hugolib/site_sections.go
       @@ -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.