Skip to content

Commit 144ed2e

Browse files
authored
refactor(core): minor fresh/compat cleanups (#2880)
1 parent 8953650 commit 144ed2e

File tree

4 files changed

+19
-42
lines changed

4 files changed

+19
-42
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
".": "./src/mod.ts",
1414
"./runtime": "./src/runtime/shared.ts",
1515
"./dev": "./src/dev/mod.ts",
16-
"./compat": "./src/compat/mod.ts"
16+
"./compat": "./src/compat.ts"
1717
},
1818
"tasks": {
1919
"test": "deno test -A --parallel",
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import type { VNode } from "preact";
2-
import type { FreshContext } from "../context.ts";
3-
import type { HandlerFn, RouteHandler } from "../handlers.ts";
2+
import type { FreshContext } from "./context.ts";
3+
import type { HandlerFn, RouteHandler } from "./handlers.ts";
44

55
/**
6-
* @deprecated Use {@link PageProps} instead.
6+
* @deprecated Use {@linkcode PageProps} instead.
77
*/
88
export type AppProps<_Data = unknown, T = unknown> = FreshContext<T>;
99
/**
10-
* @deprecated Use {@link PageProps} instead.
10+
* @deprecated Use {@linkcode PageProps} instead.
1111
*/
1212
export type LayoutProps<_Data = unknown, T = unknown> = FreshContext<T>;
1313
/**
14-
* @deprecated Use {@link PageProps} instead.
14+
* @deprecated Use {@linkcode PageProps} instead.
1515
*/
1616
export type UnknownPageProps<_Data = unknown, T = unknown> = FreshContext<T>;
1717
/**
18-
* @deprecated Use {@link PageProps} instead.
18+
* @deprecated Use {@linkcode PageProps} instead.
1919
*/
2020
export type ErrorPageProps<_Data = unknown, T = unknown> = FreshContext<T>;
2121

2222
/**
23-
* @deprecated Use {@link FreshContext} instead.
23+
* @deprecated Use {@linkcode FreshContext} instead.
2424
*/
2525
export type RouteContext<_T = never, S = Record<string, unknown>> =
2626
FreshContext<S>;
2727

2828
/**
29-
* @deprecated Use {@link RouteHandler} instead.
29+
* @deprecated Use {@linkcode RouteHandler} instead.
3030
*/
3131
// deno-lint-ignore no-explicit-any
3232
export type Handlers<T = any, State = Record<string, unknown>> = RouteHandler<
@@ -35,7 +35,7 @@ export type Handlers<T = any, State = Record<string, unknown>> = RouteHandler<
3535
>;
3636

3737
/**
38-
* @deprecated Use {@link HandlerFn} instead.
38+
* @deprecated Use {@linkcode HandlerFn} instead.
3939
*/
4040
// deno-lint-ignore no-explicit-any
4141
export type Handler<T = any, State = Record<string, unknown>> = HandlerFn<
@@ -54,14 +54,14 @@ function defineFn<State>(
5454
}
5555

5656
/**
57-
* @deprecated Use {@link [../mod.ts].Define.page|define.page} instead.
57+
* @deprecated Use {@linkcode [./mod.ts].Define.page|define.page} instead.
5858
*/
5959
export const defineApp = defineFn;
6060
/**
61-
* @deprecated Use {@link [../mod.ts].Define.page|define.page} instead.
61+
* @deprecated Use {@linkcode [./mod.ts].Define.page|define.page} instead.
6262
*/
6363
export const defineRoute = defineFn;
6464
/**
65-
* @deprecated Use {@link [../mod.ts].Define.page|define.page} instead.
65+
* @deprecated Use {@linkcode [./mod.ts].Define.page|define.page} instead.
6666
*/
6767
export const defineLayout = defineFn;

src/compat/mod.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

www/routes/docs/index.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
import type { Handlers } from "fresh/compat";
1+
import { define } from "../../utils/state.ts";
22

3-
export const handler: Handlers<void> = {
3+
export const handler = define.handlers({
44
GET(ctx) {
5-
const slug = ctx.params.slug;
6-
7-
if (slug === "concepts/architechture") {
8-
return new Response("", {
9-
status: 307,
10-
headers: { location: "/docs/concepts/architecture" },
11-
});
12-
}
13-
14-
return new Response("", {
15-
status: 307,
16-
headers: { location: "/docs/introduction" },
17-
});
5+
return ctx.url.pathname === "/concepts/architechture"
6+
? ctx.redirect("/docs/concepts/architecture")
7+
: ctx.redirect("/docs/introduction");
188
},
19-
};
9+
});

0 commit comments

Comments
 (0)