mdx-components not available when using next mdx remote
Unanswered
Argentine ant posted this in #help-forum
Argentine antOP
Trying to split a larger MDX file into smaller components using next MDX remote
Running into an issue where the mdx-components I have in mdx-components.tsx don't seem to be available to the JSX rendered by MDXRemote. Is there a workaround for this?
import fs from "fs"
import path from "path"
import { MDXRemote } from "next-mdx-remote/rsc"
export default function MdxSection({ slug, section }: { slug: string, section: number }) {
const content = fs.readFileSync(
path.join(
process.cwd(),
"*redacted*/learn/[...slug]",
`${slug}.mdx`
),
"utf8"
)
const contentArray = content.split("<br />")
return <MDXRemote source={contentArray[section]} />
} Running into an issue where the mdx-components I have in mdx-components.tsx don't seem to be available to the JSX rendered by MDXRemote. Is there a workaround for this?
1 Reply
hey, i have the same problem. Did you find any solution for this situation?