mirror of
https://github.com/placeholder-soft/web.git
synced 2026-01-12 22:45:00 +08:00
setup redirects in next js config (#733)
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import ProfileProviders from 'apps/web/app/(basenames)/name/[username]/ProfileProviders';
|
||||
import { Metadata } from 'next';
|
||||
import { base } from 'viem/chains';
|
||||
import {
|
||||
fetchAddress,
|
||||
fetchDescription,
|
||||
formatDefaultUsername,
|
||||
USERNAME_DOMAINS,
|
||||
} from 'apps/web/src/utils/usernames';
|
||||
import { redirect } from 'next/navigation';
|
||||
import classNames from 'classnames';
|
||||
@@ -34,18 +32,7 @@ export async function generateMetadata({ params }: UsernameProfileProps): Promis
|
||||
}
|
||||
|
||||
export default async function Username({ params }: UsernameProfileProps) {
|
||||
let username = params.username;
|
||||
|
||||
// redirect /[name].base.eth to /name
|
||||
if (username.endsWith(`.${USERNAME_DOMAINS[base.id]}`)) {
|
||||
return redirect(username.replace(`.${USERNAME_DOMAINS[base.id]}`, ''));
|
||||
}
|
||||
|
||||
username = await formatDefaultUsername(params.username);
|
||||
|
||||
const usernameProfilePageClasses = classNames(
|
||||
'mx-auto mt-32 flex min-h-screen w-full max-w-[1440px] flex-col justify-between gap-10 px-4 px-4 pb-40 md:flex-row md:px-8',
|
||||
);
|
||||
let username = await formatDefaultUsername(params.username);
|
||||
|
||||
const ensAddress = await fetchAddress(username);
|
||||
|
||||
@@ -54,6 +41,10 @@ export default async function Username({ params }: UsernameProfileProps) {
|
||||
redirect(`/name/not-found?name=${username}`);
|
||||
}
|
||||
|
||||
const usernameProfilePageClasses = classNames(
|
||||
'mx-auto mt-32 flex min-h-screen w-full max-w-[1440px] flex-col justify-between gap-10 px-4 px-4 pb-40 md:flex-row md:px-8',
|
||||
);
|
||||
|
||||
return (
|
||||
<ProfileProviders username={username} address={ensAddress}>
|
||||
<main className={usernameProfilePageClasses}>
|
||||
|
||||
@@ -238,6 +238,21 @@ module.exports = extendBaseConfig(
|
||||
destination: 'https://buildonbase.deform.cc/registry-edit/',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: '/name/:path.base.eth',
|
||||
destination: '/name/:path',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: '/names/:path',
|
||||
destination: '/name/:path',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: '/name',
|
||||
destination: '/names',
|
||||
permanent: true,
|
||||
},
|
||||
];
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user