refactor(guide): always redirect to introduction

This commit is contained in:
iCrawl 2023-04-16 17:38:45 +02:00
parent 29389e39f4
commit f2fce0a7da
No known key found for this signature in database
GPG key ID: 1AB888B16355FBB2
5 changed files with 18 additions and 28 deletions

View file

@ -0,0 +1 @@
export { default } from '~/app/not-found';

View file

@ -1,5 +1,5 @@
import { allContents } from 'contentlayer/generated';
import { redirect } from 'next/navigation';
import { notFound } from 'next/navigation';
import { Mdx } from '~/components/Mdx';
export async function generateStaticParams() {
@ -10,7 +10,7 @@ export default function Page({ params }: { params: { slug: string[] } }) {
const content = allContents.find((content) => content.slug === params.slug?.join('/'));
if (!content) {
redirect('/guide/home/introduction');
notFound();
}
return (

View file

@ -0,0 +1,5 @@
import { redirect } from 'next/navigation';
export default function Page() {
redirect('/guide/home/introduction');
}

View file

@ -1,28 +1,3 @@
import Image from 'next/image';
import vercelLogo from '~/assets/powered-by-vercel.svg';
export default function Page() {
return (
<div className="mx-auto max-w-6xl min-h-screen flex flex-col place-items-center gap-12 px-8 py-16 lg:place-content-center lg:px-8 lg:py-0">
<div className="flex flex-row place-content-center">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
rel="external noopener noreferrer"
target="_blank"
title="Vercel"
>
<Image
alt="Vercel"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
height={44}
placeholder="blur"
priority
src={vercelLogo}
width={212}
/>
</a>
</div>
</div>
);
return null;
}

View file

@ -0,0 +1,9 @@
import { NextResponse, type NextRequest } from 'next/server';
export default async function middleware(request: NextRequest) {
return NextResponse.redirect(new URL('/guide/home/introduction', request.url));
}
export const config = {
matcher: ['/'],
};