-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.ts
More file actions
29 lines (24 loc) · 819 Bytes
/
main.ts
File metadata and controls
29 lines (24 loc) · 819 Bytes
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
27
28
29
/// <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 });