diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-03-25 18:18:34 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-03-26 10:20:40 +0100 |
commit | 4dae52af680e6ff2c8cdeb4ce1f219330b27001c (patch) | |
tree | db157b09fc15b25a07512581fbd80536fe8e18ee /hugolib/page.go | |
parent | 794d4052b87c98943588b35e1cfecc06e6a0c7f2 (diff) |
Avoid nilpointer on no File on Page
Fixes #5781
Diffstat (limited to 'hugolib/page.go')
-rw-r--r-- | hugolib/page.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index 576342cfa..99b771eee 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -236,7 +236,7 @@ func (p *pageState) TranslationKey() string { p.translationKeyInit.Do(func() { if p.m.translationKey != "" { p.translationKey = p.Kind() + "/" + p.m.translationKey - } else if p.IsPage() && p.File() != nil { + } else if p.IsPage() && !p.File().IsZero() { p.translationKey = path.Join(p.Kind(), filepath.ToSlash(p.File().Dir()), p.File().TranslationBaseName()) } else if p.IsNode() { p.translationKey = path.Join(p.Kind(), p.SectionsPath()) @@ -462,7 +462,7 @@ func (p *pageState) Render(layout ...string) template.HTML { func (p *pageState) wrapError(err error) error { var filename string - if p.File() != nil { + if !p.File().IsZero() { filename = p.File().Filename() } @@ -665,7 +665,7 @@ func (p *pageState) parseError(err error, input []byte, offset int) error { } func (p *pageState) pathOrTitle() string { - if p.File() != nil { + if !p.File().IsZero() { return p.File().Filename() } @@ -763,7 +763,7 @@ func (p *pageState) sortParentSections() { // For pages that do not (sections witout content page etc.), it returns the // virtual path, consistent with where you would add a source file. func (p *pageState) sourceRef() string { - if p.File() != nil { + if !p.File().IsZero() { sourcePath := p.File().Path() if sourcePath != "" { return "/" + filepath.ToSlash(sourcePath) |