diff --git a/CLAUDE.md b/CLAUDE.md
index 41d4cf9e..10dcf6de 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -24,7 +24,7 @@ The repository holds one Next.js app that serves two sites:
How the two sites share the app:
-- **Hosts.** bench's routes are under `/bench`. `next.config.mjs` rewrites every path on bench.vortex.dev onto `/bench`, before the filesystem, so bench's public URLs are the root paths they always were (`/`, `/chart/{slug}`, `/api/…`). Previews, local dev and a deployment's own URL serve bench at `/bench`. vortex.dev and www.vortex.dev do not: `/bench` 404s there, except `/bench/api/health`, which the Vercel cron may call on any of the deployment's hosts. bench builds every root-relative link and fetch with `benchPath()` (`src/bench/lib/base-path.ts`): bench's root layout reads the request's host and hands the base to client components (`src/bench/components/BenchBase.tsx`).
+- **Hosts.** bench's routes are under `/bench`. `next.config.mjs` rewrites every path on bench.vortex.dev onto `/bench`, before the filesystem, so bench's public URLs are the root paths they always were (`/`, `/chart/{slug}`, `/api/…`). Previews, local dev and a deployment's own URL serve bench at `/bench`. vortex.dev and www.vortex.dev do not: `/bench` 404s there, except `/bench/api/health`, which the Vercel cron may call on any of the deployment's hosts. bench builds every root-relative link and fetch with `benchPath()` (`src/bench/lib/base-path.ts`): bench's root layout reads the request's host and hands the base to client components (`src/bench/components/BenchBase.tsx`). The site's links to bench go through `benchHref()` (`src/lib/bench-link.ts`): https://bench.vortex.dev on production (`VERCEL_ENV`, which `next.config.mjs` embeds at build time), and the deployment's own `/bench` everywhere else, so a preview's links stay on the preview.
- **Root layouts.** Each site has its own, so Next.js has none to draw an unmatched URL's 404 in. `src/app/global-not-found.tsx` (`experimental.globalNotFound`) is the site's 404, in the site's layout, prerendered for every unmatched URL; a catch-all route (`src/app/(bench)/bench/[...notFound]`) keeps bench's unmatched paths out of it. bench has no `not-found.tsx`, so those paths get Next.js's default 404 document, with bench's metadata but without bench's layout. `robots.ts` stays at the app root, where Next.js reads it; the favicon is `public/favicon.ico`, named in the site's metadata, because the `app/favicon.ico` convention would also put it on bench's pages. Next.js serves a metadata image route inside a route group with a hash suffix (`/opengraph-image-12o0cb`), and the og:image tags name that URL; rewrites in `next.config.mjs` keep the plain `/opengraph-image` URLs (which the posts' JSON-LD names) serving the same images.
- **Headers.** The CSP and the other security headers in `next.config.mjs` cover both sites: one policy, since both self-host their fonts. bench now sends the site's security headers, including `X-Frame-Options: DENY` and `frame-ancestors 'none'`, so no other site can embed bench's pages in a frame. `vercel.json` holds bench's cron (`/bench/api/health`) and bench's CDN rule for its landing, chart, and methodology pages on bench.vortex.dev (header rules match the path as requested, before the rewrites). bench's HTML differs between its two URL forms, so the `/bench` form gets the CDN rule only outside production (`benchPrefixCdnRules` in `next.config.mjs`): a cached `/bench` page must never answer for bench.vortex.dev.
- **Toolchain.** One package: one `package.json`, one `bun.lock`, one `bunfig.toml`, one `tsconfig.json`. Next.js 16.4.1, React 19.3 and TypeScript 7. `tsconfig.json` has every strict flag either app had, including bench's `noFallthroughCasesInSwitch` and `noUncheckedSideEffectImports`; `src/css.d.ts` types the CSS side-effect imports. The root `biome.json` lints and formats both sites: an override keeps bench's files (`src/bench`, `src/app/(bench)`, the parity and deploy checks, `vitest.config.ts`) in bench's old Prettier style (single quotes, trailing commas, 100 columns) with bench's lint rules (see "bench" below), and `bun run check:ci` checks all of it. bench's tests run on Vitest from the root `vitest.config.ts`, scoped to bench's files; the site's run on `bun test`. bench's PostCSS config sits beside its stylesheets (`src/bench/styles/postcss.config.mjs`), and Turbopack applies it to those alone: with no config at the root, the site's CSS gets Turbopack's defaults.
diff --git a/next.config.mjs b/next.config.mjs
index 2a2ebdb4..7d37ae4b 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -87,7 +87,11 @@ const nextConfig = wrapWithPlausible({
// deployed build however the runtime is configured. Vercel sets the
// variable during its builds.
env: {
- VERCEL_GIT_COMMIT_SHA: process.env.VERCEL_GIT_COMMIT_SHA ?? "unknown"
+ VERCEL_GIT_COMMIT_SHA: process.env.VERCEL_GIT_COMMIT_SHA ?? "unknown",
+ // Which deployment this is, for the site's links to bench
+ // (src/lib/bench-link.ts): bench.vortex.dev on production, this
+ // deployment's /bench elsewhere. Embedded so client components see it.
+ VERCEL_ENV: process.env.VERCEL_ENV ?? ""
},
async headers() {
return [
diff --git a/src/components/results-table/index.tsx b/src/components/results-table/index.tsx
index 2738fc5a..573df868 100644
--- a/src/components/results-table/index.tsx
+++ b/src/components/results-table/index.tsx
@@ -1,9 +1,8 @@
import { OpenInNewIcon } from "@/components/icons";
+import { benchHref } from "@/lib/bench-link";
import { formatReadDate, type Panel } from "@/lib/bench-summary";
import { resultsRow, resultsSystems } from "@/vendor/vortex-design/results.js";
-const SOURCE_URL = "https://bench.vortex.dev";
-
const classes = (...names: (string | false)[]) =>
names.filter(Boolean).join(" ") || undefined;
@@ -31,7 +30,7 @@ export function ResultsTable({
File format benchmarks
-
+
bench.vortex.dev
diff --git a/src/lib/bench-link.ts b/src/lib/bench-link.ts
new file mode 100644
index 00000000..1343ee00
--- /dev/null
+++ b/src/lib/bench-link.ts
@@ -0,0 +1,24 @@
+/** bench's public address, which production's links name. */
+const BENCH_ORIGIN = "https://bench.vortex.dev";
+
+/**
+ * A link from the site to a bench page (`""` or `/` for the landing page,
+ * `/methodology`, `/chart/{slug}`, …). Production links to bench.vortex.dev,
+ * where bench is served from the root. Every other deployment (a preview, a
+ * local build) serves bench under `/bench` on its own host, so its links stay
+ * on that deployment rather than leaving for production. `next.config.mjs`
+ * embeds `VERCEL_ENV` at build time, so a client component agrees with the
+ * server render.
+ */
+export function benchHref(
+ path = "",
+ vercelEnv: string | undefined = process.env.VERCEL_ENV
+): string {
+ if (path !== "" && !path.startsWith("/")) {
+ throw new Error(`benchHref takes a root-relative path, not ${path}`);
+ }
+ if (vercelEnv === "production") {
+ return `${BENCH_ORIGIN}${path}`;
+ }
+ return path === "" || path === "/" ? "/bench" : `/bench${path}`;
+}
diff --git a/src/lib/faq.ts b/src/lib/faq.ts
index ac0e22f6..05950013 100644
--- a/src/lib/faq.ts
+++ b/src/lib/faq.ts
@@ -1,3 +1,4 @@
+import { benchHref } from "@/lib/bench-link";
import { formatReadDate, type Panel } from "@/lib/bench-summary";
import { baseUrl } from "@/lib/constants";
import { GPU_DETAIL, GPU_PANEL } from "@/lib/gpu-result";
@@ -12,7 +13,6 @@ import {
const REPO = "https://github.com/vortex-data/vortex";
const DOCS = "https://docs.vortex.dev";
-const BENCH = "https://bench.vortex.dev";
// What each speed panel measures, in a few words, by panel title
// (bench-summary.ts and gpu-result.ts), for the answer that says where
@@ -163,8 +163,8 @@ export function faqs({
}),
...(hasGpu && { after: [GPU_DETAIL] }),
links: [
- { href: `${BENCH}/`, label: "Every benchmark on bench.vortex.dev" },
- { href: `${BENCH}/methodology`, label: "How the benchmarks run" }
+ { href: benchHref("/"), label: "Every benchmark on bench.vortex.dev" },
+ { href: benchHref("/methodology"), label: "How the benchmarks run" }
]
},
{
@@ -219,7 +219,7 @@ export function faqs({
"Both formats are under the Apache License 2.0. Vortex is a Linux Foundation project. LF Projects, part of the Linux Foundation, holds the Vortex trademark, and the charter keeps the project's code under the Apache License. Changing the charter takes a two-thirds vote of the Technical Steering Committee and the approval of LF Projects. Lance has its own governance, but the name and code are held by a private company (LanceDB) instead of an independent foundation."
],
links: [
- { href: `${BENCH}/`, label: "Every benchmark on bench.vortex.dev" },
+ { href: benchHref("/"), label: "Every benchmark on bench.vortex.dev" },
{
href: `${baseUrl}/charter.pdf`,
label: "The Vortex Technical Charter"
diff --git a/src/lib/nav.ts b/src/lib/nav.ts
index 27b8c0cc..fe5a19f7 100644
--- a/src/lib/nav.ts
+++ b/src/lib/nav.ts
@@ -16,6 +16,8 @@ export type NavLink = {
current: "page" | "true" | null;
};
+import { benchHref } from "@/lib/bench-link";
+
const SITE = "https://vortex.dev";
/**
@@ -40,7 +42,7 @@ export function navLinks(
},
{
label: "Benchmarks",
- href: bench ? bench.home : "https://bench.vortex.dev",
+ href: bench ? bench.home : benchHref(),
internal: false,
current: bench ? (benchLanding ? "page" : "true") : null
},
diff --git a/tests/smoke.spec.ts b/tests/smoke.spec.ts
index 664e3847..e8827404 100644
--- a/tests/smoke.spec.ts
+++ b/tests/smoke.spec.ts
@@ -1,6 +1,10 @@
import { expect, type Page, test } from "@playwright/test";
import { externalPosts } from "../src/content/links";
+// The site's links to bench (src/lib/bench-link.ts): bench.vortex.dev on
+// production, the deployment's own /bench on a preview or a local build.
+const BENCH_HREF = /^(https:\/\/bench\.vortex\.dev|\/bench)$/;
+
/**
* Browser smoke tests. Structural and behavioral checks against a real
* browser engine — catches regressions the HTTP-only verify script can't
@@ -197,8 +201,10 @@ test.describe("home bands", () => {
await expect(table.locator("tbody tr")).toHaveCount(7);
await expect(table.locator("tbody td.is-ours")).toHaveCount(7);
await expect(table).toContainText(/read \d+ \w{3} \d{4}/);
- const source = table.locator('a[href="https://bench.vortex.dev"]');
+ // bench.vortex.dev on production, this deployment's /bench elsewhere.
+ const source = table.locator("a.vx-source");
await expect(source).toBeVisible();
+ await expect(source).toHaveAttribute("href", BENCH_HREF);
await expect(source).toHaveText("bench.vortex.dev");
});
@@ -533,7 +539,7 @@ test.describe("header", () => {
const nav = page.getByRole("navigation", { name: "Primary" });
for (const [name, href] of [
["Docs", "https://docs.vortex.dev"],
- ["Benchmarks", "https://bench.vortex.dev"],
+ ["Benchmarks", BENCH_HREF],
["Explorer", "https://explore.vortex.dev"],
["Blog", "/blog"]
] as const) {
diff --git a/tests/unit/bench-link.test.ts b/tests/unit/bench-link.test.ts
new file mode 100644
index 00000000..fdc1e65b
--- /dev/null
+++ b/tests/unit/bench-link.test.ts
@@ -0,0 +1,26 @@
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+import { benchHref } from "@/lib/bench-link";
+
+describe("benchHref", () => {
+ it("names bench.vortex.dev on production", () => {
+ assert.equal(benchHref("", "production"), "https://bench.vortex.dev");
+ assert.equal(benchHref("/", "production"), "https://bench.vortex.dev/");
+ assert.equal(
+ benchHref("/methodology", "production"),
+ "https://bench.vortex.dev/methodology"
+ );
+ });
+
+ it("stays on the deployment's /bench everywhere else", () => {
+ for (const env of ["preview", "development", "", undefined]) {
+ assert.equal(benchHref("", env), "/bench");
+ assert.equal(benchHref("/", env), "/bench");
+ assert.equal(benchHref("/methodology", env), "/bench/methodology");
+ }
+ });
+
+ it("refuses a path that is not root-relative", () => {
+ assert.throws(() => benchHref("methodology", "production"));
+ });
+});
diff --git a/tests/unit/nav.test.ts b/tests/unit/nav.test.ts
index 4aadea79..97c87164 100644
--- a/tests/unit/nav.test.ts
+++ b/tests/unit/nav.test.ts
@@ -24,7 +24,8 @@ describe("navLinks", () => {
"Explorer",
"Blog"
]);
- assert.equal(links.Benchmarks?.href, "https://bench.vortex.dev");
+ // Outside production, the deployment's own /bench (bench-link.ts).
+ assert.equal(links.Benchmarks?.href, "/bench");
assert.equal(links.Blog?.href, "/blog");
assert.equal(links.Blog?.internal, true);
assert.equal(links.Blog?.current, "page");
diff --git a/tests/unit/results-table.test.tsx b/tests/unit/results-table.test.tsx
index 7b7e8ea9..9c91c21c 100644
--- a/tests/unit/results-table.test.tsx
+++ b/tests/unit/results-table.test.tsx
@@ -4,6 +4,7 @@ import { describe, it } from "node:test";
import { renderToStaticMarkup } from "react-dom/server";
import { OpenInNewIcon } from "@/components/icons";
import { ResultsTable } from "@/components/results-table";
+import { benchHref } from "@/lib/bench-link";
import { formatReadDate, panelsFrom } from "@/lib/bench-summary";
import { renderResults } from "@/vendor/vortex-design/results.js";
@@ -26,10 +27,12 @@ describe("ResultsTable", () => {
const html = renderToStaticMarkup(
);
+ // The system names bench.vortex.dev; the site names it on production
+ // and its own /bench elsewhere (bench-link.ts), the one difference.
const system = renderResults(PANELS, {
read: formatReadDate(READ),
icon: renderToStaticMarkup()
- });
+ }).replace('href="https://bench.vortex.dev"', `href="${benchHref()}"`);
assert.equal(html, system);
});