Implementing mdit-plugins to @next/mdx im lost
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
Hello people,
at the moment I'm trying to implement mdit-plugins into my NextJS Application. (https://mdit-plugins.github.io/)
I have only basic md experience but none with implementing this plugin.
First I have the following files:
next.config.mjs
and mdx-components.tsx
music.tsx
and my music.mdx file:
I tried with the help of chatGPT to guide myself into the right direction but that didn't work out. On the internet there is also no tutorial or help of any way how to solve this issue, maybe someone around here has any idea on how to get it to work with mdit-plugins from Github. I would like to extend my mdx commands by a few new components and therefore I'm trying to get it to work.
Has anyone an idea on how to solve this? Did I provide all necessary information?
at the moment I'm trying to implement mdit-plugins into my NextJS Application. (https://mdit-plugins.github.io/)
I have only basic md experience but none with implementing this plugin.
First I have the following files:
next.config.mjs
/** @type {import('next').NextConfig} */
import createMDX from "@next/mdx";
const nextConfig = {
eslint: {
ignoreDuringBuilds: true
},
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
use: ["@svgr/webpack"],
});
return config;
},
experimental: {
turbo: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js'
}
},
}
},
};
const withMDX = createMDX({
// Add markdown plugins here, as desired
})
export default withMDX(nextConfig);
and mdx-components.tsx
import type { MDXComponents } from 'mdx/types'
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...components,
}
}
music.tsx
import Music from "../../mdx/articles/music.mdx";
export default async function MusicPage() {
return (
<Music/>
and my music.mdx file:
# Title
[!warning]
This is my custom warning text
I tried with the help of chatGPT to guide myself into the right direction but that didn't work out. On the internet there is also no tutorial or help of any way how to solve this issue, maybe someone around here has any idea on how to get it to work with mdit-plugins from Github. I would like to extend my mdx commands by a few new components and therefore I'm trying to get it to work.
Has anyone an idea on how to solve this? Did I provide all necessary information?
1 Reply
Polar bearOP
This is my package.json
"dependencies": {
"@upstash/redis": "^1.34.3",
"@vercel/speed-insights": "^1.0.14",
"gray-matter": "^4.0.3",
"next": "^15.0.2",
"primereact": "^10.8.4",
"react": "^19.0.0-rc-b8ae38f8-20241018",
"react-dom": "^19.0.0-rc-b8ae38f8-20241018"
},
"devDependencies": {
"@mdit/plugin-alert": "^0.13.1",
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
"@next/mdx": "^15.0.2",
"@svgr/webpack": "^8.1.0",
"@tailwindcss/typography": "^0.5.15",
"@types/mdx": "^2.0.13",
"@types/node": "^22",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^9",
"eslint-config-next": "15.0.2",
"markdown-it": "^14.1.0",
"postcss": "^8",
"tailwindcss": "^3.4.14",
"turbo": "^2.2.3",
"typescript": "^5"
}