forked from wevm/wagmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiddleware.ts
24 lines (21 loc) · 1001 Bytes
/
middleware.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { NextRequest, NextResponse } from 'next/server'
import { locales } from 'nextra/locales'
const redirects: Record<string, string> = {
'/docs/connectors/coinbase-wallet': '/docs/connectors/coinbaseWallet',
'/docs/connectors/metamask': '/docs/connectors/metaMask',
'/docs/connectors/walletconnect': '/docs/connectors/walletConnect',
'/docs/migrating-to-030': '/docs/migrating-to-03', // Tweeted wrong link: https://twitter.com/awkweb/status/1518607780332122116
'/docs/migrating-to-03': '/docs/migration-guide',
'/docs/provider': '/docs/WagmiConfig',
}
export function middleware(request: NextRequest) {
// Handle redirect in `_middleware.ts` because of bug using `next.config.js`
// https://github.com/shuding/nextra/issues/384
if (request.nextUrl.pathname in redirects) {
const url = request.nextUrl.clone()
const pathname = redirects[request.nextUrl.pathname] ?? '/'
url.pathname = pathname
return NextResponse.redirect(url)
}
return locales(request)
}