docs: Merge data fetching pages (#1974) (#2107)

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
Casey Ydenberg
2023-12-07 10:50:50 +01:00
committed by GitHub
co-authored by Marvin Hagemeister
parent 2caf798016
commit 25afcae943
6 changed files with 63 additions and 58 deletions
+2
View File
@@ -8,6 +8,7 @@ import * as $_app from "./routes/_app.tsx";
import * as $_middleware from "./routes/_middleware.ts";
import * as $components from "./routes/components.tsx";
import * as $docs_slug_ from "./routes/docs/[...slug].tsx";
import * as $docs_middleware from "./routes/docs/_middleware.ts";
import * as $docs_index from "./routes/docs/index.tsx";
import * as $index from "./routes/index.tsx";
import * as $raw from "./routes/raw.ts";
@@ -30,6 +31,7 @@ const manifest = {
"./routes/_middleware.ts": $_middleware,
"./routes/components.tsx": $components,
"./routes/docs/[...slug].tsx": $docs_slug_,
"./routes/docs/_middleware.ts": $docs_middleware,
"./routes/docs/index.tsx": $docs_index,
"./routes/index.tsx": $index,
"./routes/raw.ts": $raw,
+23
View File
@@ -0,0 +1,23 @@
import { FreshContext } from "$fresh/server.ts";
const REDIRECTS: Record<string, string> = {
"/docs/getting-started/fetching-data":
"/docs/getting-started/custom-handlers",
};
export async function handler(
_req: Request,
ctx: FreshContext,
) {
// Redirect from old doc URLs to new ones
const redirect = REDIRECTS[ctx.url.pathname];
if (redirect) {
const url = new URL(redirect, ctx.url.origin);
return new Response("", {
status: 307,
headers: { location: url.href },
});
}
return await ctx.next();
}