Has ToC

Function to indicate whether the current page has table of contents.

Donate

Become a backer or sponsor to support our work.

On this page

Sponsors

Backgrounds

The .TableOfContents is not always empty string when there is no table of contents, it may be <nav id="TableOfContents"></nav>, and the function is used to deal with this case.

Usage

The function accepts the page variable as the context, and return a boolean value indicates whether the given page has table of contents.

1{{ if partial "base/functions/has-toc" . }}
2  {{ .TableOfContents }}
3{{ end }}