diff options
author | Bjørn Erik Pedersen <[email protected]> | 2021-03-09 10:26:44 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2021-03-09 13:26:39 +0100 |
commit | 18074d0c2375cc4bf4d7933dd4206cb878a23d1c (patch) | |
tree | a244eb41d5d0888494b0003e807a1884f17f4ac8 /hugolib/page__output.go | |
parent | 35bfb662229226d5f3cc3077ca74323f0aa88b7d (diff) | |
download | hugo-18074d0c2375cc4bf4d7933dd4206cb878a23d1c.tar.gz hugo-18074d0c2375cc4bf4d7933dd4206cb878a23d1c.zip |
Fix output format handling for render hooks
Fixes #8176
Diffstat (limited to 'hugolib/page__output.go')
-rw-r--r-- | hugolib/page__output.go | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/hugolib/page__output.go b/hugolib/page__output.go index a3235db49..377e16df5 100644 --- a/hugolib/page__output.go +++ b/hugolib/page__output.go @@ -107,12 +107,39 @@ func (o *pageOutput) initRenderHooks() error { h, err := ps.createRenderHooks(o.f) if err != nil { initErr = err - } - if h == nil { return } - o.cp.renderHooks.hooks = h + + if !o.cp.renderHooksHaveVariants || h.IsZero() { + // Check if there is a different render hooks template + // for any of the other page output formats. + // If not, we can reuse this. + for _, po := range ps.pageOutputs { + if po.f.Name != o.f.Name { + h2, err := ps.createRenderHooks(po.f) + if err != nil { + initErr = err + return + } + + if h2.IsZero() { + continue + } + + if o.cp.renderHooks.hooks.IsZero() { + o.cp.renderHooks.hooks = h2 + } + + o.cp.renderHooksHaveVariants = !h2.Eq(o.cp.renderHooks.hooks) + + if o.cp.renderHooksHaveVariants { + break + } + + } + } + } }) return initErr |