MDXProvider
isn't taken into account
#2467
Answered
by
wooorm
openscript
asked this question in
Q&A
-
Dear mdx-js community I'm rendering .mdx files successfully with: import { RunOptions, runSync } from "@mdx-js/mdx";
import { MDXProvider } from "@mdx-js/react";
import { Title } from "@timelet/ui";
import * as jsxRuntime from "react/jsx-runtime";
type PageProps = {
markdown: string;
};
export function Page({ markdown }: PageProps) {
const Content = runSync(markdown, { ...(jsxRuntime as RunOptions) }).default;
return (
<section>
<MDXProvider components={{ h1: Title }}>
<Content />
</MDXProvider>
</section>
);
} How to make export function Page({ markdown }: PageProps) {
const Content = runSync(markdown, { ...(jsxRuntime as RunOptions) }).default;
return (
<section>
<Content components={{ h1: Title }} />
</section>
);
} Any hints are highly appreciated :) |
Beta Was this translation helpful? Give feedback.
Answered by
wooorm
Apr 7, 2024
Replies: 1 comment 1 reply
-
You need to compile the MDX so that it knows about your provider. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
openscript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to compile the MDX so that it knows about your provider.
There's an option for that.
But, you probably don't need providers, see their readme's warning signs. You can pass components fine without them!