1.1 KiB
1.1 KiB
You can add a table of contents to a page using the toc
Markdown/Code Widgets.
In its most basic form it looks like this (click the edit button to see the code):
You can use it in two ways:
- Manually, by adding a
toc
widget to the pages where you’d like to render a ToC - Automatically, using a Live Template Widgets
To have a ToC added to all pages with a larger (e.g. 3) number of headings, it is recommended to use template/widget/toc. You can do this by either copy and pasting it into your own space, or by using Federation and have it included in your space that way:
federation:
- uri: silverbullet.md/template/widget/toc
Configuration
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 tofalse
to disable rendering this headerminHeaders
: only renders a ToC if the number of headers in the current page exceeds this number, otherwise render an empty widget
Example:
header: false
minHeaders: 1