mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-25 01:53:44 +03:00
fix(cli): allow to set url to the spec in SSR mode
This commit is contained in:
parent
b11679604a
commit
c9c6bc5255
10
cli/index.ts
10
cli/index.ts
|
@ -21,7 +21,7 @@ type Options = {
|
|||
output?: string;
|
||||
title?: string;
|
||||
templateFileName?: string;
|
||||
redocOptions?: object;
|
||||
redocOptions?: any;
|
||||
};
|
||||
|
||||
const BUNDLES_DIR = dirname(require.resolve('redoc'));
|
||||
|
@ -200,7 +200,9 @@ async function getPageHTML(
|
|||
let redocStandaloneSrc;
|
||||
if (ssr) {
|
||||
console.log('Prerendering docs');
|
||||
const store = await createStore(spec, pathToSpec, redocOptions);
|
||||
|
||||
const specUrl = redocOptions.specUrl || (isURL(pathToSpec) ? pathToSpec : undefined);
|
||||
const store = await createStore(spec, specUrl, redocOptions);
|
||||
const sheet = new ServerStyleSheet();
|
||||
html = renderToString(sheet.collectStyles(React.createElement(Redoc, { store })));
|
||||
css = sheet.getStyleTags();
|
||||
|
@ -282,3 +284,7 @@ function debounce(callback: Function, time: number) {
|
|||
}, time);
|
||||
};
|
||||
}
|
||||
|
||||
function isURL(str: string): boolean {
|
||||
return /^(https?:)\/\//m.test(str);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user