Fix docs 404 for once and for all

This commit is contained in:
Konstantin Wohlwend 2025-08-01 15:13:57 -07:00
parent 202f54d787
commit e79ebda8d5
9 changed files with 19 additions and 23 deletions

View File

@ -1,7 +1,7 @@
import { EnhancedAPIPage } from '@/components/api/enhanced-api-page';
import { getMDXComponents } from '@/mdx-components';
import { apiSource } from 'lib/source';
import { notFound } from 'next/navigation';
import { redirect } from 'next/navigation';
import { SharedContentLayout } from '../../../components/layouts/shared-content-layout';
export default async function ApiPage({
@ -12,7 +12,7 @@ export default async function ApiPage({
const { slug } = await params;
const page = apiSource.getPage(slug ?? []);
if (!page) notFound();
if (!page) redirect("/");
const MDX = page.data.body;

View File

@ -7,7 +7,7 @@ import {
import { getMDXComponents } from '@/mdx-components';
import { createRelativeLink } from 'fumadocs-ui/mdx';
import { source } from 'lib/source';
import { notFound, redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
export default async function Page(props: {
params: Promise<{ slug?: string[] }>,
@ -20,7 +20,7 @@ export default async function Page(props: {
}
const page = source.getPage(params.slug);
if (!page) notFound();
if (!page) redirect("/");
const MDXContent = page.data.body;
@ -52,7 +52,7 @@ export async function generateMetadata(props: {
}) {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();
if (!page) redirect("/");
return {
title: page.data.title,

View File

@ -1,5 +1,5 @@
import { source } from 'lib/source';
import { notFound, redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
import { NextRequest } from 'next/server';
export function GET(request: NextRequest) {
@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
return redirect(targetPath);
} else {
// Page doesn't exist, return 404
return notFound();
return redirect("/");
}
}

View File

@ -1,5 +1,4 @@
import { notFound } from 'next/navigation';
import { type NextRequest, NextResponse } from 'next/server';
import { NextResponse, type NextRequest } from 'next/server';
import { getLLMText } from '../../../../lib/get-llm-text';
import { apiSource, source } from '../../../../lib/source';
@ -19,7 +18,7 @@ export async function GET(
page = apiSource.getPage(slug);
}
if (!page) notFound();
if (!page) redirect("/");
try {
return new NextResponse(await getLLMText(page));

View File

@ -1,5 +1,5 @@
import { source } from 'lib/source';
import { notFound, redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
import { NextRequest } from 'next/server';
export function GET(request: NextRequest) {
@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
return redirect(targetPath);
} else {
// Page doesn't exist, redirect to overview
return notFound();
return redirect("/");
}
}

View File

@ -1,8 +1,5 @@
import { redirect } from "next/navigation";
export default function NotFound() {
return (
<div>
<h2>404 Not Found</h2>
</div>
);
redirect("/");
}

View File

@ -1,5 +1,5 @@
import { source } from 'lib/source';
import { notFound, redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
import { NextRequest } from 'next/server';
export function GET(request: NextRequest) {
@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
return redirect(targetPath);
} else {
// Page doesn't exist, redirect to overview
return notFound();
return redirect("/");
}
}

View File

@ -1,5 +1,5 @@
import { source } from 'lib/source';
import { notFound, redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
import { NextRequest } from 'next/server';
export function GET(request: NextRequest) {
@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
return redirect(targetPath);
} else {
// Page doesn't exist, redirect to overview
return notFound();
return redirect("/");
}
}

View File

@ -1,5 +1,5 @@
import { apiSource } from 'lib/source';
import { notFound, redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
import { NextRequest } from 'next/server';
export function GET(request: NextRequest) {
@ -26,6 +26,6 @@ export function GET(request: NextRequest) {
return redirect(targetPath);
} else {
// Page doesn't exist, redirect to overview
return notFound();
return redirect("/");
}
}