UNPKG

fumadocs-core

Version:

The React.js library for building a documentation website

43 lines • 2.07 kB
import { ElementType, ReactElement, ReactNode } from "react"; /** what a tree renders into Markdown for */ export type MarkdownTarget = 'markdown' | 'search'; /** * The target that the current component is being rendered into Markdown for, calling it opts the component in. */ export declare function asMarkdown(): MarkdownTarget | false; /** * Render a React tree into a Markdown document. */ export declare function renderToMarkdown(node: ReactNode, { target }?: { target?: MarkdownTarget; }): Promise<string>; /** * Render a page element into Markdown, `undefined` when its component doesn't call `asMarkdown()`. */ export declare function renderRoute(element: ReactElement): Promise<string | undefined>; /** * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`): * a missing component is serialized as JSX syntax by `renderToMarkdown`. */ export declare function jsxComponents(components: Record<string, ElementType> | undefined): Record<string, ElementType>; export type MarkdownTag = (strings: TemplateStringsArray, ...values: ReactNode[]) => Promise<string>; /** * Tagged template for Markdown, interpolated values can be strings, React nodes, promises, or arrays of them. * * Use `md\`${children}\`` inside a component to stringify its children before manipulating them, the result is not * trimmed so block-level output keeps its trailing blank line. * * Formatters (Prettier, oxfmt) format `md` templates as Markdown and may move the content onto its own indented lines, * so a leading empty line, the indentation before the closing backtick and the common indentation are removed. */ export declare const md: MarkdownTag & { /** * Like `md`, but trims the result, prefixes every line (empty lines receive the trimmed prefix, e.g. `>` instead of * `> `) and returns it as a block. */ linePrefix: (prefix: string) => MarkdownTag; /** * Like `md`, but trims the result, indents every non-empty line and returns it as a block. */ indent: (size?: number) => MarkdownTag; };