Skip to content

Commit a5d5cf0

Browse files
committed
fix: PlatformTabs
Change-Id: I5452a1ea0a0366cb77e975053aa48d619f847e89
1 parent 28cfdb6 commit a5d5cf0

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

rspress.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export default defineConfig({
224224
},
225225
llms: {
226226
remarkSplitMdxOptions: {
227-
includes: [[['Go', 'LegacyCompatTable', 'APITable'], '@lynx']],
227+
includes: [
228+
[['Go', 'LegacyCompatTable', 'APITable', 'PlatformTabs'], '@lynx'],
229+
],
228230
},
229231
},
230232
});

src/components/platform-tabs/PlatformTabs.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ interface PlatformTabProps {
108108
* ```
109109
*/
110110
const PlatformTab = ({ platform, children }: PlatformTabProps) => {
111+
if (process.env.__SSR_MD__) {
112+
return (
113+
<>
114+
<>{`\n**${platform} specific content start**\n`}</>
115+
{children}
116+
<>{`\n**${platform} specific content end**\n`}</>
117+
</>
118+
);
119+
}
111120
return <div data-platform={platform}>{children}</div>;
112121
};
113122

@@ -178,6 +187,9 @@ export const PlatformTabs = ({
178187
className,
179188
queryKey,
180189
}: PlatformTabsProps) => {
190+
if (process.env.__SSR_MD__) {
191+
return <>{children}</>;
192+
}
181193
// Get available platforms from children
182194
const availablePlatforms = React.Children.toArray(children).reduce<
183195
Platform[]

theme/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Layout as BaseLayout,
1111
getCustomMDXComponent,
1212
Link as BaseLink,
13+
Tabs as BaseTabs,
1314
} from '@rspress/core/theme';
1415
import type { SearchProps } from '@rspress/plugin-algolia/runtime';
1516
import {
@@ -232,8 +233,6 @@ const Search = (props?: Partial<SearchProps> | undefined) => {
232233
);
233234
};
234235

235-
export { HomeLayout, Layout, Search };
236-
237236
const Link = (props: React.ComponentProps<typeof BaseLink>) => {
238237
const { href, children, className, ...restProps } = props;
239238
const getLangPrefix = (lang: string) => (lang === 'en' ? '' : `/${lang}`);
@@ -255,6 +254,14 @@ const Link = (props: React.ComponentProps<typeof BaseLink>) => {
255254
);
256255
};
257256

258-
export { Link }; // override Link from @rspress/core/theme
257+
/* FIXME: overrides builtin Tabs for avoid "window is not defined" warning inner Tabs component, remove this line in the future when upgrading Rspress */
258+
const Tabs = (props: any) => {
259+
if (process.env.__SSR_MD__) {
260+
return <>{props.children}</>;
261+
}
262+
263+
return <BaseTabs {...props} />;
264+
};
259265

266+
export { HomeLayout, Layout, Search, Link, Tabs };
260267
export * from '@rspress/core/theme';

0 commit comments

Comments
 (0)