We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 994d5ad commit 4766281Copy full SHA for 4766281
website/middleware.ts
@@ -0,0 +1,21 @@
1
+import { NextResponse } from 'next/server';
2
+import type { NextRequest } from 'next/server';
3
+
4
+export function middleware(request: NextRequest) {
5
+ const pathname = request.nextUrl.pathname;
6
7
+ // Add trailing slash to framework-docs paths (except for files with extensions)
8
+ if (pathname.startsWith('/framework-docs/') &&
9
+ !pathname.endsWith('/') &&
10
+ !pathname.match(/\.[a-zA-Z0-9]+$/)) {
11
+ const url = request.nextUrl.clone();
12
+ url.pathname = pathname + '/';
13
+ return NextResponse.redirect(url, 308);
14
+ }
15
16
+ return NextResponse.next();
17
+}
18
19
+export const config = {
20
+ matcher: '/framework-docs/:path*',
21
+};
0 commit comments