0.0.21 • Published 7 months ago
@fightclub/ui v0.0.21
documentation
vite support for MDX files
pnpm install @mdx-js/rollup
- Configure Vite: In your vite.config.js or vite.config.ts file,
- need to import and configure the MDX plugin.
//vite.config.ts
import mdx from "@mdx-js/rollup"
export default defineConfig(({mode})=>{
return {
plugins: [react(), mdx()],
//...
}
});
Using MDX files
- Once the plugin is set up, you can import and use .mdx files in your components or pages.
- For example, if you have a page about.mdx, you can import it like this:
import About from './about.mdx';
// Inside your component or page
function App() {
return <About />;
}
Add a TypeScript Declaration for MDX
- You need to add a TypeScript declaration to let TypeScript know how to handle .mdx files.
- Create or modify a global.d.ts or vite-env.d.ts file (in your src directory or root) and add the following declaration:
declare module '*.mdx' {
// You can adjust this to use a more specific type if needed
import { ComponentType } from 'react';
const content: ComponentType;
export default content;
}
- This tells TypeScript that when importing .mdx files, they will be treated as React components (using ComponentType).
0.0.21
7 months ago
0.0.20
7 months ago
0.0.18
7 months ago
0.0.17
7 months ago
0.0.15
7 months ago
0.0.14
7 months ago
0.0.13
7 months ago
0.0.12
7 months ago
0.0.11
7 months ago
0.0.10
7 months ago
0.0.9
7 months ago
0.0.8
7 months ago
0.0.7
7 months ago
0.0.6
7 months ago
0.0.5
7 months ago
0.0.4
7 months ago
0.0.3
7 months ago
0.0.2
7 months ago
0.0.1
7 months ago