Fix .Fragments when called cross sites on uninitialized output format

Fixes #10794
This commit is contained in:
Bjørn Erik Pedersen
2023-03-05 10:32:00 +01:00
parent df5608f8a0
commit b83050cb40
7 changed files with 114 additions and 33 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/gohugoio/hugo/lazy"
"github.com/gohugoio/hugo/markup/converter"
"github.com/gohugoio/hugo/markup/tableofcontents"
)
// OutputFormatContentProvider represents the method set that is "outputFormat aware" and that we
@@ -73,6 +74,17 @@ func (lcp *LazyContentProvider) Reset() {
lcp.init.Reset()
}
func (lcp *LazyContentProvider) TableOfContents(ctx context.Context) template.HTML {
lcp.init.Do(ctx)
return lcp.cp.TableOfContents(ctx)
}
func (lcp *LazyContentProvider) Fragments(ctx context.Context) *tableofcontents.Fragments {
lcp.init.Do(ctx)
return lcp.cp.Fragments(ctx)
}
func (lcp *LazyContentProvider) Content(ctx context.Context) (any, error) {
lcp.init.Do(ctx)
return lcp.cp.Content(ctx)