add 404 page and sitemap

This commit is contained in:
miloschwartz
2026-09-25 19:46:47 -04:00
parent e5e87f9019
commit 175208ee49
9 changed files with 315 additions and 3 deletions
+5 -2
View File
@@ -5,8 +5,8 @@ import {
DocsPage,
DocsTitle,
MarkdownCopyButton,
ViewOptionsPopover,
} from 'fumadocs-ui/layouts/notebook/page';
import { ViewOptionsPopover } from '@/components/view-options';
import { notFound } from 'next/navigation';
import { getMDXComponents } from '@/components/mdx';
import type { Metadata } from 'next';
@@ -77,7 +77,10 @@ export async function generateMetadata(props: PageProps<'/[[...slug]]'>): Promis
description: page.data.description,
alternates: {
canonical: page.url,
types: { 'text/markdown': getPageMarkdownUrl(page).url },
types: {
'text/markdown': getPageMarkdownUrl(page).url,
'application/xml': '/sitemap.xml',
},
},
openGraph: {
images: '/images/home-social-graph.png',
+30
View File
@@ -0,0 +1,30 @@
import type { Metadata } from 'next';
import type { ReactNode } from 'react';
import type * as PageTree from 'fumadocs-core/page-tree';
import { NotFoundPage, type NotFoundLink } from '@/components/not-found';
import { getNavigationTree } from '@/lib/navigation';
export const metadata: Metadata = {
title: 'Page Not Found',
};
function label(name: ReactNode) {
return typeof name === 'string' ? name : null;
}
function flatten(nodes: PageTree.Node[]): NotFoundLink[] {
const links: NotFoundLink[] = [];
for (const node of nodes) {
if (node.type === 'page') {
const title = label(node.name);
if (title && node.url) links.push({ title, url: node.url });
continue;
}
if (node.type === 'folder') links.push(...flatten(node.children));
}
return links;
}
export default function NotFound() {
return <NotFoundPage pages={flatten(getNavigationTree().children)} />;
}