forked from egoist-labs/denopkg.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
26 lines (21 loc) · 816 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { InnerRenderFunction, RenderContext, start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import { config, setup } from "@twind";
import { virtualSheet } from "twind/sheets";
const sheet = virtualSheet();
sheet.reset();
setup({ ...config, sheet });
function render(ctx: RenderContext, render: InnerRenderFunction) {
const snapshot = ctx.state.get("twind") as unknown[] | null;
sheet.reset(snapshot || undefined);
render();
ctx.styles.splice(0, ctx.styles.length, ...(sheet).target);
const newSnapshot = sheet.reset();
ctx.state.set("twind", newSnapshot);
}
await start(manifest, { render });