aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/shortcode.go
diff options
context:
space:
mode:
authordavidejones <[email protected]>2022-10-25 16:33:25 +0100
committerBjørn Erik Pedersen <[email protected]>2022-10-26 13:00:21 +0200
commite5d2a8f6a3121701eb95712b5540989fafaa0c71 (patch)
treee8f2dd5b1b103d255050c7998113614fe02b0d75 /hugolib/shortcode.go
parent00ff161b675ab16244bd9678807cb0b93240d1b1 (diff)
downloadhugo-e5d2a8f6a3121701eb95712b5540989fafaa0c71.tar.gz
hugo-e5d2a8f6a3121701eb95712b5540989fafaa0c71.zip
Avoid nilpointer when shortcode page content output nil
Updates #10391
Diffstat (limited to 'hugolib/shortcode.go')
-rw-r--r--hugolib/shortcode.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go
index b2f42ff1d..a10afe2bc 100644
--- a/hugolib/shortcode.go
+++ b/hugolib/shortcode.go
@@ -381,6 +381,17 @@ func renderShortcode(
// Pre Hugo 0.55 this was the behaviour even for the outer-most
// shortcode.
if sc.doMarkup && (level > 0 || sc.configVersion() == 1) {
+
+ cp := p.pageOutput.cp
+ if cp == nil {
+ var err error
+ cp, err = newPageContentOutput(p, p.pageOutput)
+ if err != nil {
+ return "", false, err
+ }
+ p.pageOutput.initContentProvider(cp)
+ }
+
var err error
b, err := p.pageOutput.cp.renderContent([]byte(inner), false)
if err != nil {