From 7f9615ea9dde6a681fd9e569950f4da4d09fd24f Mon Sep 17 00:00:00 2001 From: KitAmbraid <128903658+KitAmbraid@users.noreply.github.com> Date: Sat, 22 Feb 2025 12:06:42 +0100 Subject: [PATCH] Add option to personalize toc header (#1243) --- plugs/index/toc.ts | 3 ++- website/Table of Contents.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugs/index/toc.ts b/plugs/index/toc.ts index 0817a018..9b92c37b 100644 --- a/plugs/index/toc.ts +++ b/plugs/index/toc.ts @@ -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 = ""; } diff --git a/website/Table of Contents.md b/website/Table of Contents.md index cd7a7679..f9a88cc2 100644 --- a/website/Table of Contents.md +++ b/website/Table of Contents.md @@ -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