diff --git a/cli/index.ts b/cli/index.ts index a82387e7..9ca87dc5 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -67,7 +67,7 @@ yargs console.log(e.stack); } }, - ) +) .command( 'bundle [spec]', 'bundle spec into zero-dependency HTML-file', @@ -112,7 +112,7 @@ yargs console.log(e.message); } }, - ) +) .demandCommand() .options('t', { alias: 'template', @@ -217,22 +217,22 @@ async function getPageHTML( const template = compile(readFileSync(templateFileName).toString()); return template({ redocHTML: ` +
${(ssr && html) || ''}
-
${(ssr && html) || ''}
`, + ${(ssr && `const __redoc_state = ${JSON.stringify(state)};`) || ''} + + var container = document.getElementById('redoc'); + Redoc.${ + ssr + ? 'hydrate(__redoc_state, container);' + : `init("spec.json", ${JSON.stringify(redocOptions)}, container)` + }; + + `, redocHead: ssr ? (cdn - ? '' - : ``) + css + ? '' + : ``) + css : '', title: title, });