Skip to content

Commit e79ebda

Browse files
committed
Fix docs 404 for once and for all
1 parent 202f54d commit e79ebda

File tree

9 files changed

+19
-23
lines changed

9 files changed

+19
-23
lines changed

docs/src/app/api/[[...slug]]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EnhancedAPIPage } from '@/components/api/enhanced-api-page';
22
import { getMDXComponents } from '@/mdx-components';
33
import { apiSource } from 'lib/source';
4-
import { notFound } from 'next/navigation';
4+
import { redirect } from 'next/navigation';
55
import { SharedContentLayout } from '../../../components/layouts/shared-content-layout';
66

77
export default async function ApiPage({
@@ -12,7 +12,7 @@ export default async function ApiPage({
1212
const { slug } = await params;
1313
const page = apiSource.getPage(slug ?? []);
1414

15-
if (!page) notFound();
15+
if (!page) redirect("/");
1616

1717
const MDX = page.data.body;
1818

docs/src/app/docs/[[...slug]]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { getMDXComponents } from '@/mdx-components';
88
import { createRelativeLink } from 'fumadocs-ui/mdx';
99
import { source } from 'lib/source';
10-
import { notFound, redirect } from 'next/navigation';
10+
import { redirect } from 'next/navigation';
1111

1212
export default async function Page(props: {
1313
params: Promise<{ slug?: string[] }>,
@@ -20,7 +20,7 @@ export default async function Page(props: {
2020
}
2121

2222
const page = source.getPage(params.slug);
23-
if (!page) notFound();
23+
if (!page) redirect("/");
2424

2525
const MDXContent = page.data.body;
2626

@@ -52,7 +52,7 @@ export async function generateMetadata(props: {
5252
}) {
5353
const params = await props.params;
5454
const page = source.getPage(params.slug);
55-
if (!page) notFound();
55+
if (!page) redirect("/");
5656

5757
return {
5858
title: page.data.title,

docs/src/app/js/[...path]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { source } from 'lib/source';
2-
import { notFound, redirect } from 'next/navigation';
2+
import { redirect } from 'next/navigation';
33
import { NextRequest } from 'next/server';
44

55
export function GET(request: NextRequest) {
@@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
2626
return redirect(targetPath);
2727
} else {
2828
// Page doesn't exist, return 404
29-
return notFound();
29+
return redirect("/");
3030
}
3131
}

docs/src/app/llms.mdx/[[...slug]]/route.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { notFound } from 'next/navigation';
2-
import { type NextRequest, NextResponse } from 'next/server';
1+
import { NextResponse, type NextRequest } from 'next/server';
32
import { getLLMText } from '../../../../lib/get-llm-text';
43
import { apiSource, source } from '../../../../lib/source';
54

@@ -19,7 +18,7 @@ export async function GET(
1918
page = apiSource.getPage(slug);
2019
}
2120

22-
if (!page) notFound();
21+
if (!page) redirect("/");
2322

2423
try {
2524
return new NextResponse(await getLLMText(page));

docs/src/app/next/[...path]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { source } from 'lib/source';
2-
import { notFound, redirect } from 'next/navigation';
2+
import { redirect } from 'next/navigation';
33
import { NextRequest } from 'next/server';
44

55
export function GET(request: NextRequest) {
@@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
2626
return redirect(targetPath);
2727
} else {
2828
// Page doesn't exist, redirect to overview
29-
return notFound();
29+
return redirect("/");
3030
}
3131
}

docs/src/app/not-found.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1+
import { redirect } from "next/navigation";
12

23
export default function NotFound() {
3-
return (
4-
<div>
5-
<h2>404 Not Found</h2>
6-
</div>
7-
);
4+
redirect("/");
85
}

docs/src/app/python/[...path]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { source } from 'lib/source';
2-
import { notFound, redirect } from 'next/navigation';
2+
import { redirect } from 'next/navigation';
33
import { NextRequest } from 'next/server';
44

55
export function GET(request: NextRequest) {
@@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
2626
return redirect(targetPath);
2727
} else {
2828
// Page doesn't exist, redirect to overview
29-
return notFound();
29+
return redirect("/");
3030
}
3131
}

docs/src/app/react/[...path]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { source } from 'lib/source';
2-
import { notFound, redirect } from 'next/navigation';
2+
import { redirect } from 'next/navigation';
33
import { NextRequest } from 'next/server';
44

55
export function GET(request: NextRequest) {
@@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
2626
return redirect(targetPath);
2727
} else {
2828
// Page doesn't exist, redirect to overview
29-
return notFound();
29+
return redirect("/");
3030
}
3131
}

docs/src/app/rest-api/[...path]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { apiSource } from 'lib/source';
2-
import { notFound, redirect } from 'next/navigation';
2+
import { redirect } from 'next/navigation';
33
import { NextRequest } from 'next/server';
44

55
export function GET(request: NextRequest) {
@@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
2626
return redirect(targetPath);
2727
} else {
2828
// Page doesn't exist, redirect to overview
29-
return notFound();
29+
return redirect("/");
3030
}
3131
}

0 commit comments

Comments
 (0)