fumadocs-core
Version:
The React.js library for building a documentation website
52 lines • 1.99 kB
TypeScript
import { c as TOCItemType } from "./toc-BuHOTlzj.js";
import * as Hast from "hast";
import { Transformer } from "unified";
import { Heading, Root as Root$1 } from "mdast";
interface RemarkHeadingOptions {
/**
* slug the IDs of headings, the IDs slugged when rendering come from `slugImportSource`. Custom IDs are slugged too,
* so a slugger can count them as duplicates.
*/
slug?: (root: Root$1, heading: Heading, text: string) => string;
/**
* The module that slugs IDs when rendering, compiled pages import `createHeadingIds()` from it like the JSX runtime
* from `jsxImportSource`. It replaces `fumadocs-core/mdx-plugins/remark-heading.runtime`, which it can call with
* its own slugger.
*
* @defaultValue the runtime of Fumadocs, or with a custom `slug`, none: IDs are slugged from the source
*/
slugImportSource?: string;
/**
* Allow custom headings ids
*
* @defaultValue true
*/
customId?: boolean;
/**
* Attach an array of `TOCItemType` to `file.data.toc`
*
* @defaultValue true
*/
generateToc?: boolean;
}
declare module 'vfile' {
interface DataMap {
/**
* [Fumadocs: remark-heading] output data.
*/
toc?: TOCItemType[];
}
}
/**
* Add heading ids and extract TOC.
*
* For a content source that renders pages for props, the IDs of headings with authored expressions or in branches of
* `<show>` are slugged when rendering: {@link rehypeHeading} gives them to the headings.
*/
declare function remarkHeading({ slug, slugImportSource, customId, generateToc }?: RemarkHeadingOptions): Transformer<Root$1, Root$1>;
/**
* Give headings their IDs from code, the IDs that {@link remarkHeading} computes for a content source that renders
* pages for props. It runs after the plugins that read headings: a heading with an ID from code is JSX.
*/
declare function rehypeHeading(): Transformer<Hast.Root, Hast.Root>;
export { rehypeHeading as n, remarkHeading as r, RemarkHeadingOptions as t };