mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

Markdown page table of contents

Open JorelAli opened this issue 4 years ago • 5 comments

Expanding from the idea of @ishitatsuyuki, I think mdbook should have the option to have a right-hand sidebar with a table of contents for a page.

Screenshot example

image

Examples of similar documents:

  • https://redux.js.org/introduction/learning-resources
  • https://docusaurus.io/docs/en/installation
  • https://code.visualstudio.com/docs/editor/codebasics

This could be implemented as an option in the book.toml file, or could be a YAML front matter setting at the top of a page, such as:

---
toc: true
---

Page content here...

JorelAli avatar Jun 23 '20 16:06 JorelAli

For anyone still reading this (@aidan-fitz @tshepang @maniyar1), I've made a temporary workaround here.

JorelAli avatar Jul 10 '20 13:07 JorelAli

Thanks @JorelAli 👍

I've used the CSS/JS you wrote and put it in a Userscript here (to be run by the browser). This way we can have a page ToC on deployed mdBooks that do not have one yet.

Hopefully this is somewhat useful :)

Sebas-h avatar Oct 28 '21 08:10 Sebas-h

Come across this issue when I tried to find a solution for in-page tocs. This is such a great job and I wonder why not file a PR to merge this into mdbook's main stream so that everyone can use this feature out-of-box?

Evian-Zhang avatar Jun 29 '23 01:06 Evian-Zhang

wow, this is exactly what I need, I spent a lot of time looking for it, I really look forward to merging it into mdbook soon. Pleeeeeaaaaase!!! It will save users a lot of time out of the box. Big thanks!!!

Leroy-X avatar Sep 21 '23 09:09 Leroy-X