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