mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
fix(cli): don't wait for content loaded in bundled HTML
This commit is contained in:
parent
d1d80422a4
commit
d9ee2d0d89
30
cli/index.ts
30
cli/index.ts
|
@ -67,7 +67,7 @@ yargs
|
||||||
console.log(e.stack);
|
console.log(e.stack);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
'bundle [spec]',
|
'bundle [spec]',
|
||||||
'bundle spec into zero-dependency HTML-file',
|
'bundle spec into zero-dependency HTML-file',
|
||||||
|
@ -112,7 +112,7 @@ yargs
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.demandCommand()
|
.demandCommand()
|
||||||
.options('t', {
|
.options('t', {
|
||||||
alias: 'template',
|
alias: 'template',
|
||||||
|
@ -217,22 +217,22 @@ async function getPageHTML(
|
||||||
const template = compile(readFileSync(templateFileName).toString());
|
const template = compile(readFileSync(templateFileName).toString());
|
||||||
return template({
|
return template({
|
||||||
redocHTML: `
|
redocHTML: `
|
||||||
|
<div id="redoc">${(ssr && html) || ''}</div>
|
||||||
<script>
|
<script>
|
||||||
${(ssr && `const __redoc_state = ${JSON.stringify(state)};`) || ''}
|
${(ssr && `const __redoc_state = ${JSON.stringify(state)};`) || ''}
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
var container = document.getElementById('redoc');
|
var container = document.getElementById('redoc');
|
||||||
Redoc.${
|
Redoc.${
|
||||||
ssr
|
ssr
|
||||||
? 'hydrate(__redoc_state, container);'
|
? 'hydrate(__redoc_state, container);'
|
||||||
: `init("spec.json", ${JSON.stringify(redocOptions)}, container)`
|
: `init("spec.json", ${JSON.stringify(redocOptions)}, container)`
|
||||||
};
|
};
|
||||||
});
|
|
||||||
</script>
|
</script>`,
|
||||||
<div id="redoc">${(ssr && html) || ''}</div>`,
|
|
||||||
redocHead: ssr
|
redocHead: ssr
|
||||||
? (cdn
|
? (cdn
|
||||||
? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>'
|
? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>'
|
||||||
: `<script>${redocStandaloneSrc}</script>`) + css
|
: `<script>${redocStandaloneSrc}</script>`) + css
|
||||||
: '<script src="redoc.standalone.js"></script>',
|
: '<script src="redoc.standalone.js"></script>',
|
||||||
title: title,
|
title: title,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user