0.0.1 • Published 11 months ago

@cicara/toc v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@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);
});
0.0.1

11 months ago