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:
+17
-1
@@ -5,6 +5,22 @@
|
||||
/// <reference lib="deno.unstable" />
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
import { virtualSheet } from "$twind/sheets";
|
||||
import { setup, theme } from "./utils/twind.ts";
|
||||
|
||||
import routes from "./fresh.gen.ts";
|
||||
|
||||
await start(routes);
|
||||
const sheet = virtualSheet();
|
||||
sheet.reset();
|
||||
setup({ sheet, theme });
|
||||
|
||||
await start(routes, {
|
||||
render(ctx, render) {
|
||||
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);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user