MDX
MDX is an extension syntax of Markdown that allows the use of JSX syntax within Markdown. For usage, refer to rspress MDX.
TOC
rspress Components
Most of the built-in components provided by the rspress theme have been adjusted to global components, which can be used directly in .mdx files without import, including:
BadgeCardLinkCardPackageManagerTabsStepsTab/TabsToc
Other less commonly used components can be imported from rspress/theme, for example:
doom Components
doom provides some global components to assist in documentation writing, which can be used directly without import. Currently, these include:
Overview
Document overview component used to display the document directory
Directive
Sometimes, due to nested indentation, the custom container syntax may fail. You can use the Directive component as a replacement.
-
The directory structure of multilingual documents (
doc/en) needs to be exactly the same as the documents under thedoc/zhdirectory to ensure that the links in multilingual documents are identical except for the language identifier.NoteIf you are using automated translation tools, you do not need to worry about this issue. The automated translation tools will automatically generate the target language document directory structure based on
doc/zh.
ExternalSite
Component for referencing external sites
ExternalSiteLink
Component for referencing external site links
In mdx, <ExternalSiteLink name="connectors" href="link" children="Content" /> has a different meaning from the following content:
If you do not want the text to be rendered inside a p element, you can pass it using the children attribute as shown in the example above.
AcpApisOverview and ExternalApisOverview
Components for referencing external site API overviews
Term
Term component, plain text, dynamically mounted and injected
props
name: Built-in term name, refer to dynamic mount configuration filetextCase: Text case transformation, optional values arelower,upper,capitalize
TermsTable
Built-in term list display component
props
terms:NormalizedTermItem[], optional, custom term list for convenient reuse when rendering custom terms in internal documentation
JsonViewer
Custom Component Reuse
According to the convention, we can extract reusable content into the shared directory, then import it where needed, for example:
If you need to use more runtime related APIs, you can implement components with .jsx/.tsx and then import and use them in .mdx files.
Note: Currently, components exported from .mdx do not support passing props. Refer to this issue. Therefore, for scenarios requiring props passing, please develop using .jsx/.tsx components.