@fumadocs/mdx-remote
Version:
The remote MDX files adapter for Fumadocs
92 lines (91 loc) • 3.2 kB
TypeScript
import { t as MdxContent } from "./render-CHFQWkSB.js";
import * as Plugins from "fumadocs-core/mdx-plugins";
import { CompileOptions } from "@mdx-js/mdx";
import { MDXComponents } from "mdx/types";
import { TableOfContents } from "fumadocs-core/toc";
import { Pluggable } from "unified";
import { Compatible, VFile } from "vfile";
//#region src/utils.d.ts
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
/**
* Parse frontmatter, currently powered by `gray-matter`
*/
declare function parseFrontmatter(content: string): {
frontmatter: {
[key: string]: any;
};
content: string;
};
//#endregion
//#region src/compile.d.ts
type FumadocsPresetOptions = Omit<CompileOptions, 'remarkPlugins' | 'rehypePlugins'> & {
preset?: 'fumadocs';
remarkPlugins?: ResolvePlugins;
rehypePlugins?: ResolvePlugins;
remarkHeadingOptions?: Plugins.RemarkHeadingOptions | false;
rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;
rehypeTocOptions?: Plugins.RehypeTocOptions | false;
remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;
remarkNpmOptions?: Plugins.RemarkNpmOptions | false;
/**
* The directory to find image sizes
*
* @defaultValue './public'
* @deprecated Use `remarkImageOptions.publicDir` instead
*/
imageDir?: string;
remarkImageOptions?: Plugins.RemarkImageOptions | false;
};
type CompilerOptions = (CompileOptions & {
preset: 'minimal';
}) | FumadocsPresetOptions;
interface CompileMDXOptions {
source: string;
/**
* File path of source content
*/
filePath?: string;
components?: MDXComponents;
scope?: Record<string, unknown>;
/**
* @deprecated Use `compiler.compileFile` instead if you doesn't need to execute output JavaScript code.
*/
skipRender?: boolean;
}
interface CompileMDXResult<TFrontmatter = Record<string, unknown>> {
body: MdxContent;
frontmatter: TFrontmatter;
toc: TableOfContents;
vfile: VFile;
compiled: string;
exports: Record<string, unknown> | null;
}
declare function createCompiler(mdxOptions?: CompilerOptions): {
render(compiled: string, scope?: Record<string, unknown>, filePath?: string): Promise<{
default: MdxContent;
toc?: TableOfContents;
}>;
/**
* Compile VFile
*/
compileFile(from: Compatible): Promise<VFile>;
compile<Frontmatter extends object = Record<string, unknown>>(options: CompileMDXOptions): Promise<CompileMDXResult<Frontmatter>>;
};
/**
* @deprecated Use `createCompiler()` API instead, this function will always create a new compiler instance.
*/
declare function compileMDX<Frontmatter extends object = Record<string, unknown>>(options: CompileMDXOptions & {
mdxOptions?: CompilerOptions;
}): Promise<CompileMDXResult<Frontmatter>>;
//#endregion
//#region src/index.d.ts
/**
* @deprecated Use `compiler.render` instead
*/
declare function executeMdx(compiled: string, scope: object, baseUrl?: string | URL): Promise<{
default: MdxContent;
toc?: TableOfContents;
}>;
//#endregion
export { CompileMDXOptions, CompileMDXResult, CompilerOptions, type CompilerOptions as MDXOptions, FumadocsPresetOptions, compileMDX, createCompiler, executeMdx, parseFrontmatter };
//# sourceMappingURL=index.d.ts.map