@next/mdx 15.4.6 → 15.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +16 -1
- package/mdx-js-loader.js +14 -7
- package/package.json +1 -1
- package/readme.md +6 -7
package/index.d.ts
CHANGED
|
@@ -21,7 +21,22 @@ declare namespace nextMDX {
|
|
|
21
21
|
*
|
|
22
22
|
* @see https://mdxjs.com/packages/mdx/#api
|
|
23
23
|
*/
|
|
24
|
-
options?: Options
|
|
24
|
+
options?: Options & {
|
|
25
|
+
remarkPlugins?:
|
|
26
|
+
| (
|
|
27
|
+
| string
|
|
28
|
+
| [name: string, options: any]
|
|
29
|
+
| NonNullable<Options['remarkPlugins']>[number]
|
|
30
|
+
)[]
|
|
31
|
+
| Options['remarkPlugins']
|
|
32
|
+
rehypePlugins?:
|
|
33
|
+
| (
|
|
34
|
+
| string
|
|
35
|
+
| [name: string, options: any]
|
|
36
|
+
| NonNullable<Options['rehypePlugins']>[number]
|
|
37
|
+
)[]
|
|
38
|
+
| Options['rehypePlugins']
|
|
39
|
+
}
|
|
25
40
|
}
|
|
26
41
|
}
|
|
27
42
|
|
package/mdx-js-loader.js
CHANGED
|
@@ -5,15 +5,22 @@ function interopDefault(mod) {
|
|
|
5
5
|
return mod.default || mod
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
async function importPluginForPath(pluginPath, projectRoot) {
|
|
9
|
+
const path = require.resolve(pluginPath, { paths: [projectRoot] })
|
|
10
|
+
return interopDefault(
|
|
11
|
+
// "use pathToFileUrl to make esm import()s work with absolute windows paths":
|
|
12
|
+
// on windows import("C:\\path\\to\\file") is not valid, so we need to use file:// URLs
|
|
13
|
+
// https://github.com/vercel/next.js/commit/fbf9e12de095e0237d4ba4aa6139d9757bd20be9
|
|
14
|
+
await import(process.platform === 'win32' ? pathToFileURL(path) : path)
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
async function importPlugin(plugin, projectRoot) {
|
|
9
19
|
if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// https://github.com/vercel/next.js/commit/fbf9e12de095e0237d4ba4aa6139d9757bd20be9
|
|
15
|
-
await import(process.platform === 'win32' ? pathToFileURL(path) : path)
|
|
16
|
-
)
|
|
20
|
+
plugin[0] = await importPluginForPath(plugin[0], projectRoot)
|
|
21
|
+
}
|
|
22
|
+
if (typeof plugin === 'string') {
|
|
23
|
+
plugin = await importPluginForPath(plugin, projectRoot)
|
|
17
24
|
}
|
|
18
25
|
return plugin
|
|
19
26
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -105,14 +105,13 @@ yarn add @next/mdx
|
|
|
105
105
|
Create an `mdx-components.js` file at the root of your project with the following contents:
|
|
106
106
|
|
|
107
107
|
```js
|
|
108
|
-
//
|
|
109
|
-
|
|
108
|
+
// Allows customizing built-in components, e.g. to add styling.
|
|
109
|
+
const components = {
|
|
110
|
+
// h1: ({ children }) => <h1 style={{ fontSize: "100px" }}>{children}</h1>,
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function useMDXComponents() {
|
|
110
114
|
return components
|
|
111
|
-
// Allows customizing built-in components, e.g. to add styling.
|
|
112
|
-
// return {
|
|
113
|
-
// h1: ({ children }) => <h1 style={{ fontSize: "100px" }}>{children}</h1>,
|
|
114
|
-
// ...components,
|
|
115
|
-
// }
|
|
116
115
|
}
|
|
117
116
|
```
|
|
118
117
|
|