Skip to content

Commit 7053107

Browse files
angusbezzinaclaude
andcommitted
refactor(web): one source for the canonical origin, and document the move
vite.config.ts and src/config.ts each held their own copy of https://annotkit.gpu-cli.sh. They are read in different build contexts — Node at build time, the browser at runtime — so nothing forced them to agree, and changing one without the other would ship a canonical tag and an OG url pointing at different hosts. Both now import shared/site.ts. Also documents the domain move, which was only half-covered: the README listed VITE_SITE_URL in two config tables but never said what a domain change actually costs. It is three edits — the shared constant, the footer text in scripts/og-template.html (baked into og.png, so re-run npm run og), and the two README backlinks. Notes the honest non-answer too: package.json's description and the request URLs in tests/subscribe.test.ts mention the domain and neither matters, so nobody has to wonder whether they do. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d0b6830 commit 7053107

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

web/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,30 @@ at `<branch>.annotkit.pages.dev`.
189189
Secrets are not part of a deploy. `wrangler pages secret put` writes them once
190190
per environment (see above), and they persist across deployments.
191191

192+
## Moving to a different domain
193+
194+
Nothing in the build needs to change to *launch* on `annotkit.gpu-cli.sh`
195+
that is already the default, so the canonical and OpenGraph tags point at the
196+
final domain even while the site is served from `*.pages.dev`. That is
197+
deliberate: it stops the pages.dev URL being indexed as a duplicate.
198+
199+
Changing to a **different** domain later is three edits and a re-render:
200+
201+
1. `shared/site.ts``DEFAULT_SITE_URL`. One constant, imported by both
202+
`vite.config.ts` (which substitutes `%SITE_URL%` into index.html) and
203+
`src/config.ts` (which hands it to the components). They used to hold a
204+
copy each, which is exactly how a canonical tag and an OG url end up
205+
disagreeing.
206+
2. `scripts/og-template.html` — the domain is printed as footer text on the
207+
card. Change it, then `npm run og` to re-render `public/og.png`.
208+
3. The root `README.md` backlink, and this file's first line.
209+
210+
Then add the custom domain to the Pages project and point a CNAME at it.
211+
212+
`web/package.json`'s `description` and the request URLs in
213+
`tests/subscribe.test.ts` also mention the domain; neither is load-bearing
214+
(the tests only need a well-formed absolute URL to build a `Request`).
215+
192216
## Design
193217

194218
Hallmark, genre **editorial**: macrostructure **Specimen**, theme **Specimen**,

web/shared/site.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The canonical origin, in one place.
3+
*
4+
* Two build contexts need it and they cannot see each other's globals:
5+
* `vite.config.ts` substitutes it into index.html at build time (Node), and
6+
* `src/config.ts` hands it to the components (browser). Holding a copy in
7+
* each is how the canonical tag and the OG url end up disagreeing after a
8+
* domain change, so both import this.
9+
*
10+
* `VITE_SITE_URL` overrides it per environment; this is only the fallback.
11+
*
12+
* NOT the only place the domain appears — `scripts/og-template.html` prints
13+
* it as footer text, and that is baked into `public/og.png`. Changing the
14+
* domain means changing that too and re-running `npm run og`. See the
15+
* "Moving to a different domain" section of README.md.
16+
*/
17+
export const DEFAULT_SITE_URL = "https://annotkit.gpu-cli.sh";

web/src/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
* should be a one-file change, not a grep.
77
*/
88

9+
import { DEFAULT_SITE_URL } from "../shared/site";
10+
911
export const site = {
1012
name: "AnnotKit",
11-
/** STUB — confirm before launch (epic §11, maintainer action 6). */
12-
url: import.meta.env.VITE_SITE_URL ?? "https://annotkit.gpu-cli.sh",
13+
url: import.meta.env.VITE_SITE_URL ?? DEFAULT_SITE_URL,
1314
repo: "https://github.com/gpu-cli/annotkit",
1415
issues: "https://github.com/gpu-cli/annotkit/issues",
1516
license: "https://github.com/gpu-cli/annotkit/blob/main/LICENSE",

web/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig, type Plugin } from "vite";
22
import react from "@vitejs/plugin-react";
33

4-
const DEFAULT_SITE_URL = "https://annotkit.gpu-cli.sh";
4+
import { DEFAULT_SITE_URL } from "./shared/site";
55

66
/**
77
* Substitutes `%SITE_URL%` in index.html so the canonical and OpenGraph URLs

0 commit comments

Comments
 (0)