Skip to content

Commit

Permalink
fix(cli): don't wait for content loaded in bundled HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Mar 22, 2018
1 parent d1d8042 commit d9ee2d0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ yargs
console.log(e.stack);
}
},
)
)
.command(
'bundle [spec]',
'bundle spec into zero-dependency HTML-file',
Expand Down Expand Up @@ -112,7 +112,7 @@ yargs
console.log(e.message);
}
},
)
)
.demandCommand()
.options('t', {
alias: 'template',
Expand Down Expand Up @@ -217,22 +217,22 @@ async function getPageHTML(
const template = compile(readFileSync(templateFileName).toString());
return template({
redocHTML: `
<div id="redoc">${(ssr && html) || ''}</div>
<script>
${(ssr && `const __redoc_state = ${JSON.stringify(state)};`) || ''}
document.addEventListener('DOMContentLoaded', function() {
var container = document.getElementById('redoc');
Redoc.${
ssr
? 'hydrate(__redoc_state, container);'
: `init("spec.json", ${JSON.stringify(redocOptions)}, container)`
};
});
</script>
<div id="redoc">${(ssr && html) || ''}</div>`,
${(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)`
};
</script>`,
redocHead: ssr
? (cdn
? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>'
: `<script>${redocStandaloneSrc}</script>`) + css
? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>'
: `<script>${redocStandaloneSrc}</script>`) + css
: '<script src="redoc.standalone.js"></script>',
title: title,
});
Expand Down

0 comments on commit d9ee2d0

Please sign in to comment.