Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(docsite): add custom 404 page with header and footer (#2899)

Kenton Quatmanaebddb3626d7
diff --git a/apps/docsite/src/__tests__/mcp-server.test.ts b/apps/docsite/src/__tests__/mcp-server.test.ts
index 1faf8065d4..aa372ffb96 100644
--- a/apps/docsite/src/__tests__/mcp-server.test.ts
+++ b/apps/docsite/src/__tests__/mcp-server.test.ts
@@ -18,7 +18,7 @@ import {templates} from '../generated/templateRegistry';
import type {ComponentEntry} from '../generated/componentRegistry';
// ── Replicate MCP server logic for testing ─────────────────────────────
-// These mirror the runtime logic in apps/docsite/src/app/[transport]/route.ts
+// These mirror the runtime logic in apps/docsite/src/app/mcp/route.ts
// without importing the Next.js route handler directly.
const allComponents: ComponentEntry[] = Object.values(components).flat();
@@ -268,7 +268,7 @@ describe('MCP search simulation', () => {
describe('MCP branding', () => {
it('route file uses Astryx (XDS) in tool descriptions', async () => {
const fs = await import('node:fs');
- const routePath = new URL('../app/[transport]/route.ts', import.meta.url);
+ const routePath = new URL('../app/mcp/route.ts', import.meta.url);
const source = fs.readFileSync(routePath, 'utf-8');
expect(source).toContain('Search Astryx (XDS) design system');
expect(source).toContain('Astryx (XDS) component');
@@ -279,7 +279,7 @@ describe('MCP branding', () => {
it('route file does not contain hardcoded ALIASES map', async () => {
const fs = await import('node:fs');
- const routePath = new URL('../app/[transport]/route.ts', import.meta.url);
+ const routePath = new URL('../app/mcp/route.ts', import.meta.url);
const source = fs.readFileSync(routePath, 'utf-8');
expect(source).not.toContain('const ALIASES');
expect(source).toContain('keywordIndex');
diff --git a/apps/docsite/src/app/[transport]/route.ts b/apps/docsite/src/app/mcp/route.ts
similarity index 100%
rename from apps/docsite/src/app/[transport]/route.ts
rename to apps/docsite/src/app/mcp/route.ts
diff --git a/apps/docsite/src/app/not-found.module.css b/apps/docsite/src/app/not-found.module.css
new file mode 100644
index 0000000000..bb8519b428
--- /dev/null
+++ b/apps/docsite/src/app/not-found.module.css
@@ -0,0 +1,14 @@
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
+.shell {
+ display: flex;
+ flex-direction: column;
+ min-height: 100%;
+ height: 100%;
+ width: 100%;
+}
+
+.content {
+ flex: 1 1 auto;
+ width: 100%;
+}
diff --git a/apps/docsite/src/app/not-found.tsx b/apps/docsite/src/app/not-found.tsx
new file mode 100644
index 0000000000..e263c49431
--- /dev/null
+++ b/apps/docsite/src/app/not-found.tsx
@@ -0,0 +1,40 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {headers} from 'next/headers';
+import {XDSAppShell} from '@xds/core/AppShell';
+import {XDSCenter} from '@xds/core/Center';
+import {XDSVStack} from '@xds/core/Layout';
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {SharedTopNav} from '../components/SharedTopNav';
+import {SiteFooter} from '../components/SiteFooter';
+import styles from './not-found.module.css';
+
+export default async function NotFound() {
+ const headersList = await headers();
+ const ua = headersList.get('user-agent') ?? '';
+ const defaultIsMobile = /mobile|android|iphone|ipad/i.test(ua);
+
+ return (
+ <XDSAppShell
+ variant="surface"
+ height="fill"
+ mobileNav={{defaultIsMobile}}
+ topNav={<SharedTopNav />}>
+ <div className={styles.shell}>
+ <div className={styles.content}>
+ <XDSCenter axis="both" height="100%">
+ <XDSVStack gap={2} hAlign="center">
+ <XDSHeading level={1} type="display-1">
+ 404
+ </XDSHeading>
+ <XDSText type="body" color="secondary">
+ This page could not be found.
+ </XDSText>
+ </XDSVStack>
+ </XDSCenter>
+ </div>
+ <SiteFooter />
+ </div>
+ </XDSAppShell>
+ );
+}