feat: resolve mdx imports relative to components dir

This commit is contained in:
Timothy Lin
2021-07-04 12:36:26 +08:00
parent e701b6a52a
commit 5af6209e5a
2 changed files with 28 additions and 0 deletions

View File

@ -69,6 +69,8 @@ export async function getFileBySlug(type, slug) {
}
const { code } = await bundleMDX(source, {
// mdx imports can be automatically source from the components directory
cwd: path.join(process.cwd(), 'components'),
xdmOptions(options) {
// this is the recommended way to add custom remark/rehype plugins:
// The syntax might look weird, but it protects you in case we add/remove
@ -100,6 +102,13 @@ export async function getFileBySlug(type, slug) {
]
return options
},
esbuildOptions: (options) => {
options.loader = {
...options.loader,
'.js': 'jsx',
}
return options
},
})
return {