In MDX, all .mdx
files are compiled into React components, which means they can be used as React components and can freely use React components. For example:
It will be rendered as:
Testing the use of MDX fragments and React components.
This is mdx fragment.
This is a component from tsx
You can use built-in components provided by Rspress or install some React component libraries to enrich your documentation in .mdx
files.
In the docs directory, MDX fragments or React components need to be excluded from routing through the route.exclude configuration. For convenience, we agree that files starting with "_" will be excluded by default.
You can also place components in adjacent directories outside the docs directory, for example:
It will be rendered as:
This is some text
It will be rendered as:
This is content in tsx, but you can use code block
styles.
.tsx
components can make it difficult to extract some static information, such as local search indexes.
It is more recommended to use .mdx
files to write document content and use .tsx
files to write interactive dynamic content.