Skip to content

Commit

Permalink
Fix blog redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-aac committed Jan 29, 2024
1 parent ba38047 commit 48fe890
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions workspaces/website/functions/[[route]].ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { apiRouter, corsify, preflight } from "../src/api";
import { renderPage } from "vite-plugin-ssr/server";
import { IRequest, Router } from "itty-router";
import * as redirects from "../redirects.json";
import { ro } from "date-fns/locale";

const router = Router();

Expand All @@ -22,6 +23,25 @@ redirects.items.forEach(({ source, destination }) => {
);
});

/**
* Redirects for old posts.
*/

router.get(
'/:locale/posts/:category',
(req: IRequest, _context: EventContext<{}, any, Record<string, unknown>>) => {
return Response.redirect(new URL(`/${req.params.locale}/content/category/${req.params.category}`, req.url), 301);
}
);

router.get(
'/:locale/posts/:cat/:slug',
(req: IRequest, _context: EventContext<{}, any, Record<string, unknown>>) => {
return Response.redirect(new URL(`/${req.params.locale}/content/${req.params.slug}`, req.url), 301);
}
);


async function ittyAssetshandler(
req: IRequest,
context: EventContext<{}, any, Record<string, unknown>>
Expand Down

0 comments on commit 48fe890

Please sign in to comment.