Co-authored-by: Reed von Redwitz <reed+github@vonredwitz.com>
15 lines
391 B
TypeScript
15 lines
391 B
TypeScript
import { Plugin } from "$fresh/server.ts";
|
|
|
|
let CSS_TO_INJECT = "h1 { text-decoration: underline; }";
|
|
|
|
export default {
|
|
name: "css-inject-async",
|
|
async renderAsync(ctx) {
|
|
const res = await ctx.renderAsync();
|
|
if (res.requiresHydration) {
|
|
CSS_TO_INJECT += " h1 { font-style: italic; }";
|
|
}
|
|
return { styles: [{ cssText: CSS_TO_INJECT, id: "def" }] };
|
|
},
|
|
} as Plugin;
|