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:
+6
-8
@@ -2,19 +2,17 @@
|
||||
// This file SHOULD be checked into source version control.
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $0 from "./routes/_render.ts";
|
||||
import * as $1 from "./routes/docs/[...slug].tsx";
|
||||
import * as $2 from "./routes/gfm.css.ts";
|
||||
import * as $3 from "./routes/index.tsx";
|
||||
import * as $0 from "./routes/docs/[...slug].tsx";
|
||||
import * as $1 from "./routes/gfm.css.ts";
|
||||
import * as $2 from "./routes/index.tsx";
|
||||
import * as $$0 from "./islands/Counter.tsx";
|
||||
import * as $$1 from "./islands/LemonDrop.tsx";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/_render.ts": $0,
|
||||
"./routes/docs/[...slug].tsx": $1,
|
||||
"./routes/gfm.css.ts": $2,
|
||||
"./routes/index.tsx": $3,
|
||||
"./routes/docs/[...slug].tsx": $0,
|
||||
"./routes/gfm.css.ts": $1,
|
||||
"./routes/index.tsx": $2,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$0,
|
||||
|
||||
+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);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user