mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-27 09:19:53 +00:00
The docs estate declared its typeface in 30 root layouts and one linked stylesheet, each pulling a third-party family off a hosted font CDN on the critical path of every route. Two of those surfaces also self-hosted the faces, so the same bytes were vendored by hand in the repo. @hanzo/font 1.8.8 is where Zen is authored. It is now mounted the way this repo already mounts every other package stylesheet — `@import '@hanzo/font/css'` at the top of the app's own sheet — which declares the @font-face rules and publishes --font-zen-sans / --font-zen-mono. A single :root block per app binds those to --font-sans / --font-mono, the pair every rule and every font-* utility already read, so the variable contract is untouched and the next face swap is two lines rather than a sweep. Genuine system fallbacks stay. Mounting through the sheet rather than a JS side-effect import also drops the untyped bare subpath TypeScript could not resolve, so no per-app declaration shim is needed. public/reference/ is static HTML with no bundler, so it keeps its own @font-face; scripts/sync-reference-fonts.ts copies the two variable faces out of the installed package on each build and the directory is ignored, the same rule public/openapi/ already follows. The hand-vendored faces are deleted. Also corrects the brand typography table, which still named a face Hanzo does not ship, and the three sample configs and two skill pages that repeated it.
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import {
|
|
isRouteErrorResponse,
|
|
Links,
|
|
Meta,
|
|
Outlet,
|
|
Scripts,
|
|
ScrollRestoration,
|
|
} from 'react-router';
|
|
import { RootProvider } from '@hanzo/docs-ui/provider/react-router';
|
|
import type { Route } from './+types/root';
|
|
import './app.css';
|
|
import { isMarkdownPreferred, rewritePath } from '@hanzo/docs-core/negotiation';
|
|
import NotFound from './routes/not-found';
|
|
import { docsContentRoute, docsRoute } from '@/lib/shared';
|
|
|
|
export function Layout({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<html lang="en" suppressHydrationWarning>
|
|
<head>
|
|
<meta charSet="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<Meta />
|
|
<Links />
|
|
</head>
|
|
<body className="flex flex-col min-h-screen">
|
|
<RootProvider>{children}</RootProvider>
|
|
<ScrollRestoration />
|
|
<Scripts />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|
|
|
|
export default function App() {
|
|
return <Outlet />;
|
|
}
|
|
|
|
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
let message = 'Oops!';
|
|
let details = 'An unexpected error occurred.';
|
|
let stack: string | undefined;
|
|
|
|
if (isRouteErrorResponse(error)) {
|
|
if (error.status === 404) return <NotFound />;
|
|
message = 'Error';
|
|
details = error.statusText;
|
|
} else if (import.meta.env.DEV && error && error instanceof Error) {
|
|
details = error.message;
|
|
stack = error.stack;
|
|
}
|
|
|
|
return (
|
|
<main className="pt-16 p-4 w-full max-w-[1400px] mx-auto">
|
|
<h1>{message}</h1>
|
|
<p>{details}</p>
|
|
{stack && (
|
|
<pre className="w-full p-4 overflow-x-auto">
|
|
<code>{stack}</code>
|
|
</pre>
|
|
)}
|
|
</main>
|
|
);
|
|
}
|
|
|
|
const { rewrite: rewriteDocs } = rewritePath(
|
|
`${docsRoute}{/*path}`,
|
|
`${docsContentRoute}{/*path}/content.md`,
|
|
);
|
|
const { rewrite: rewriteSuffix } = rewritePath(
|
|
`${docsRoute}{/*path}.md`,
|
|
`${docsContentRoute}{/*path}/content.md`,
|
|
);
|
|
const serverMiddleware: Route.MiddlewareFunction = async ({ request }, next) => {
|
|
const url = new URL(request.url);
|
|
const suffixPath = rewriteSuffix(url.pathname);
|
|
if (suffixPath) return Response.redirect(new URL(suffixPath, url));
|
|
|
|
if (isMarkdownPreferred(request)) {
|
|
const docsPath = rewriteDocs(url.pathname);
|
|
if (docsPath) return Response.redirect(new URL(docsPath, url));
|
|
}
|
|
|
|
return next();
|
|
};
|
|
export const middleware = [serverMiddleware];
|