0.0.21 • Published 10 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
10 months ago
0.0.20
10 months ago
0.0.18
10 months ago
0.0.17
10 months ago
0.0.15
10 months ago
0.0.14
10 months ago
0.0.13
10 months ago
0.0.12
10 months ago
0.0.11
10 months ago
0.0.10
10 months ago
0.0.9
10 months ago
0.0.8
10 months ago
0.0.7
10 months ago
0.0.6
10 months ago
0.0.5
10 months ago
0.0.4
10 months ago
0.0.3
10 months ago
0.0.2
10 months ago
0.0.1
10 months ago