@@ -25,11 +25,9 @@ get a bundled version of these files to eval in the browser.
2525## This solution
2626
2727This is an async function that will compile and bundle your MDX files and their
28- dependencies. It uses [ esbuild] ( https://esbuild.github.io/ ) , so it's VERY fast
29- and supports TypeScript files (for the dependencies of your MDX files). It also
30- uses [ xdm] ( https://github.com/wooorm/xdm ) which is a more modern and powerful
31- MDX compiler with fewer bugs and more features (and no extra runtime
32- requirements).
28+ dependencies. It uses [ MDX v2] ( https://mdxjs.com/blog/v2/ ) and
29+ [ esbuild] ( https://esbuild.github.io/ ) , so it's VERY fast and supports TypeScript
30+ files (for the dependencies of your MDX files).
3331
3432Your source files could be local, in a remote github repo, in a CMS, or wherever
3533else and it doesn't matter. All ` mdx-bundler ` cares about is that you pass it
@@ -154,17 +152,6 @@ Why not?
154152
155153</details >
156154
157- <details >
158- <summary >
159- <strong>
160- "Why does this use XDM instead of @mdx-js?"
161- </strong>
162- </summary >
163-
164- It has more features, fewer bugs, and no runtime!
165-
166- </details >
167-
168155<details >
169156 <summary >
170157 <strong>
@@ -321,18 +308,18 @@ file source code. You could get these from the filesystem or from a remote
321308database. If your MDX doesn't reference other files (or only imports things from
322309` node_modules ` ), then you can omit this entirely.
323310
324- #### xdmOptions
311+ #### mdxOptions
325312
326- This allows you to modify the built-in xdm configuration (passed to the xdm
327- esbuild plugin ). This can be helpful for specifying your own
313+ This allows you to modify the built-in MDX configuration (passed to
314+ ` @mdx-js/ esbuild` ). This can be helpful for specifying your own
328315remarkPlugins/rehypePlugins.
329316
330- The function is passed the default xdmOptions and the frontmatter.
317+ The function is passed the default mdxOptions and the frontmatter.
331318
332319``` ts
333320bundleMDX ({
334321 source: mdxSource ,
335- xdmOptions (options , frontmatter ) {
322+ mdxOptions (options , frontmatter ) {
336323 // this is the recommended way to add custom remark/rehype plugins:
337324 // The syntax might look weird, but it protects you in case we add/remove
338325 // plugins in the future.
@@ -505,7 +492,7 @@ the directory. If one option is set the other must be aswell.
505492_ The Javascript bundle is not written to this directory and is still returned as
506493a string from ` bundleMDX ` ._
507494
508- This feature is best used with tweaks to ` xdmOptions ` and ` esbuildOptions ` . In
495+ This feature is best used with tweaks to ` mdxOptions ` and ` esbuildOptions ` . In
509496the example below and ` .png ` files are written to the disk and then served from
510497` /file/ ` .
511498
@@ -521,7 +508,7 @@ const {code} = await bundleMDX({
521508 cwd: ' /path/to/site/content' ,
522509 bundleDirectory: ' /path/to/site/public/file,
523510 bundlePath : ' /file/' ,
524- xdmOptions : options => {
511+ mdxOptions : options => {
525512 options .remarkPlugins = [remarkMdxImages ]
526513
527514 return options
@@ -553,7 +540,7 @@ const {code} = await bundleMDX({
553540` bundleMDX ` has a single type parameter which is the type of your frontmatter.
554541It defaults to ` {[key: string]: any} ` and must be an object. This is then used
555542to type the returned ` frontmatter ` and the frontmatter passed to
556- ` esbuildOptions ` and ` xdmOptions ` .
543+ ` esbuildOptions ` and ` mdxOptions ` .
557544
558545``` ts
559546const {frontmatter} = bundleMDX <{title: string }>({source })
@@ -564,7 +551,7 @@ frontmatter.title // has type string
564551### Component Substitution
565552
566553MDX Bundler passes on
567- [ XDM 's ability to substitute components] ( https://github .com/wooorm/xdm#mdx-content )
554+ [ MDX 's ability to substitute components] ( https://mdxjs .com/docs/using-mdx/#components )
568555through the ` components ` prop on the component returned by ` getMDXComponent ` .
569556
570557Here's an example that removes _ p_ tags from around images.
@@ -653,7 +640,7 @@ import {remarkMdxImages} from 'remark-mdx-images'
653640const {code } = await bundleMDX ({
654641 source: mdxSource,
655642 cwd: ' /users/you/site/_content/pages' ,
656- xdmOptions : options => {
643+ mdxOptions : options => {
657644 options .remarkPlugins = [... (options .remarkPlugins ?? []), remarkMdxImages]
658645
659646 return options
@@ -684,7 +671,7 @@ folder to be used in image sources.
684671const {code } = await bundleMDX ({
685672 source: mdxSource,
686673 cwd: ' /users/you/site/_content/pages' ,
687- xdmOptions : options => {
674+ mdxOptions : options => {
688675 options .remarkPlugins = [... (options .remarkPlugins ?? []), remarkMdxImages]
689676
690677 return options
0 commit comments