Skip to content

Commit 9cd96ae

Browse files
committed
allow for redirect on old tutorial routes
1 parent f1f1370 commit 9cd96ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

apps/codingcatdev/src/hooks.server.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { redirect, type Handle } from '@sveltejs/kit';
2+
3+
export const handle = (async ({ event, resolve }) => {
4+
if (event.url.pathname.startsWith('/tutorials')) {
5+
throw redirect(301, '/posts');
6+
}
7+
8+
if (event.url.pathname.startsWith('/tutorial')) {
9+
throw redirect(301, `/post/${event.url.pathname.split('/').at(-1)}`);
10+
}
11+
12+
const response = await resolve(event);
13+
return response;
14+
}) satisfies Handle;

0 commit comments

Comments
 (0)