(request: NextRequest)
| 2 | import type { NextRequest } from 'next/server'; |
| 3 | |
| 4 | export function middleware(request: NextRequest) { |
| 5 | const { pathname } = request.nextUrl; |
| 6 | if (pathname.endsWith('.md')) { |
| 7 | const url = request.nextUrl.clone(); |
| 8 | url.pathname = '/md'; |
| 9 | url.searchParams.set('path', pathname.slice(0, -3)); |
| 10 | return NextResponse.rewrite(url); |
| 11 | } |
| 12 | return NextResponse.next(); |
| 13 | } |
| 14 | |
| 15 | export const config = { |
| 16 | matcher: ['/((?!_next|api|favicon|robots|sitemap|og).*\\.md)'], |