Skip to content
626 linesCodeBlameRaw
1import {
2 BookOpen,
3 ChevronDown,
4 Compass,
5 CreditCard,
6 LayoutDashboard,
7 LogIn,
8 LogOut,
9 Menu,
10 Plus,
11 Search,
12 Settings,
13} from "lucide-react";
14import { useEffect, useState } from "react";
15import {
16 Form,
17 isRouteErrorResponse,
18 Link,
19 Links,
20 Meta,
21 NavLink,
22 Outlet,
23 Scripts,
24 ScrollRestoration,
25 type ShouldRevalidateFunctionArgs,
26 useLocation,
27 useMatches,
28 useParams,
29 useRouteError,
30 useRouteLoaderData,
31 useSubmit,
32} from "react-router";
33
34import { type User, awaitsConfirmation, hasAccessIn, sharedWorkspaces } from "@g1t/contracts";
35
36import type { Route } from "./+types/root";
37import appCss from "./app.css?url";
38import displayFont from "@g1t/theme/fonts/bricolage-grotesque-latin.woff2?url";
39import sansFont from "@g1t/theme/fonts/hanken-grotesk-latin.woff2?url";
40import { Logo } from "./components/logo";
41import { Avatar, ButtonLink, SubmitButton, notACredential } from "./components/ui";
42import {
43 DropdownMenu,
44 DropdownMenuContent,
45 DropdownMenuItem,
46 DropdownMenuLabel,
47 DropdownMenuSeparator,
48 DropdownMenuTrigger,
49} from "./components/ui/dropdown-menu";
50import { AppShell, Progress, type ShellData, useLeaving } from "./components/shell";
51import { SiteFooter } from "./components/footer";
52import { SpikeBanner } from "./components/spike-banner";
53import { PolicyNotice } from "./components/policy-notice";
54import { readCookie } from "./lib/mission";
55import { WORKSPACE_COOKIE, workspaceFor } from "./lib/workspace-choice";
56import { NotFound } from "./components/not-found";
57import { usesAppShell } from "./lib/chrome";
58import { CommandPalette, type PaletteCommand, PaletteKey, usePaletteShortcut } from "./components/command-palette";
59import { billing, inbox, projects } from "./lib/services.server";
60import { countsFor, readableRepos } from "./lib/access.server";
61import { shortCache } from "./lib/cache.server";
62import { getViewer, viewerMiddleware } from "./lib/session.server";
63import { shortcutOf, workspaceProjects } from "./lib/workspace-projects.server";
64import { registrationMode } from "./lib/registration.server";
65import { addresses } from "./lib/addresses.server";
66import { useSignUpCopy } from "./lib/registration";
67import { RELOADED_KEY, reloadFixes } from "./lib/stale-build";
68
69
70export const links: Route.LinksFunction = () => [
71 { rel: "icon", href: "/favicon.ico", sizes: "32x32" },
72 { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
73 { rel: "icon", type: "image/png", sizes: "192x192", href: "/icon-192.png" },
74 { rel: "apple-touch-icon", href: "/apple-touch-icon.png" },
75 // The text and headline faces are wanted on every page, so they start
76 // loading with the stylesheet; mono waits until something uses it.
77 { rel: "preload", href: sansFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
78 { rel: "preload", href: displayFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
79];
80
81export const middleware: Route.MiddlewareFunction[] = [viewerMiddleware];
82
83export async function loader({ context, params, request }: Route.LoaderArgs) {
84 const user = getViewer(context);
85 const chosen = readCookie(request.headers.get("cookie"), WORKSPACE_COOKIE);
86 // What sign-up buttons say: Request access while g1t is invite-only.
87 const [shell, mode] = await Promise.all([
88 // An account still confirming its address sees only the pages that
89 // allows (lib/confirm-gate.ts), in the visitor's frame.
90 user && !awaitsConfirmation(user)
91 ? shellFor(user, params, chosen, context).catch((error: unknown) => {
92 // A sidebar that could not be read is no reason to lose the page,
93 // or to draw it as if they were signed out.
94 console.error("root: the sidebar could not be read", error);
95 return bareShell(user, params, chosen);
96 })
97 : visitorShell(params, context),
98 user ? Promise.resolve(null) : registrationMode(),
99 ]);
100 // Where this g1t lives, for clone lines, agent setup and link previews.
101 return { user, shell, inviteOnly: mode !== "open", addresses: addresses() };
102}
103
104/**
105 * The sidebar for someone not signed in: nothing of their own, only the
106 * open counts of the project being looked at. One call, and only in a
107 * project; it answers the same for a private project as a missing one.
108 */
109async function visitorShell(params: { owner?: string; repo?: string }, context: Route.LoaderArgs["context"]): Promise<ShellData> {
110 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
111 const counts = path ? await countsFor(context, params) : null;
112 return {
113 workspace: null,
114 repos: [],
115 repo: path && counts?.ok ? { ...path, member: false, issues: counts.value.issues, pulls: counts.value.pulls } : null,
116 limit: null,
117 monthUsageMicros: null,
118 };
119}
120
121/** The sidebar from what the session already says, with no service asked. */
122function bareShell(user: User, params: { owner?: string; repo?: string }, chosen: string | null): ShellData {
123 return {
124 workspace: workspaceFor(user.workspaces ?? [], chosen, params),
125 repos: [],
126 repo: null,
127 limit: null,
128 monthUsageMicros: null,
129 };
130}
131
132/**
133 * The sidebar only changes with the workspace or repository being looked
134 * at, or after something was submitted: not on every page within them.
135 */
136export function shouldRevalidate({
137 currentParams,
138 nextParams,
139 formMethod,
140 defaultShouldRevalidate,
141}: ShouldRevalidateFunctionArgs) {
142 if (formMethod && formMethod !== "GET") return defaultShouldRevalidate;
143 return currentParams.owner !== nextParams.owner || currentParams.repo !== nextParams.repo;
144}
145
146/**
147 * The sidebar: the workspace whose pages or project these are when it is
148 * one of yours, else the one you chose (lib/workspace-choice.ts); its
149 * projects; and the repository being looked at.
150 */
151async function shellFor(
152 user: User,
153 params: { owner?: string; repo?: string },
154 chosen: string | null,
155 context: Route.LoaderArgs["context"],
156): Promise<ShellData> {
157 const memberships = user.workspaces ?? [];
158 const workspace = workspaceFor(memberships, chosen, params);
159 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
160 const now = new Date();
161 const monthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
162 // What the sidebar shows of the workspace changes rarely: kept for a few
163 // seconds per person and workspace, except just after they changed
164 // something (lib/cache.server.ts).
165 const kept = <T,>(what: string, load: () => Promise<T>) =>
166 workspace ? shortCache(`shell:${what}:${user.id}:${workspace.slug}`, SHELL_TTL_MS, load) : Promise.resolve(null);
167 const [listed, counts, status, usage, limit, entitlements, shared, unread, shortcuts] = await Promise.all([
168 // Every project, for the palette and the count; the sidebar lists only
169 // the person's pinned and recent ones (lib/pins.ts).
170 workspace ? workspaceProjects(workspace.slug, user) : Promise.resolve(null),
171 path ? countsFor(context, params) : Promise.resolve(null),
172 // Whether billing is on, without reading the account: that asks the
173 // card processor about the workspace's cards, too slow for every page.
174 kept("status", () => billing.status()).catch(() => null),
175 kept(`usage:${monthStart}`, () => billing.usage(workspace!.slug, user, monthStart)).catch(() => null),
176 kept("limit", () => billing.limit(workspace!.slug, user)).catch(() => null),
177 kept("entitlements", () => billing.entitlements(workspace!.slug)).catch(() => null),
178 sharedRepos(user),
179 // The bell's count: one query, never kept, so marking an item shows at once.
180 inbox.counts(user.username).catch(() => null),
181 // Never kept: opening a project moves it up Recent.
182 workspace ? projects.shortcuts(workspace.slug, user).catch(() => null) : Promise.resolve(null),
183 ]);
184 return {
185 workspace,
186 // Projects are what the sidebar lists: what the workspace builds and runs.
187 repos: listed?.ok ? listed.value.map(shortcutOf) : [],
188 pinned: (shortcuts?.pinned ?? []).map(shortcutOf),
189 recent: (shortcuts?.recent ?? []).map(shortcutOf),
190 repo:
191 path && counts?.ok
192 ? {
193 ...path,
194 // Until the repository's own page says what their role is.
195 member: hasAccessIn(user, path.namespace),
196 issues: counts.value.issues,
197 pulls: counts.value.pulls,
198 }
199 : null,
200 // Where the workspace stands against its usage limit, once billing is on.
201 limit:
202 status?.enabled && limit?.ok
203 ? {
204 exposureMicros: limit.value.exposureMicros,
205 ceilingMicros: limit.value.ceilingMicros,
206 state: limit.value.state,
207 comped: limit.value.trust === "internal",
208 }
209 : null,
210 free: Boolean(status?.free),
211 // A spend spike or a hold pauses new compute: the shell says so on every page.
212 compute:
213 workspace && entitlements && (entitlements.paused || entitlements.spike?.status === "open")
214 ? { paused: entitlements.paused, spike: entitlements.spike ?? null, owner: workspace.role === "owner" }
215 : null,
216 shared,
217 inbox: unread,
218 // While g1t is free every charge is zero, so usage is shown at cost.
219 // Usage at price, the one figure every page shows.
220 monthUsageMicros: usage?.ok ? (usage.value.free ? usage.value.usedMicros : (usage.value.priceMicros ?? usage.value.spentMicros)) : null,
221 };
222}
223
224/**
225 * How long the sidebar's workspace answers are kept: as long as someone's
226 * own changes read fresh anyway (lib/perf.ts `PRIMARY_WINDOW_SECONDS`).
227 */
228const SHELL_TTL_MS = 30_000;
229
230/** Most repositories listed under Shared with you. */
231const MAX_SHARED = 20;
232
233/**
234 * Repositories shared with the user in workspaces they do not belong to,
235 * by their grants: only those, never the workspace's other repositories.
236 */
237async function sharedRepos(user: User): Promise<ShellData["shared"]> {
238 const outside = new Set(sharedWorkspaces(user));
239 if (outside.size === 0) return [];
240 const ids = (user.grants ?? []).filter((grant) => outside.has(grant.workspace)).map((grant) => grant.repo_id).slice(0, MAX_SHARED);
241 const found = await readableRepos(ids, user);
242 return found
243 .map((repo) => ({ namespace: repo.namespace, name: repo.name, isPrivate: repo.isPrivate }))
244 .sort((a, b) => `${a.namespace}/${a.name}`.localeCompare(`${b.namespace}/${b.name}`));
245}
246
247function HeaderLink({ to, children }: { to: string; children: React.ReactNode }) {
248 return (
249 <NavLink
250 to={to}
251 className={({ isActive }) =>
252 `rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-raised hover:text-fg ${
253 isActive ? "text-fg" : "text-muted"
254 }`
255 }
256 >
257 {children}
258 </NavLink>
259 );
260}
261
262/** What the palette offers someone without the app's sidebar. */
263const PUBLIC_COMMANDS: PaletteCommand[] = [
264 { label: "Explore", hint: "Public projects", to: "/explore", icon: <Compass size={15} /> },
265 { label: "Search g1t", hint: "Repositories, code, issues, people", to: "/search", icon: <Search size={15} /> },
266 { label: "Pricing", to: "/pricing", icon: <CreditCard size={15} /> },
267 { label: "Documentation", to: "https://docs.g1t.sh/", icon: <BookOpen size={15} /> },
268 { label: "Sign in", to: "/login", icon: <LogIn size={15} /> },
269 { label: "Sign up", to: "/register", icon: <Plus size={15} /> },
270];
271
272/** Sign up, or Request access while g1t is invite-only. */
273function SignUpButton() {
274 const copy = useSignUpCopy();
275 return <ButtonLink to="/register">{copy.primary}</ButtonLink>;
276}
277
278function Header({ user }: { user: User | null | undefined }) {
279 const submit = useSubmit();
280 const signUp = useSignUpCopy();
281 const [palette, setPalette] = useState(false);
282 usePaletteShortcut(() => setPalette((open) => !open));
283 const params = useParams();
284 const repo = params.owner && params.repo ? `${params.owner}/${params.repo}` : null;
285 return (
286 <header className="sticky top-0 z-40 border-b border-line bg-surface/85 backdrop-blur">
287 <div className="mx-auto flex h-14 max-w-6xl items-center gap-2 px-4">
288 <Link to="/" aria-label="g1t home" className="mr-2 flex">
289 <Logo />
290 </Link>
291 <Form action="/search" role="search" className="relative hidden grow sm:block sm:max-w-xs">
292 <Search
293 size={14}
294 className="pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-faint"
295 />
296 <input
297 name="q"
298 {...notACredential()}
299 placeholder="Search g1t"
300 aria-label="Search g1t"
301 className="w-full rounded-md border border-line bg-bg py-1.5 pr-12 pl-8 text-sm outline-none transition-colors placeholder:text-faint hover:border-line-strong focus:border-accent-dim"
302 />
303 <PaletteKey className="pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded bg-raised px-1.5 font-mono text-[0.625rem] text-muted ring-1 ring-line" />
304 </Form>
305 <button
306 type="button"
307 aria-label="Search g1t"
308 onClick={() => setPalette(true)}
309 className="flex size-10 items-center justify-center rounded-md text-muted transition-colors hover:bg-raised hover:text-fg sm:hidden"
310 >
311 <Search size={18} />
312 </button>
313 <CommandPalette
314 open={palette}
315 onOpenChange={setPalette}
316 commands={user ? [{ label: "Mission control", to: "/", icon: <LayoutDashboard size={15} /> }, ...PUBLIC_COMMANDS.slice(0, 4)] : PUBLIC_COMMANDS.map((command) => (command.to === "/register" ? { ...command, label: signUp.primary } : command))}
317 repo={repo}
318 />
319 <nav aria-label="Main" className="hidden items-center gap-0.5 sm:flex">
320 <HeaderLink to="/explore">Explore</HeaderLink>
321 <HeaderLink to="/pricing">Pricing</HeaderLink>
322 <HeaderLink to="https://docs.g1t.sh/">Docs</HeaderLink>
323 </nav>
324 <div className="ml-auto flex items-center gap-2">
325 {/* On a phone the links fold into one menu, so the bar fits. */}
326 <DropdownMenu>
327 <DropdownMenuTrigger
328 aria-label="Menu"
329 className="flex size-10 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-raised hover:text-fg focus-visible:ring-2 focus-visible:ring-accent data-[state=open]:bg-raised data-[state=open]:text-fg sm:hidden"
330 >
331 <Menu size={18} />
332 </DropdownMenuTrigger>
333 <DropdownMenuContent align="end" className="w-52">
334 <DropdownMenuItem asChild className="min-h-11">
335 <Link to="/explore">
336 <Compass />
337 Explore
338 </Link>
339 </DropdownMenuItem>
340 <DropdownMenuItem asChild className="min-h-11">
341 <Link to="/pricing">
342 <CreditCard />
343 Pricing
344 </Link>
345 </DropdownMenuItem>
346 <DropdownMenuItem asChild className="min-h-11">
347 <Link to="https://docs.g1t.sh/">
348 <BookOpen />
349 Docs
350 </Link>
351 </DropdownMenuItem>
352 {!user && (
353 <>
354 <DropdownMenuSeparator />
355 <DropdownMenuItem asChild className="min-h-11">
356 <Link to="/login">
357 <LogIn />
358 Sign in
359 </Link>
360 </DropdownMenuItem>
361 </>
362 )}
363 </DropdownMenuContent>
364 </DropdownMenu>
365 {user ? (
366 <>
367 <Link
368 to="/new"
369 aria-label="New project"
370 className="rounded-md border border-line p-1.5 text-muted transition-colors hover:border-line-strong hover:text-fg"
371 >
372 <Plus size={16} />
373 </Link>
374 <DropdownMenu>
375 <DropdownMenuTrigger
376 aria-label="Account menu"
377 className="flex items-center gap-1.5 rounded-md p-1 outline-none transition-colors hover:bg-raised focus-visible:ring-2 focus-visible:ring-accent data-[state=open]:bg-raised"
378 >
379 <Avatar name={user.username} image={user.avatar} size={24} />
380 <ChevronDown size={14} className="text-faint" />
381 </DropdownMenuTrigger>
382 <DropdownMenuContent align="end" className="w-56">
383 <DropdownMenuLabel>
384 Signed in as{" "}
385 <span className="font-mono font-medium text-fg">
386 {user.username}
387 </span>
388 </DropdownMenuLabel>
389 <DropdownMenuSeparator />
390 {(user.workspaces ?? []).map((membership) => (
391 <DropdownMenuItem asChild key={membership.slug}>
392 <Link to={`/${membership.slug}`}>
393 <Avatar name={membership.slug} image={membership.avatar} size={16} square />
394 <span className="min-w-0 truncate">{membership.name || membership.slug}</span>
395 </Link>
396 </DropdownMenuItem>
397 ))}
398 <DropdownMenuItem asChild>
399 <Link to="/workspaces/new">
400 <Plus />
401 New workspace
402 </Link>
403 </DropdownMenuItem>
404 <DropdownMenuSeparator />
405 <DropdownMenuItem asChild>
406 <Link to="/">
407 <LayoutDashboard />
408 Mission control
409 </Link>
410 </DropdownMenuItem>
411 <DropdownMenuItem asChild>
412 <Link to="/new">
413 <Plus />
414 New project
415 </Link>
416 </DropdownMenuItem>
417 <DropdownMenuSeparator />
418 <DropdownMenuItem asChild>
419 <Link to="/settings/profile">
420 <Settings />
421 Settings
422 </Link>
423 </DropdownMenuItem>
424 <DropdownMenuItem asChild>
425 <Link to="https://docs.g1t.sh/quickstart/">
426 <BookOpen />
427 Documentation
428 </Link>
429 </DropdownMenuItem>
430 <DropdownMenuSeparator />
431 {/* Submitted from here: the menu closes on select, and a button
432 that has left the page cannot submit a form. */}
433 <DropdownMenuItem
434 onSelect={() => submit(null, { method: "post", action: "/logout" })}
435 >
436 <LogOut />
437 Sign out
438 </DropdownMenuItem>
439 </DropdownMenuContent>
440 </DropdownMenu>
441 </>
442 ) : (
443 <>
444 <span className="hidden sm:contents">
445 <HeaderLink to="/login">Sign in</HeaderLink>
446 </span>
447 <SignUpButton />
448 </>
449 )}
450 </div>
451 </div>
452 </header>
453 );
454}
455
456/**
457 * The root's data as the browser last had it. When a navigation fails in a
458 * way that takes the root's data with it, the error is still drawn in the
459 * person's own frame, signed in, not the visitor's. Never kept on the
460 * server, where one module serves everyone.
461 */
462let lastRoot: Awaited<ReturnType<typeof loader>> | undefined;
463
464export function Layout({ children }: { children: React.ReactNode }) {
465 // Undefined when the root loader itself failed.
466 const loaded = useRouteLoaderData<typeof loader>("root");
467 const inBrowser = typeof document !== "undefined";
468 if (loaded && inBrowser) lastRoot = loaded;
469 const root = loaded ?? (inBrowser ? lastRoot : undefined);
470 const user = root?.user;
471 const { pathname, search } = useLocation();
472 // Drawn around the error page too: a 404 keeps the sidebar out of a
473 // project or workspace the viewer cannot see.
474 const error = useRouteError();
475 const missing = isRouteErrorResponse(error) && error.status === 404;
476 // The billing page shows the full banner itself.
477 const paused = root?.shell?.compute && root.shell.workspace && !pathname.endsWith("/-/billing") && (
478 <SpikeBanner
479 compact
480 slug={root.shell.workspace.slug}
481 entitlements={{ paused: root.shell.compute.paused, spike: root.shell.compute.spike }}
482 owner={root.shell.compute.owner}
483 />
484 );
485 // On the few pages an account still confirming its address can open
486 // besides /confirm-email (policies, support, signing in): the way back.
487 const verify = user && awaitsConfirmation(user) && pathname !== "/confirm-email" && (
488 <p
489 role="status"
490 className="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-b border-warn/30 bg-warn/10 px-4 py-2 text-sm"
491 >
492 <span>Confirm your email address to start using g1t.</span>
493 <Link to="/confirm-email" className="font-medium underline underline-offset-4">
494 Enter your code
495 </Link>
496 </p>
497 );
498 // A workspace that requires two-factor authentication of someone who
499 // has not turned it on: they keep their place, and cannot use it yet.
500 const held = user?.held && user.held.length > 0 && pathname !== "/settings/two-factor" && <PolicyNotice held={user.held} />;
501 const leaving = useLeaving();
502 const banner =
503 paused || verify || held ? (
504 <>
505 {paused}
506 {verify}
507 {held}
508 </>
509 ) : null;
510 return (
511 <html lang="en">
512 <head>
513 <meta charSet="utf-8" />
514 <meta name="viewport" content="width=device-width, initial-scale=1" />
515 <meta name="theme-color" content="#0f0f11" />
516 {/* The stylesheet before everything React Router preloads, so a slow
517 connection paints sooner (docs/research/css-shipping.md). */}
518 <link rel="stylesheet" href={appCss} precedence="default" />
519 <Meta />
520 <Links />
521 </head>
522 <body className="flex min-h-screen flex-col">
523 {/* The first stop for the keyboard: past the menus, to the page. */}
524 <a
525 href="#content"
526 className="sr-only rounded-md bg-fg px-3 py-2 text-sm font-medium text-bg focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[70]"
527 >
528 Skip to content
529 </a>
530 {root?.shell && usesAppShell(pathname, user != null && !awaitsConfirmation(user)) ? (
531 <AppShell user={user ?? null} shell={root.shell} missing={missing} banner={banner}>
532 {children}
533 </AppShell>
534 ) : (
535 <>
536 <Progress />
537 <Header user={user} />
538 {banner}
539 <div id="content" tabIndex={-1} {...leaving} className={`grow outline-none ${leaving.className}`}>
540 {children}
541 </div>
542 <SiteFooter user={user} />
543 </>
544 )}
545 <ScrollRestoration />
546 <Scripts />
547 </body>
548 </html>
549 );
550}
551
552export default function App() {
553 return <Outlet />;
554}
555
556export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
557 const location = useLocation();
558 const matches = useMatches();
559 // A tab left open across a deploy: load the address again as a whole
560 // page, once, rather than show an error the reload fixes.
561 const reload = reloadFixes({
562 error,
563 status: isRouteErrorResponse(error) ? error.status : undefined,
564 // The first page a tab loads has the key "default"; a client navigation's is its own.
565 clientNavigation: location.key !== "default",
566 caughtByCatchAll: matches.at(-1)?.id === "routes/not-found",
567 });
568 const href = location.pathname + location.search + location.hash;
569 useEffect(() => {
570 if (!reload) return;
571 try {
572 if (sessionStorage.getItem(RELOADED_KEY) === href) return;
573 sessionStorage.setItem(RELOADED_KEY, href);
574 } catch {
575 // No session storage: reload anyway; a document load never asks again.
576 }
577 window.location.assign(href);
578 }, [reload, href]);
579 if (reload) {
580 return (
581 <main className="mx-auto max-w-xl px-4 py-32 text-center text-sm text-muted" aria-busy="true">
582 <title>Loading · g1t</title>
583 Loading the latest version of g1t…
584 </main>
585 );
586 }
587
588 let title = "Something went wrong";
589 let details = "An unexpected error occurred. Try again in a moment.";
590 let stack: string | undefined;
591
592 if (isRouteErrorResponse(error)) {
593 // The same page for something private and something missing.
594 if (error.status === 404) {
595 return (
596 <>
597 <title>Not found · g1t</title>
598 <NotFound data={error.data} />
599 </>
600 );
601 }
602 if (typeof error.data === "string" && error.data) {
603 details = error.data;
604 }
605 } else if (import.meta.env.DEV && error instanceof Error) {
606 details = error.message;
607 stack = error.stack;
608 }
609
610 return (
611 <main className="mx-auto max-w-xl px-4 py-32 text-center">
612 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
613 <p className="mt-3 text-muted">{details}</p>
614 <div className="mt-8">
615 <ButtonLink to="/" variant="quiet">
616 Back to home
617 </ButtonLink>
618 </div>
619 {stack && (
620 <pre className="mt-8 overflow-x-auto rounded-lg border border-line p-4 text-left text-xs">
621 <code>{stack}</code>
622 </pre>
623 )}
624 </main>
625 );
626}