Related, when I got to Adding React Components to MDC Files, I was unable to load the Shoutout component from within the markdown file. To resolve:
- Go to
posts.js
and add:
import { MDXProvider } from "@mdx-js/react"
import Shoutout from "../components/shoutout"
const shortcodes = {
Shoutout
}
- And where you import the content, adjust to:
<MDXProvider components={shortcodes}>
<MDXRenderer>{content}</MDXRenderer>
</MDXProvider>
- Now in your markdown file, you can use
<Shoutout>
tags without importing.
I hope this helps others.
-
This reply was modified 5 years, 3 months ago by
Alex Fornuto. Reason: Adjust formatting