Skip to content

Commit b2d064d

Browse files
committed
Fix blog redirects
1 parent ba38047 commit b2d064d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { apiRouter, corsify, preflight } from "../src/api";
22
import { renderPage } from "vite-plugin-ssr/server";
33
import { IRequest, Router } from "itty-router";
44
import * as redirects from "../redirects.json";
5+
import { ro } from "date-fns/locale";
56

67
const router = Router();
78

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

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

0 commit comments

Comments
 (0)