@mehm8128/rehype-toc
v1.4.1
Published
rehype plugin to generate a collapsible table of contents
Readme
rehype-toc
rehype plugin to generate a table of contents from headings in your markdown.
You can create the table of contents as follows.

Installation
pnpm add @mehm8128/rehype-tocUsage
astro.config.mjs
import { rehypeCollapsibleToc } from "@mehm8128/rehype-toc";
export default defineConfig({
markdown: {
rehypePlugins: [rehypeCollapsibleToc],
},
});rehype
import { rehype } from "rehype"
import { rehypeCollapsibleToc } from "@mehm8128/rehype-toc";
const input = "<h2 id="heading-id"><a href="#heading-id">Heading</a></h2>";
const { value } = await rehype().use(rehypeCollapsibleToc).process(input);