mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
hugolib: Prevent decoding pageParam in common cases
This commit is contained in:
parent
6498d73c08
commit
e98f885b8a
1 changed files with 9 additions and 4 deletions
|
@ -606,15 +606,20 @@ func (p *Page) renderContent(content []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Page) getRenderingConfig() *helpers.Blackfriday {
|
func (p *Page) getRenderingConfig() *helpers.Blackfriday {
|
||||||
|
|
||||||
p.renderingConfigInit.Do(func() {
|
p.renderingConfigInit.Do(func() {
|
||||||
pageParam := cast.ToStringMap(p.GetParam("blackfriday"))
|
p.renderingConfig = p.s.ContentSpec.NewBlackfriday()
|
||||||
|
|
||||||
if p.Language() == nil {
|
if p.Language() == nil {
|
||||||
panic(fmt.Sprintf("nil language for %s with source lang %s", p.BaseFileName(), p.lang))
|
panic(fmt.Sprintf("nil language for %s with source lang %s", p.BaseFileName(), p.lang))
|
||||||
}
|
}
|
||||||
p.renderingConfig = p.s.ContentSpec.NewBlackfriday()
|
|
||||||
|
|
||||||
if err := mapstructure.Decode(pageParam, p.renderingConfig); err != nil {
|
bfParam := p.GetParam("blackfriday")
|
||||||
|
if bfParam == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pageParam := cast.ToStringMap(bfParam)
|
||||||
|
if err := mapstructure.Decode(pageParam, &p.renderingConfig); err != nil {
|
||||||
p.s.Log.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error())
|
p.s.Log.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue