Skip to content

Commit e1b6003

Browse files
committed
fix: inject styles and scripts in given order
1 parent 1ce3c7a commit e1b6003

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"@typescript-eslint/prefer-readonly-parameter-types": "off",
119119
"camelcase": "off",
120120
"capitalized-comments": "off",
121+
"no-await-in-loop": "off",
121122
"no-promise-executor-return": "off",
122123
"node/no-unsupported-features/es-syntax": "off",
123124
"unicorn/no-array-callback-reference": "off",

src/lib/generate-output.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ export async function generateOutput(html: string, relativePath: string, config:
3030
await page.goto(`http://localhost:${config.port!}${relativePath}`); // make sure relative paths work as expected
3131
await page.setContent(html); // overwrite the page content with what was generated from the markdown
3232

33-
await Promise.all([
34-
...config.stylesheet.map(
35-
async (stylesheet) => page.addStyleTag(isHttpUrl(stylesheet) ? { url: stylesheet } : { path: stylesheet }), // add each stylesheet
36-
),
37-
config.css ? page.addStyleTag({ content: config.css }) : undefined, // add custom css
38-
]);
33+
for (const stylesheet of config.stylesheet) {
34+
await page.addStyleTag(isHttpUrl(stylesheet) ? { url: stylesheet } : { path: stylesheet });
35+
}
3936

40-
await Promise.all(config.script.map(async (scriptTagOptions) => page.addScriptTag(scriptTagOptions)));
37+
if (config.css) {
38+
await page.addStyleTag({ content: config.css });
39+
}
40+
41+
for (const scriptTagOptions of config.script) {
42+
await page.addScriptTag(scriptTagOptions);
43+
}
4144

4245
/**
4346
* Trick to wait for network to be idle.

0 commit comments

Comments
 (0)