MDX to markdown is the same as JSX to JS. To quote the original site,
MDX is an authorable format that lets you seamlessly write JSX in your Markdown documents. You can import components, such as interactive charts or alerts, and embed them within your content. This makes writing long-form content with components a blast 🚀.
... and this one:
Writing is fun again when you combine components, that can even be dynamic or load data, with the simplicity of Markdown for long-form content.
Basically, renaming your
.md file to
.mdx gives you ability to import and use React components as if it was a normal React or Next.js app.
Here is a small demo video for curious:
Say we have a basic React counter component like this:
If you need to use components in your markdown content files, use
.mdx extension, and provide any custom components through the
components/component-mapper.jsx file. Then include it in your
.mdx file and display it just like in React application:
You clicked 0 times!
Voila! This way you can create dynamic components for your documentation like never before. Live code editors, quizes, exams, cheatsheets, comments, you name it. Possibilities are endless. Notice that you can use tailwindcss classnames in components for styling.
For more information what can be achieved with MDX, see the official site.