You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@hu-tu-yi-shi Generally we don't import & use the components that way. We use useMDXComponent hook to process the .mdx files and use custom components.
Example
// https://www.contentlayer.dev/docs/sources/files/mdx#usage-from-nextjsimportReactfrom'react'import{allPosts,typePost}from'contentlayer/generated'import{useMDXComponent}from'next-contentlayer/hooks'exportconstgetStaticProps=()=>{constpost=allPosts[0]return{props: { post }}}constMyButton: React.FC=()=><button>Clickme</button>constPage: React.FC<{post}>=({post})=>{const MDXContent =useMDXComponent(post.body.code)return(<div>{/* Some code ... */}// MyButton is the custom component which can be used in .mdx file<MDXContentcomponents={{ MyButton }}/></div>)}exportdefaultPage
sorry my english is not good
issue info
my issue like this #266
i want to import the
C1
component in theindex.mdx
but it not work
error info
i open the url
http://localhost:3000/posts/a22
, i have see nothingmy code
here is my code https://github.com/hu-tu-yi-shi/tmp-contentlayer-bug
can you help me , thank you very much
The text was updated successfully, but these errors were encountered: