import { Nodes, Root } from 'mdast'; import { Transformer, PluggableList } from 'unified'; import { MdxJsxFlowElement, MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx'; interface Heading { id: string; content: string; } interface Content { heading: string | undefined; content: string; } interface StructuredData { headings: Heading[]; /** * Refer to paragraphs, a heading may contain multiple contents as well */ contents: Content[]; } interface StructureOptions { /** * Types to be scanned as content. * * @defaultValue ['heading', 'paragraph', 'blockquote', 'tableCell', 'mdxJsxFlowElement'] */ types?: string[] | ((node: Nodes) => boolean); /** * A list of indexable MDX attributes, either: * * - an array of attribute names. * - a function that determines if attribute should be indexed. */ allowedMdxAttributes?: string[] | ((node: MdxJsxFlowElement, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute) => boolean); /** * export as `structuredData` or specified variable name. */ exportAs?: string | boolean; } declare module 'mdast' { interface Data { /** * [Fumadocs] Get content of unserializable element, `remarkStructure` uses it to generate search index. */ _string?: string[]; } } declare module 'vfile' { interface DataMap { /** * [Fumadocs] injected by `remarkStructure` */ structuredData: StructuredData; } } declare const remarkStructureDefaultOptions: { types: string[]; allowedMdxAttributes: (node: MdxJsxFlowElement) => boolean; exportAs: false; }; /** * Extract content into structured data. * * By default, the output is stored into VFile (`vfile.data.structuredData`), you can specify `exportAs` to export it. */ declare function remarkStructure({ types, allowedMdxAttributes, exportAs, }?: StructureOptions): Transformer; /** * Extract data from markdown/mdx content */ declare function structure(content: string, remarkPlugins?: PluggableList, options?: StructureOptions): StructuredData; export { type StructureOptions, type StructuredData, remarkStructure, remarkStructureDefaultOptions, structure };