You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In principle, this API works for any site built with React; see [react-render-to-markdown](https://www.npmjs.com/package/react-render-to-markdown) if you're interested.
110
110
111
-
2. Provides `import.meta.env.SSG_MD` environment variable, making it easy for users to distinguish between SSG-MD rendering and browser rendering in React components, thus achieving more flexible content customization:
111
+
2. Rspress uses a custom remark plugin `remarkSplitMdx` to preprocess MDX files before rendering. This plugin splits the MDX AST, separating pure Markdown content from JSX components: Markdown text is serialized as string literals, while JSX components and MDX expressions (e.g., `{variable}`) are preserved as React elements. This ensures that Markdown content passes through as-is without being processed by React rendering, while dynamic components are rendered by `renderToMarkdownString`.
112
+
113
+
For example, the following MDX:
114
+
115
+
```mdx
116
+
# Hello
117
+
118
+
Some **bold** text.
119
+
120
+
<PackageManagerTabscommand="install rspress" />
121
+
122
+
{window.title}
123
+
```
124
+
125
+
Will be transformed to a component like:
126
+
127
+
```tsx
128
+
function _createMdxContent() {
129
+
return (
130
+
<>
131
+
{'# Hello\n\nSome **bold** text.\n'}
132
+
<PackageManagerTabscommand="install rspress" />
133
+
{window.title}
134
+
</>
135
+
);
136
+
}
137
+
```
138
+
139
+
3. Provides `import.meta.env.SSG_MD` environment variable, making it easy for users to distinguish between SSG-MD rendering and browser rendering in React components, thus achieving more flexible content customization:
3. Rspress internal component library has been adapted for SSG-MD to ensure reasonable Markdown content is rendered during the SSG-MD phase. For example:
150
+
4. Rspress internal component library has been adapted for SSG-MD to ensure reasonable Markdown content is rendered during the SSG-MD phase. For example:
0 commit comments