OldDew
OldDew
TTCTheo's Typesafe Cult
Created by BillGun on 2/5/2024 in #questions
next-mdx-remote plugins not working properly
Hello, did you find a solution? I am having a similar problem. The way I'm doing it is by getting the markdown file content (literally reading from file):
export const getPostBySlug = (slug: string) => {
const realSlug = slug.replace(/\.mdx$/, '')
const filePath = path.join(rootDirectory, `${realSlug}.mdx`)

const fileContent = fs.readFileSync(filePath, { encoding: 'utf8' })
return fileContent
}
export const getPostBySlug = (slug: string) => {
const realSlug = slug.replace(/\.mdx$/, '')
const filePath = path.join(rootDirectory, `${realSlug}.mdx`)

const fileContent = fs.readFileSync(filePath, { encoding: 'utf8' })
return fileContent
}
Afterwards I try adding the source for the MDXRemote like this:
const Page = async ({ params } : any) => {
const post = getPostBySlug(params.slug)

return (
<section className='py-24'>
<div className='container py-4 prose'>
<MDXRemote source={post} />
</div>
</section>
)
}
const Page = async ({ params } : any) => {
const post = getPostBySlug(params.slug)

return (
<section className='py-24'>
<div className='container py-4 prose'>
<MDXRemote source={post} />
</div>
</section>
)
}
All works except plugins.
3 replies