A mdbook plugin that provides a table of contents for each page. Uses css/js from mdBook-pagetoc.
Sample image from mdBook-pagetoc:
-
Only supports the
html
renderer. -
On the first run of
mdbook build
, it creates two filespagetoc.css
andpagetoc.js
. -
You can customize any of them after the first run.
-
Add to
book.toml
config:[preprocessor.pagetoc] [output.html] additional-css = ["theme/pagetoc.css"] additional-js = ["theme/pagetoc.js"]
-
The place marker
<div class="sidetoc"><nav class="pagetoc"></nav></div>
will be inserted inside the<main>
tag. ie. This replaceswith:
-
If not customizing, you may want to add entries as appropriate to
.gitignore
to keep your repo clean:theme/pagetoc.css theme/pagetoc.js
-
Customization: To autohide when only single header, add this snippet to
pagetoc.css
:a[class^='pagetoc-H']:only-child { display: none; }