Skip to content

Commit 7f9615e

Browse files
authored
Add option to personalize toc header (#1243)
1 parent f553c62 commit 7f9615e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

plugs/index/toc.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type TocConfig = {
1515
// Don't show the TOC if there are more than this many headers
1616
maxHeaders?: number;
1717
header?: boolean;
18+
headerText?: string;
1819
};
1920

2021
export async function widget(
@@ -58,7 +59,7 @@ export async function widget(
5859
// Too many headers, not showing TOC
5960
return null;
6061
}
61-
let headerText = "# Table of Contents\n";
62+
let headerText = config.headerText ?? "# Table of Contents\n";
6263
if (config.header === false) {
6364
headerText = "";
6465
}

website/Table of Contents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ To have a ToC added to all pages with a larger (e.g. 3) number of headings, it i
1616
In the body of the `toc` code widget you can configure a few options:
1717

1818
* `header`: by default a “Table of Contents” header is added to the ToC, set this to `false` to disable rendering this header
19+
* `headerText`: by default "# Table of Contents\n". Change it to change the rendering of this header
1920
* `minHeaders`: only renders a ToC if the number of headers in the current page exceeds this number, otherwise renders an empty widget
2021
* `maxHeaders`: only renders a ToC if the number of headers in the current page is below this number, otherwise renders an empty widget
2122

0 commit comments

Comments
 (0)