mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? This fixes a couple of things: - Although it’s rare for MDX plugins to accept more than 1 option, they may accept any number of arguments. - In addition to `remarkPlugins` and `rehypePlugins`, now `recmaPlugins` is also patched to accept strings - TypeScript property Descriptions are preserved for patched values. ### Why? Because it is broken. ### How? Fixes #77297
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import type { NextConfig } from 'next'
|
|
import type { Options } from '@mdx-js/loader'
|
|
import type { RuleSetConditionAbsolute } from 'webpack'
|
|
|
|
type WithMDX = (config: NextConfig) => NextConfig
|
|
|
|
type PluggableListName = 'remarkPlugins' | 'rehypePlugins' | 'recmaPlugins'
|
|
|
|
declare namespace nextMDX {
|
|
interface NextMDXOptions {
|
|
/**
|
|
* A webpack rule test to match files to treat as MDX.
|
|
*
|
|
* @default /\.mdx$/
|
|
* @example
|
|
* // Support both .md and .mdx files.
|
|
* /\.mdx?$/
|
|
*/
|
|
extension?: RuleSetConditionAbsolute
|
|
|
|
/**
|
|
* The options to pass to MDX.
|
|
*
|
|
* @see https://mdxjs.com/packages/mdx/#api
|
|
*/
|
|
options?: {
|
|
[Key in keyof Options]: Key extends PluggableListName
|
|
?
|
|
| (
|
|
| string
|
|
| [name: string, ...options: any[]]
|
|
| NonNullable<Options[Key]>[number]
|
|
)[]
|
|
| Options[Key]
|
|
: Options[Key]
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Use [MDX](https://github.com/mdx-js/mdx) with [Next.js](https://github.com/vercel/next.js)
|
|
*/
|
|
declare function nextMDX(options?: nextMDX.NextMDXOptions): WithMDX
|
|
|
|
export = nextMDX
|