Replies: 2 comments 13 replies
-
a) you likely don’t need to follow that guide. That guide is for when you want to do yourself what Next already does for you. Use next/mdx. |
Beta Was this translation helpful? Give feedback.
-
I modified the below code and working fine. But the whole reason I wanted to do the provider or injection approach so I do not have to Pass the components manually. import { Fragment } from 'react';
import { compile, run } from '@mdx-js/mdx';
import * as runtime from 'react/jsx-runtime';
import Button from '@/components/button';
async function getContent() {
const code = String(
await compile(
`
Hello World !
<Button />
`,
{
outputFormat: 'function-body',
development: false,
},
),
);
const mdxModule = await run(code, {
...runtime,
baseUrl: import.meta.url,
Fragment: Fragment,
});
return {
MDXContent: mdxModule.default,
};
}
export default async function PrivacyNextPage() {
const { MDXContent } = await getContent();
return (
<article className='prose mx-auto'>
<MDXContent
components={{
Button,
}}
/>
</article>
);
} |
Beta Was this translation helpful? Give feedback.
-
I am trying to inject the Provider component in Next.js 14 using this example https://mdxjs.com/guides/injecting-components/
Also I have tried removing the
import.meta.resolve
keyword it still does not works.Beta Was this translation helpful? Give feedback.
All reactions