Skip to content

Commit 857619c

Browse files
fix: redirect legacy routes to new releases routes (#158)
* fix: redirect legacy routes to new releases routes * chore: fix and add extra release build redirect
1 parent 5d6d67e commit 857619c

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

app/redirects/release-build.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { LoaderFunctionArgs } from '@remix-run/node';
2+
import { redirect } from '@remix-run/react';
3+
4+
export const loader = (args: LoaderFunctionArgs) => {
5+
return redirect(`/build/${encodeURIComponent(args.params.id!)}`);
6+
};

app/redirects/releases.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { LoaderFunctionArgs } from '@remix-run/node';
2+
import { redirect } from '@remix-run/react';
3+
4+
const channelsMap: Record<string, string | undefined> = {
5+
stable: 'stable',
6+
prerelease: 'pre',
7+
nightly: 'nightly',
8+
};
9+
10+
export const loader = (args: LoaderFunctionArgs) => {
11+
let channel = channelsMap[args.params.channel || 'stable'];
12+
if (!channel) {
13+
channel = 'stable';
14+
}
15+
return redirect(`/release?channel=${encodeURIComponent(channel)}`);
16+
};

app/routes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import { type RouteConfig, index, route } from '@remix-run/route-config';
22

3+
const redirect = (path: string, file: string) => {
4+
return {
5+
...route(path, file),
6+
id: path,
7+
};
8+
};
9+
310
export default [
411
// Home page
512
index('routes/home.tsx'),
613
// API routes
714
route('releases.json', 'api/releases.ts'),
815
route('active.json', 'api/active.ts'),
16+
// Redirects
17+
redirect('releases', 'redirects/releases.tsx'),
18+
redirect('releases/:channel', 'redirects/releases.tsx'),
19+
redirect('release-build/:id', 'redirects/release-build.tsx'),
920
// UI routes
1021
route('build/:id', 'routes/build/release-job.tsx'),
1122
route('history', 'routes/history.tsx'),

0 commit comments

Comments
 (0)