feat: async plugin rendering (#745)

An async render hook is added to plugins that enables injecting stylesheets and scripts based on the rendered HTML text.
This commit is contained in:
Tom
2023-06-06 12:36:04 +02:00
committed by GitHub
parent cd760b90d4
commit dd4e584a3e
6 changed files with 113 additions and 13 deletions
+8
View File
@@ -35,6 +35,10 @@ Deno.test("/static page prerender", async () => {
assertStringIncludes(body, '<style id="abc">body { color: red; }</style>');
assert(!body.includes(`>{"v":[[],[]]}</script>`));
assert(!body.includes(`import`));
assertStringIncludes(
body,
'<style id="def">h1 { text-decoration: underline; }</style>',
);
});
Deno.test("/with-island prerender", async () => {
@@ -48,6 +52,10 @@ Deno.test("/with-island prerender", async () => {
);
assertStringIncludes(body, `>{"v":[[{}],["JS injected!"]]}</script>`);
assertStringIncludes(body, `/plugin-js-inject-main.js"`);
assertStringIncludes(
body,
'<style id="def">h1 { text-decoration: underline; } h1 { font-style: italic; }</style>',
);
});
Deno.test({