diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-03-05 09:51:14 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-03-05 12:51:57 +0100 |
commit | df5608f8a0706c6519f50b5497e36c21b8e790be (patch) | |
tree | a5bd23a5f67ac1d9e9a7915bf94aead301d1c503 /hugolib/page.go | |
parent | f56ce01ae1a3e5b399410ea8876ebc7321204edd (diff) | |
download | hugo-df5608f8a0706c6519f50b5497e36c21b8e790be.tar.gz hugo-df5608f8a0706c6519f50b5497e36c21b8e790be.zip |
Allow page.TableOfContents on self in shortcode
Fixes #10791
Diffstat (limited to 'hugolib/page.go')
-rw-r--r-- | hugolib/page.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index 40972d7c5..aa107c63e 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -17,6 +17,7 @@ import ( "bytes" "context" "fmt" + "html/template" "path" "path/filepath" "sort" @@ -62,9 +63,8 @@ var ( var ( pageTypesProvider = resource.NewResourceTypesProvider(media.OctetType, pageResourceType) nopPageOutput = &pageOutput{ - pagePerOutputProviders: nopPagePerOutput, - ContentProvider: page.NopPage, - TableOfContentsProvider: page.NopPage, + pagePerOutputProviders: nopPagePerOutput, + ContentProvider: page.NopPage, } ) @@ -159,6 +159,11 @@ func (p *pageState) Fragments(ctx context.Context) *tableofcontents.Fragments { return p.pageOutput.cp.tableOfContents } +func (p *pageState) TableOfContents(ctx context.Context) template.HTML { + p.s.initInit(ctx, p.cp.initToC, p) + return p.pageOutput.cp.tableOfContentsHTML +} + func (p *pageState) HeadingsFiltered(context.Context) tableofcontents.Headings { return nil } @@ -951,7 +956,6 @@ func (p *pageState) shiftToOutputFormat(isRenderingSite bool, idx int) error { }) p.pageOutput.contentRenderer = lcp p.pageOutput.ContentProvider = lcp - p.pageOutput.TableOfContentsProvider = lcp p.pageOutput.PageRenderProvider = lcp } } |