mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Fix .Fragments when called cross sites on uninitialized output format
Fixes #10794
This commit is contained in:
@@ -334,9 +334,6 @@ type PageWithoutContent interface {
|
||||
// Used in change/dependency tracking.
|
||||
identity.Provider
|
||||
|
||||
// Fragments returns the fragments for this page.
|
||||
Fragments(context.Context) *tableofcontents.Fragments
|
||||
|
||||
// Headings returns the headings for this page when a filter is set.
|
||||
// This is currently only triggered with the Related content feature
|
||||
// and the "fragments" type of index.
|
||||
@@ -407,6 +404,9 @@ type SitesProvider interface {
|
||||
type TableOfContentsProvider interface {
|
||||
// TableOfContents returns the table of contents for the page rendered as HTML.
|
||||
TableOfContents(context.Context) template.HTML
|
||||
|
||||
// Fragments returns the fragments for this page.
|
||||
Fragments(context.Context) *tableofcontents.Fragments
|
||||
}
|
||||
|
||||
// TranslationsProvider provides access to any translations.
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user