From 7bc7b43f68840f8ded0c3c896238003b70e37733 Mon Sep 17 00:00:00 2001 From: nuno-aac Date: Mon, 29 Jan 2024 15:06:28 +0000 Subject: [PATCH] Fix blog redirects --- workspaces/website/functions/[[route]].ts | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/workspaces/website/functions/[[route]].ts b/workspaces/website/functions/[[route]].ts index 6f65f56109..92e6eb19cc 100644 --- a/workspaces/website/functions/[[route]].ts +++ b/workspaces/website/functions/[[route]].ts @@ -22,6 +22,35 @@ redirects.items.forEach(({ source, destination }) => { ); }); +/** + * Redirects for old posts. + */ + +router.get( + '/:locale?/posts/:category', + (req: IRequest, _context: EventContext<{}, any, Record>) => { + return Response.redirect( + new URL( + `${req.params.locale ? `/${req.params.locale}` : ``}/content/category/${req.params.category}`, + req.url + ), + 301); + } +); + +router.get( + '/:locale?/posts/:cat/:slug', + (req: IRequest, _context: EventContext<{}, any, Record>) => { + return Response.redirect( + new URL( + `${req.params.locale ? `/${req.params.locale}` : ``}/content/${req.params.slug}`, + req.url + ), + 301); + } +); + + async function ittyAssetshandler( req: IRequest, context: EventContext<{}, any, Record>