Skip to content

Commit 7bc7b43

Browse files
committed
Fix blog redirects
1 parent ba38047 commit 7bc7b43

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

workspaces/website/functions/[[route]].ts

+29
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,35 @@ redirects.items.forEach(({ source, destination }) => {
2222
);
2323
});
2424

25+
/**
26+
* Redirects for old posts.
27+
*/
28+
29+
router.get(
30+
'/:locale?/posts/:category',
31+
(req: IRequest, _context: EventContext<{}, any, Record<string, unknown>>) => {
32+
return Response.redirect(
33+
new URL(
34+
`${req.params.locale ? `/${req.params.locale}` : ``}/content/category/${req.params.category}`,
35+
req.url
36+
),
37+
301);
38+
}
39+
);
40+
41+
router.get(
42+
'/:locale?/posts/:cat/:slug',
43+
(req: IRequest, _context: EventContext<{}, any, Record<string, unknown>>) => {
44+
return Response.redirect(
45+
new URL(
46+
`${req.params.locale ? `/${req.params.locale}` : ``}/content/${req.params.slug}`,
47+
req.url
48+
),
49+
301);
50+
}
51+
);
52+
53+
2554
async function ittyAssetshandler(
2655
req: IRequest,
2756
context: EventContext<{}, any, Record<string, unknown>>

0 commit comments

Comments
 (0)