@cicara/toc
v0.0.1
Published
help generate a table of contents for articles
Downloads
11
Readme
@cicara/toc
Help generate a table of contents for articles.
pnpm add @cicara/toc
import { TOC } from "@cicara/toc";
const toc = new TOC({
selector: "h2, h3",
container: document.querySelector<HTMLDivElement>("#article")!,
});
const elements = toc.getElements();
// emit when a section is active
toc.addEventListener("toc:active", (event) => {
console.log(event.detail.element);
});