Add option to personalize toc header (#1243)
parent
f553c62950
commit
7f9615ea9d
|
@ -15,6 +15,7 @@ type TocConfig = {
|
|||
// Don't show the TOC if there are more than this many headers
|
||||
maxHeaders?: number;
|
||||
header?: boolean;
|
||||
headerText?: string;
|
||||
};
|
||||
|
||||
export async function widget(
|
||||
|
@ -58,7 +59,7 @@ export async function widget(
|
|||
// Too many headers, not showing TOC
|
||||
return null;
|
||||
}
|
||||
let headerText = "# Table of Contents\n";
|
||||
let headerText = config.headerText ?? "# Table of Contents\n";
|
||||
if (config.header === false) {
|
||||
headerText = "";
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ To have a ToC added to all pages with a larger (e.g. 3) number of headings, it i
|
|||
In the body of the `toc` code widget you can configure a few options:
|
||||
|
||||
* `header`: by default a “Table of Contents” header is added to the ToC, set this to `false` to disable rendering this header
|
||||
* `headerText`: by default "# Table of Contents\n". Change it to change the rendering of this header
|
||||
* `minHeaders`: only renders a ToC if the number of headers in the current page exceeds this number, otherwise renders an empty widget
|
||||
* `maxHeaders`: only renders a ToC if the number of headers in the current page is below this number, otherwise renders an empty widget
|
||||
|
||||
|
|
Loading…
Reference in New Issue