23 lines
531 B
TypeScript
23 lines
531 B
TypeScript
import type { FreshContext } from "@fresh/core";
|
|
|
|
const REDIRECTS: Record<string, string> = {
|
|
"/docs/getting-started/fetching-data":
|
|
"/docs/getting-started/custom-handlers",
|
|
};
|
|
|
|
export async function handler(
|
|
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();
|
|
}
|