-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathRedoc.tsx
More file actions
50 lines (43 loc) · 1.27 KB
/
Redoc.tsx
File metadata and controls
50 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react';
import useSpecData from '@theme/useSpecData';
import clsx from 'clsx';
import '../../global';
import { RedocStandalone } from 'redoc';
import type { RedocProps } from '../../types/common';
import { useSpecOptions } from '../../utils/useSpecOptions';
import './styles.css';
import ServerRedoc from './ServerRedoc';
const isDevMode = process.env.NODE_ENV === 'development';
/*!
* Redocusaurus
* https://redocusaurus.vercel.app/
* (c) 2025 Rohit Gohri
* Released under the MIT License
*/
function Redoc(initProps: RedocProps): React.JSX.Element {
// eslint-disable-next-line react/destructuring-assignment
const specProps = useSpecData(initProps.id, initProps.spec);
const finalProps = {
...specProps,
...initProps,
};
const {
spec,
className,
isSpecFile = spec != null,
url,
themeId,
optionsOverrides,
} = finalProps;
const { options } = useSpecOptions(themeId, optionsOverrides);
const enableServerRendering = spec != null && (!isDevMode || isSpecFile);
if (enableServerRendering) {
return <ServerRedoc {...finalProps} spec={spec} />;
}
return (
<div className={clsx(['redocusaurus', className])}>
<RedocStandalone specUrl={url} options={options} />
</div>
);
}
export default Redoc;