|
67 | 67 | console.log(e.stack);
|
68 | 68 | }
|
69 | 69 | },
|
70 |
| - ) |
| 70 | +) |
71 | 71 | .command(
|
72 | 72 | 'bundle [spec]',
|
73 | 73 | 'bundle spec into zero-dependency HTML-file',
|
@@ -112,7 +112,7 @@ yargs
|
112 | 112 | console.log(e.message);
|
113 | 113 | }
|
114 | 114 | },
|
115 |
| - ) |
| 115 | +) |
116 | 116 | .demandCommand()
|
117 | 117 | .options('t', {
|
118 | 118 | alias: 'template',
|
@@ -217,22 +217,22 @@ async function getPageHTML(
|
217 | 217 | const template = compile(readFileSync(templateFileName).toString());
|
218 | 218 | return template({
|
219 | 219 | redocHTML: `
|
| 220 | + <div id="redoc">${(ssr && html) || ''}</div> |
220 | 221 | <script>
|
221 |
| - ${(ssr && `const __redoc_state = ${JSON.stringify(state)};`) || ''} |
222 |
| - document.addEventListener('DOMContentLoaded', function() { |
223 |
| - var container = document.getElementById('redoc'); |
224 |
| - Redoc.${ |
225 |
| - ssr |
226 |
| - ? 'hydrate(__redoc_state, container);' |
227 |
| - : `init("spec.json", ${JSON.stringify(redocOptions)}, container)` |
228 |
| - }; |
229 |
| - }); |
230 |
| - </script> |
231 |
| - <div id="redoc">${(ssr && html) || ''}</div>`, |
| 222 | + ${(ssr && `const __redoc_state = ${JSON.stringify(state)};`) || ''} |
| 223 | + |
| 224 | + var container = document.getElementById('redoc'); |
| 225 | + Redoc.${ |
| 226 | + ssr |
| 227 | + ? 'hydrate(__redoc_state, container);' |
| 228 | + : `init("spec.json", ${JSON.stringify(redocOptions)}, container)` |
| 229 | + }; |
| 230 | +
|
| 231 | + </script>`, |
232 | 232 | redocHead: ssr
|
233 | 233 | ? (cdn
|
234 |
| - ? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>' |
235 |
| - : `<script>${redocStandaloneSrc}</script>`) + css |
| 234 | + ? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>' |
| 235 | + : `<script>${redocStandaloneSrc}</script>`) + css |
236 | 236 | : '<script src="redoc.standalone.js"></script>',
|
237 | 237 | title: title,
|
238 | 238 | });
|
|
0 commit comments