Table of contents
Change how the table of contents is generated
You can Override the default table of contents plugin by passing an alternative plugin.
To get full control of the header
and tableOfContents
creation, it is
possible to inject a custom tocPlugin
.
return docs({
// other options
tocPlugin: (/*params*/) => {
// implementation
},
});
The array that is passed to the plugin should be filled with the headings that
are retrieving when parsing the AST
.
export type DocServiceOptions = Pick<ConfigOptions, 'baseRoute'> & {
// other options
tocPlugin?: (headings: DocHeading[]) => unified.Plugin;
};