deno.land / x / fresh@1.1.1 / tests / fixture_plugin / utils / css-inject-plugin.ts

css-inject-plugin.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Plugin } from "$fresh/server.ts";
let CSS_TO_INJECT = "";export function inject(cssText: string) { CSS_TO_INJECT = cssText;}
export default { name: "css-inject", render(ctx) { CSS_TO_INJECT = ""; const res = ctx.render(); if (res.requiresHydration) { CSS_TO_INJECT += " h1 { color: blue; }"; } return { styles: [{ cssText: CSS_TO_INJECT, id: "abc" }] }; },} as Plugin;
fresh

Version Info

Tagged at
2 years ago