From d9ee2d0d89e88ce721297368782d1caac5f9294b Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 22 Mar 2018 17:49:15 +0200 Subject: [PATCH] fix(cli): don't wait for content loaded in bundled HTML --- cli/index.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) 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, });