Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Clarify that merely changing extension does not load .md f… #49785

Merged
merged 6 commits into from
Jun 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/next-mdx/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = withMDX({
})
```

Optionally you can match other file extensions for MDX compilation, by default only `.mdx` is supported
Optionally you can match other file extensions for MDX compilation, as by default only `.mdx` is supported:
joostdecock marked this conversation as resolved.
Show resolved Hide resolved

```js
// next.config.js
Expand All @@ -61,6 +61,21 @@ const withMDX = require('@next/mdx')({
module.exports = withMDX()
```

The configuration above will load both `.md` and `.mdx` files. However, please note that even with this configuration in place, MDX will load `.md` files as Markdown (not as MDX) because by default it will auto-detect the type.
If you want to load `.md` files as MDX content, you should in addition configure [the `format` option](https://mdxjs.com/packages/mdx/#optionsformat) and set it to `mdx`:

```js
// next.config.js
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)$/,
options: {
format: 'mdx'
}
})
module.exports = withMDX()
```
joostdecock marked this conversation as resolved.
Show resolved Hide resolved


## Top level .mdx pages

Define the `pageExtensions` option to have Next.js handle `.md` and `.mdx` files in the `pages` directory as pages:
Expand Down