Skip to content

Commit 67ddbdf

Browse files
docs: update Fresh 1 -> 2 migration
1 parent ede24b0 commit 67ddbdf

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

docs/canary/examples/migration-guide.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,20 @@ The full `dev.ts` file for newly generated Fresh 2 projects looks like this:
5353
```ts
5454
import { Builder } from "fresh/dev";
5555
import { tailwind } from "@fresh/plugin-tailwind";
56-
import { app } from "./main.ts";
5756

5857
// Pass development only configuration here
5958
const builder = new Builder({ target: "safari12" });
6059

6160
// Example: Enabling the tailwind plugin for Fresh
62-
tailwind(builder, app);
61+
tailwind(builder);
6362

6463
// Create optimized assets for the browser when
6564
// running `deno run -A dev.ts build`
6665
if (Deno.args.includes("build")) {
67-
await builder.build(app);
66+
await builder.build();
6867
} else {
6968
// ...otherwise start the development server
70-
await builder.listen(app);
69+
await builder.listen(() => import("./main.ts"));
7170
}
7271
```
7372

@@ -82,18 +81,9 @@ import { App, fsRoutes, staticFiles } from "fresh";
8281

8382
export const app = new App()
8483
// Add static file serving middleware
85-
.use(staticFiles());
86-
87-
// Enable file-system based routing
88-
await fsRoutes(app, {
89-
loadIsland: (path) => import(`./islands/${path}`),
90-
loadRoute: (path) => import(`./routes/${path}`),
91-
});
92-
93-
// If this module is called directly, start the server
94-
if (import.meta.main) {
95-
await app.listen();
96-
}
84+
.use(staticFiles())
85+
// Enable file-system based routing
86+
.fsRoutes();
9787
```
9888

9989
## Merging error pages
@@ -226,9 +216,9 @@ Same is true for handlers:
226216

227217
All the various context interfaces have been consolidated and simplified:
228218

229-
| Fresh 1.x | Fresh 2.x |
230-
| --------------------------------------------- | -------------- |
231-
| `AppContext`, `LayoutContext`, `RouteContext` | `FreshContext` |
219+
| Fresh 1.x | Fresh 2.x |
220+
| --------------------------------------------- | ------------------------------------------ |
221+
| `AppContext`, `LayoutContext`, `RouteContext` | [`Context`](/docs/canary/concepts/context) |
232222

233223
### Context methods
234224

0 commit comments

Comments
 (0)