MDX Processor API
processMDX Function
interface MDXProcessorOptions {
filepath: string
content?: string
components?: Record<string, string>
layout?: string
compileOptions?: Partial<CompileOptions>
watch?: {
enabled?: boolean
ignore?: string[]
}
}
interface ProcessedMDX {
code: string
frontmatter: Record<string, unknown>
metadata: Record<string, unknown>
}
async function processMDX(options: MDXProcessorOptions): Promise<ProcessedMDX>
Usage Examples
// Basic usage
const result = await processMDX({
filepath: 'content/page.mdx'
})
// With watch mode
const result = await processMDX({
filepath: 'content/page.mdx',
watch: {
enabled: true
}
})
// With custom components
const result = await processMDX({
filepath: 'content/page.mdx',
components: {
Button: 'https://ui.example.com/button'
}
})
See MDX Processing Features for more examples.