A roam/render component that automatically generates a table of contents for the current page.
When clicking a heading, it scrolls to the location of the block instead of focusing on the block.
Detailed instructions at RoamStack: Add a table of contents to your pages with roam-toc
Usage:
{{[[roam/render]]: ((ref-to-clojure-codeblock))}}
The code is in toc.cljs
I would recommend saving this as a template with #roam/templates
Some current limitations:
- After you have manually collapsed a parent block of a heading, jumping to that hidden heading will no longer work. You will have to navigate away from the page and back.
{{word-count}} showing as -1? Here's a workaround
-
Create a dedicated block for the {{word-count}} nested under the heading
-
Create a block ref in the heading, pointed to the word count block.