diff --git a/docs/canary/examples/migration-guide.md b/docs/canary/examples/migration-guide.md
index 355b661e..adc77527 100644
--- a/docs/canary/examples/migration-guide.md
+++ b/docs/canary/examples/migration-guide.md
@@ -70,14 +70,16 @@ if (Deno.args.includes("build")) {
}
```
+> [info]: Fresh 1.x used Tailwind CSS v3. To keep using v3 use the
+> `@fresh/plugin-tailwind-v3` instead.
+
### Updating `main.ts`
Similarly, configuration related to running Fresh in production can be passed to
`new App()`:
-```ts
-// main.ts
-import { App, fsRoutes, staticFiles } from "fresh";
+```ts main.ts
+import { App, staticFiles } from "fresh";
export const app = new App()
// Add static file serving middleware
@@ -102,7 +104,7 @@ Both the `_500.tsx` and `_404.tsx` template have been unified into a single
Inside the `_error.tsx` template you can show different content based on errors
or status codes with the following code:
-```tsx
+```tsx routes/_error.tsx
export default function ErrorPage(props: PageProps) {
const error = props.error; // Contains the thrown Error or HTTPError
if (error instanceof HttpError) {
@@ -138,7 +140,7 @@ export const handler = {
};
// Render that in _app.tsx
-export default function AppWrapper(ctx: FreshContext) {
+export default function AppWrapper(ctx: Context) {
return (
diff --git a/src/compat.ts b/src/compat.ts
index 94fa09b0..039be533 100644
--- a/src/compat.ts
+++ b/src/compat.ts
@@ -1,30 +1,29 @@
import type { ComponentChildren } from "preact";
-import type { FreshContext } from "./context.ts";
+import type { Context } from "./context.ts";
import type { PageProps } from "./render.ts";
import type { HandlerFn, RouteHandler } from "./handlers.ts";
/**
* @deprecated Use {@linkcode PageProps} instead.
*/
-export type AppProps<_Data = unknown, T = unknown> = FreshContext;
+export type AppProps<_Data = unknown, T = unknown> = Context;
/**
* @deprecated Use {@linkcode PageProps} instead.
*/
-export type LayoutProps<_Data = unknown, T = unknown> = FreshContext;
+export type LayoutProps<_Data = unknown, T = unknown> = Context;
/**
* @deprecated Use {@linkcode PageProps} instead.
*/
-export type UnknownPageProps<_Data = unknown, T = unknown> = FreshContext;
+export type UnknownPageProps<_Data = unknown, T = unknown> = Context;
/**
* @deprecated Use {@linkcode PageProps} instead.
*/
-export type ErrorPageProps<_Data = unknown, T = unknown> = FreshContext;
+export type ErrorPageProps<_Data = unknown, T = unknown> = Context;
/**
* @deprecated Use {@linkcode FreshContext} instead.
*/
-export type RouteContext<_T = never, S = Record> =
- FreshContext;
+export type RouteContext<_T = never, S = Record> = Context;
/**
* @deprecated Use {@linkcode RouteHandler} instead.
diff --git a/src/define.ts b/src/define.ts
index fbb0bb79..2e158048 100644
--- a/src/define.ts
+++ b/src/define.ts
@@ -21,7 +21,7 @@ export interface Define {
* import { define } from "../utils.ts";
*
* export const handler = define.handlers((ctx) => {
- * ctx.url; // ctx is inferred to be a FreshContext object, so this is a URL
+ * ctx.url; // ctx is inferred to be a Context object, so this is a URL
* return new Response("Hello, world!");
* });
* ```
@@ -70,7 +70,7 @@ export interface Define {
* import { define } from "../utils.ts";
*
* export default define.page((props) => {
- * const slug = props.params.slug; // Because props is inferred to be a FreshContext object, slug is inferred to be a string
+ * const slug = props.params.slug; // Because props is inferred to be a Context object, slug is inferred to be a string
* return {slug}
;
* });
* ```
@@ -124,7 +124,7 @@ export interface Define {
* import { define } from "../utils.ts";
*
* export const middleware = define.middleware((ctx) => {
- * ctx.url; // ctx is inferred to be a FreshContext object, so this is a URL
+ * ctx.url; // ctx is inferred to be a Context object, so this is a URL
* return ctx.next();
* });
* ```
diff --git a/src/handlers.ts b/src/handlers.ts
index aaff1bcd..4136f345 100644
--- a/src/handlers.ts
+++ b/src/handlers.ts
@@ -1,4 +1,4 @@
-import type { FreshContext } from "./context.ts";
+import type { Context } from "./context.ts";
import type { Method } from "./router.ts";
export interface PageResponse {
@@ -106,7 +106,7 @@ export function isHandlerByMethod(
/**
* A handler function that is invoked when a request is made to a route. The
- * handler function is passed a {@link FreshContext} object that contains the
+ * handler function is passed a {@link Context} object that contains the
* original request object, as well as any state related to the current request.
*
* The handler function can either return a {@link Response} object, which will
@@ -191,7 +191,7 @@ export function isHandlerByMethod(
* ```
*/
export interface HandlerFn {
- (ctx: FreshContext):
+ (ctx: Context):
| Response
| PageResponse
| Promise>;
diff --git a/src/middlewares/cors.ts b/src/middlewares/cors.ts
index 7de8c730..00fd0904 100644
--- a/src/middlewares/cors.ts
+++ b/src/middlewares/cors.ts
@@ -34,8 +34,8 @@ export type CORSOptions = {
/**
* CORS Middleware to set [`Cross-Origin-Resource-Sharing`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS) headers.
*
- * @param {CORSOptions} [options] - The options for the CORS middleware.
- * @returns {(req: Request, ctx: FreshContext) => Promise} The Fresh middleware handler function.
+ * @param [options] - The options for the CORS middleware.
+ * @returns The Fresh middleware handler function.
*
* @example
* ```ts
diff --git a/www/routes/_middleware.ts b/www/routes/_middleware.ts
index d407000e..ca4a0e7a 100644
--- a/www/routes/_middleware.ts
+++ b/www/routes/_middleware.ts
@@ -1,4 +1,4 @@
-import type { FreshContext } from "fresh";
+import type { Context } from "fresh";
import type { Event } from "$ga4";
import { GA4Report, isDocument, isServerError } from "$ga4";
@@ -6,9 +6,9 @@ const GA4_MEASUREMENT_ID = Deno.env.get("GA4_MEASUREMENT_ID");
let showedMissingEnvWarning = false;
-function ga4(
+function ga4(
request: Request,
- conn: FreshContext,
+ conn: Context,
response: Response,
_start: number,
error?: unknown,
@@ -87,8 +87,8 @@ function ga4(
});
}
-export async function handler(
- ctx: FreshContext,
+export async function handler(
+ ctx: Context,
): Promise {
let err;
let res: Response;
diff --git a/www/routes/docs/_middleware.ts b/www/routes/docs/_middleware.ts
index b1486dd2..ae53921b 100644
--- a/www/routes/docs/_middleware.ts
+++ b/www/routes/docs/_middleware.ts
@@ -1,13 +1,11 @@
-import type { FreshContext } from "fresh";
+import type { Context } from "fresh";
const REDIRECTS: Record = {
"/docs/getting-started/fetching-data":
"/docs/getting-started/custom-handlers",
};
-export async function handler(
- ctx: FreshContext,
-) {
+export async function handler(ctx: Context) {
// Redirect from old doc URLs to new ones
const redirect = REDIRECTS[ctx.url.pathname];
if (redirect) {