Avoid nilpointer on no File on Page

Fixes #5781
This commit is contained in:
Bjørn Erik Pedersen
2019-03-25 18:18:34 +01:00
parent 794d4052b8
commit 4dae52af68
15 changed files with 213 additions and 16 deletions

View File

@@ -222,7 +222,7 @@ func (p *pageMeta) Params() map[string]interface{} {
}
func (p *pageMeta) Path() string {
if p.File() != nil {
if !p.File().IsZero() {
return p.File().Path()
}
return p.SectionsPath()
@@ -256,7 +256,7 @@ func (p *pageMeta) Section() string {
return p.sections[0]
}
if p.File() != nil {
if !p.File().IsZero() {
return p.File().Section()
}
@@ -536,8 +536,8 @@ func (pm *pageMeta) setMetadata(p *pageState, frontmatter map[string]interface{}
func (p *pageMeta) applyDefaultValues() error {
if p.markup == "" {
if p.File() != nil {
// Fall back to {file extension
if !p.File().IsZero() {
// Fall back to file extension
p.markup = helpers.GuessType(p.File().Ext())
}
if p.markup == "" {