BREAKING: make render fn an option on start (#260)

This commit removes the `_render.{tj}s{x}?` file in favor of a `render` option on the `start` call in `main.ts`.
This commit is contained in:
Luca Casonato
2022-06-20 13:40:23 +02:00
committed by GitHub
parent de6c3f6ed5
commit 70d1838cad
13 changed files with 113 additions and 119 deletions
-18
View File
@@ -1,18 +0,0 @@
// This module adds twind support.
import { RenderContext, RenderFn } from "$fresh/server.ts";
import { setup, theme } from "../utils/twind.ts";
import { virtualSheet } from "$twind/sheets";
const sheet = virtualSheet();
sheet.reset();
setup({ sheet, theme });
export function render(ctx: RenderContext, render: RenderFn) {
const snapshot = ctx.state.get("twindSnapshot") as unknown[] | null;
sheet.reset(snapshot || undefined);
render();
ctx.styles.splice(0, ctx.styles.length, ...(sheet).target);
const newSnapshot = sheet.reset();
ctx.state.set("twindSnapshot", newSnapshot);
}