www: new fenced code block design (#1629)

This commit is contained in:
Marvin Hagemeister
2023-08-13 10:52:41 +02:00
committed by GitHub
parent 7679e278cc
commit 6a599dbed5
43 changed files with 363 additions and 342 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ Let's pretend you've just initialized a new Fresh project. You want to do some
complicated setup that runs once, before the server is started. This is,
fortunately, quite easy. Here's how:
```diff
```diff main.ts
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
+import { Context } from "./routes/_middleware.ts";
@@ -18,7 +18,7 @@ fortunately, quite easy. Here's how:
So your full `main.ts` should look like this:
```ts
```ts main.ts
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
@@ -37,7 +37,7 @@ await start(manifest);
But what's going on in this new `_middleware.ts` we've created?
```ts
```ts routes/_middleware.ts
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export interface State {
@@ -66,7 +66,7 @@ export class Context {
export async function handler(
req: Request,
ctx: MiddlewareHandlerContext<State>,
ctx: MiddlewareHandlerContext<State>
) {
ctx.state.context = Context.instance();
const resp = await ctx.next();