Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/web/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,27 @@ a:hover {
color: var(--ink-2);
}

/* Not found */

.not-found {
display: flex;
flex-direction: column;
gap: var(--space-8);
padding-block: var(--space-16) var(--space-24);
}

.not-found-title {
font-size: var(--text-title);
font-weight: var(--weight-strong);
line-height: var(--leading-tight);
letter-spacing: var(--tracking-title);
}

.requested-path {
color: var(--ink);
overflow-wrap: anywhere;
}

/* Report: head */

.report {
Expand Down
14 changes: 14 additions & 0 deletions apps/web/src/app/not-found.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test, vi } from 'vitest';
import NotFound from './not-found.tsx';

vi.mock('next/navigation', () => ({ usePathname: () => '/pricing' }));

test('says the page is missing, names the address, and offers a scan and the home page', () => {
const html = renderToStaticMarkup(<NotFound />);
expect(html).toContain('<h1 class="not-found-title">Page not found</h1>');
expect(html).toContain('<span class="mono requested-path">/pricing</span>');
expect(html).toContain('class="scan-form compact"');
expect(html).toContain('<a href="/">Back to the home page</a>');
expect(html).toContain('class="site-header"');
});
27 changes: 27 additions & 0 deletions apps/web/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Metadata } from 'next';
import { RequestedPath } from './requested-path.tsx';
import { ScanForm } from './scan-form.tsx';
import { SiteHeader } from './site-chrome.tsx';

export const metadata: Metadata = { title: 'Page not found · stackprobe' };

// Any address that doesn't exist. Next sends it with a 404 status.
export default function NotFound() {
return (
<>
<SiteHeader />
<main className="page not-found">
<div className="report-title">
<h1 className="not-found-title">Page not found</h1>
<p className="verdict">
There's no page at <RequestedPath />. Scan a domain, or go back to the home page.
</p>
</div>
<ScanForm variant="compact" />
<p>
<a href="/">Back to the home page</a>
</p>
</main>
</>
);
}
9 changes: 9 additions & 0 deletions apps/web/src/app/requested-path.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client';

import { usePathname } from 'next/navigation';

// The address that was asked for, which the not-found page isn't given on the server.
export function RequestedPath() {
const path = usePathname();
return <span className="mono requested-path">{path || 'this address'}</span>;
}
Loading