@jsdevtools/rehype-toc
Version:
A rehype plugin that adds a table of contents (TOC) to the page
46 lines (45 loc) • 1 kB
TypeScript
import { Node } from "unist";
/**
* The `tagName` property of HTML heading nodes
*/
export declare type HeadingTagName = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
/**
* An HTML element node
*/
export interface HtmlElementNode extends Node {
type: "element";
tagName: string;
properties: {
[prop: string]: string | undefined;
};
children?: Node[];
}
/**
* Simple node that is turns into a text literal
*/
export interface TextNode extends Node {
type: "text";
value: string;
}
/**
* An HTML heading node (i.e. <h1>, <h2>, etc.)
*/
export interface HeadingNode extends HtmlElementNode {
tagName: HeadingTagName;
}
/**
* An HTML list node (i.e. <ol> or <ul>)
*/
export interface ListNode extends HtmlElementNode {
type: "element";
tagName: "ol" | "ul";
children: ListItemNode[];
}
/**
* An HTML list item node (i.e. <li>)
*/
export interface ListItemNode extends HtmlElementNode {
type: "element";
tagName: "li";
children: Node[];
}