@@ -10,20 +10,29 @@ export const RELEASE_TAG = rawTag.trim();
1010
1111export type PackageManager = "npm" | "pnpm" | "bun" | "yarn" ;
1212
13- const FALLBACK_DOCS_URL = "https://arkenv.js.org" ;
13+ /**
14+ * Default/fallback docs origin:
15+ * During pre-release (alpha/rc), v1 docs are hosted at https://arkenv-v1.vercel.app
16+ * while https://arkenv.js.org remains the v0 docs site.
17+ * When graduating to GA (empty RELEASE_TAG), the default flips to https://arkenv.js.org.
18+ */
19+ export const FALLBACK_DOCS_URL = RELEASE_TAG
20+ ? "https://arkenv-v1.vercel.app"
21+ : "https://arkenv.js.org" ;
1422
1523/**
1624 * Resolves the docs origin for the current deployment.
1725 *
1826 * Preference order:
1927 * 1. `NEXT_PUBLIC_SITE_URL` (trimmed, no trailing slash)
20- * 2. `https://${VERCEL_PROJECT_PRODUCTION_URL}` (production domain; flips when DNS moves)
21- * 3. `https://${VERCEL_URL}` (preview deployment host)
22- * 4. Fallback `https://arkenv. js.org`
28+ * 2. `https://${NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ?? VERCEL_PROJECT_PRODUCTION_URL}` (production domain; flips when DNS moves in GA )
29+ * 3. `https://${NEXT_PUBLIC_VERCEL_URL ?? VERCEL_URL}` (preview deployment host)
30+ * 4. Fallback docs URL ( `https://arkenv-v1.vercel.app` during pre-release, `https://arkenv. js.org` for GA)
2331 *
2432 * Setting `NEXT_PUBLIC_SITE_URL` or the Vercel production URL makes the homepage
25- * agent prompt auto-update when the site moves off a preview host (e.g.
26- * arkenv-v1.vercel.app → arkenv.js.org) without hardcoding the preview forever.
33+ * agent prompt auto-update when the site moves off a preview host without hardcoding.
34+ * During pre-release (e.g. alpha), arkenv.js.org serves v0 docs, so it is ignored
35+ * in favor of the v1 deployment host or the pre-release fallback.
2736 *
2837 * @param env - Env bag to read (defaults to `process.env`; injectable for tests).
2938 * @returns Absolute docs origin with no trailing slash.
@@ -36,18 +45,26 @@ export function getDocsUrl(env: NodeJS.ProcessEnv = process.env): string {
3645 : `https://${ siteUrl } ` ;
3746 }
3847
39- const productionHost = env . VERCEL_PROJECT_PRODUCTION_URL ?. trim ( ) . replace (
40- / \/ + $ / ,
41- "" ,
42- ) ;
48+ const productionHost = (
49+ env . NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ??
50+ env . VERCEL_PROJECT_PRODUCTION_URL
51+ )
52+ ?. trim ( )
53+ . replace ( / \/ + $ / , "" ) ;
4354 if ( productionHost ) {
44- return productionHost . startsWith ( "http://" ) ||
45- productionHost . startsWith ( "https://" )
46- ? productionHost
47- : `https://${ productionHost } ` ;
55+ const isV0DomainDuringPreRelease =
56+ Boolean ( RELEASE_TAG ) && productionHost === "arkenv.js.org" ;
57+ if ( ! isV0DomainDuringPreRelease ) {
58+ return productionHost . startsWith ( "http://" ) ||
59+ productionHost . startsWith ( "https://" )
60+ ? productionHost
61+ : `https://${ productionHost } ` ;
62+ }
4863 }
4964
50- const previewHost = env . VERCEL_URL ?. trim ( ) . replace ( / \/ + $ / , "" ) ;
65+ const previewHost = ( env . NEXT_PUBLIC_VERCEL_URL ?? env . VERCEL_URL )
66+ ?. trim ( )
67+ . replace ( / \/ + $ / , "" ) ;
5168 if ( previewHost ) {
5269 return previewHost . startsWith ( "http://" ) ||
5370 previewHost . startsWith ( "https://" )
0 commit comments