A simple Table of Content extension

I just made a very simple table of content extension for Craft.

With this simple extension, you can navigate to any Title, Subtitle, Heading, Strong, Card or Page block in one document with just a click. This extension may be helpful for those long documents.

You can get the extension on github or just download the .craftx file.

With the limit of Craft API, this extension can only navigate to the text block and enter it as a page (more details). This limit makes the extension may not work as expected. I will rebuild this extension with further release of new APIs.

I also made an Awesome Craft list (WIP). You can contribute on github as you like.

Feedbacks or ideas are welcome via twitter, github, mail or just reply below.

Thanks.

4 Likes

Thank you! This is fantastic. I tend to have really long notes for docs and meeting notes I develop for work. Having a TOC is very helpful for me.

Enjoy it and if you have any problem or suggestions about this extension, please get in touch with me, I will maintain it. Thanks a lot!

1 Like

Thanks for this extension. Currently, the background is bright even in Dark Mode. Would be nice if this would stick to the currently selected theme.

Thanks for your feedback! I will fix it!

Bug fixed and added an icon to the extension!
Please update the extension from Github or just download here.
If you have any problem, please feel free to get in touch with me!
Enjoy~

Update

  • Dark Mode
  • New Icon
2 Likes

Would be great if the table of content links would just scroll to the clicked headline, instead of navigating into it. But it seems the API does not enable that yet?

The API does not support that yet. But there’s a solution that you can insert a toc to the top of pages and click the inserted block to navigate to other blocks. This extension collected in Awesome Craft works! You can give it try!

1 Like

Nice, will try that!

You could try to select the clicked heading (instead of navigating to it) with:

selectBlocks(blockIds)

Maybe the editor is setup so that it scrolls to the selected block?