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

@@ -789,11 +789,11 @@ func (s *siteRefLinker) refLink(ref string, source interface{}, relative bool, o
if refURL.Fragment != "" {
_ = target
link = link + "#" + refURL.Fragment
if pctx, ok := target.(pageContext); ok && target.File() != nil && !pctx.getRenderingConfig().PlainIDAnchors {
if pctx, ok := target.(pageContext); ok && !target.File().IsZero() && !pctx.getRenderingConfig().PlainIDAnchors {
if refURL.Path != "" {
link = link + ":" + target.File().UniqueID()
}
} else if pctx, ok := p.(pageContext); ok && p.File() != nil && !pctx.getRenderingConfig().PlainIDAnchors {
} else if pctx, ok := p.(pageContext); ok && !p.File().IsZero() && !pctx.getRenderingConfig().PlainIDAnchors {
link = link + ":" + p.File().UniqueID()
}