I created an Article component which gets its title through the route parameters like this:
const Article = () => {
const params = useParams()
const dashedTitle = params.title.replace(/ /g, '-')
return (
<article>
<MyMDX />
</article>
);
}
I want to return a MDX file with the same name as the provided title. Simply returning the <MyMDX />
component works fine if I manually import it at the top of the article with import MyMDX from '../markdowns/mymdx.mdx
. However, I don't see a way to import this file dynamically, depending on the tile.
Is there a way to do this or could I do this in a better way?