diff options
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/page.go | 12 | ||||
-rw-r--r-- | hugolib/page__output.go | 15 |
2 files changed, 14 insertions, 13 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 } } diff --git a/hugolib/page__output.go b/hugolib/page__output.go index 4ef78b612..ae2fdb778 100644 --- a/hugolib/page__output.go +++ b/hugolib/page__output.go @@ -54,13 +54,12 @@ func newPageOutput( } po := &pageOutput{ - f: f, - pagePerOutputProviders: providers, - ContentProvider: page.NopPage, - TableOfContentsProvider: page.NopPage, - PageRenderProvider: page.NopPage, - render: render, - paginator: pag, + f: f, + pagePerOutputProviders: providers, + ContentProvider: page.NopPage, + PageRenderProvider: page.NopPage, + render: render, + paginator: pag, } return po @@ -84,7 +83,6 @@ type pageOutput struct { contentRenderer page.ContentRenderer pagePerOutputProviders page.ContentProvider - page.TableOfContentsProvider page.PageRenderProvider // May be nil. @@ -97,7 +95,6 @@ func (p *pageOutput) initContentProvider(cp *pageContentOutput) { } p.contentRenderer = cp p.ContentProvider = cp - p.TableOfContentsProvider = cp p.PageRenderProvider = cp p.cp = cp |