diff --git a/src/pages/index.astro b/src/pages/index.astro index b824c55..d170fdc 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,4 +1,7 @@ --- +/** Per-request hostname selects featured product — must not prerender to static HTML. */ +export const prerender = false; + import BaseLayout from '../layouts/BaseLayout.astro'; import LayoutCurrent from '../components/LayoutCurrent.astro'; import LayoutA from '../components/LayoutA.astro'; @@ -6,12 +9,26 @@ import LayoutB from '../components/LayoutB.astro'; import LayoutC from '../components/LayoutC.astro'; const hostname = Astro.url.hostname; +const hostLower = hostname.toLowerCase(); const featuredParam = Astro.url.searchParams.get('featured'); const layoutParam = Astro.url.searchParams.get('layout'); +const protoGate = Astro.url.searchParams.get('proto') === '1'; + +/** Dev / preview, or production opt-in via ?proto=1 — hide on canonical marketing domains otherwise */ +const showProtoSwitcher = + import.meta.env.DEV || + protoGate || + hostLower === 'localhost' || + hostLower.startsWith('127.') || + hostLower.endsWith('.workers.dev') || + hostLower.endsWith('.pages.dev'); + +/** On git-rain hosts, hostname already picks rain — hide Domain row when bar is open */ +const showProtoDomainGroup = showProtoSwitcher && !hostLower.includes('git-rain'); const featured: 'fire' | 'rain' = featuredParam === 'rain' ? 'rain' : featuredParam === 'fire' ? 'fire' - : hostname.includes('git-rain') ? 'rain' + : hostLower.includes('git-rain') ? 'rain' : 'fire'; const layout: 'current' | 'a' | 'b' | 'c' = layoutParam === 'a' ? 'a' @@ -26,10 +43,12 @@ const description = featured === 'rain' : 'Multi-repo checkpoint with git-fire, reverse sync with git-rain, plus git-testkit and git-harness for serious Git automation and tests.'; function protoUrl(f: string, l: string): string { - const parts: string[] = []; - if (f !== 'fire') parts.push(`featured=${f}`); - if (l !== 'current') parts.push(`layout=${l}`); - return parts.length ? `?${parts.join('&')}` : '?'; + const params = new URLSearchParams(); + if (f !== 'fire') params.set('featured', f); + if (l !== 'current') params.set('layout', l); + if (protoGate) params.set('proto', '1'); + const qs = params.toString(); + return qs ? `?${qs}` : '?'; } --- @@ -39,21 +58,27 @@ function protoUrl(f: string, l: string): string { {layout === 'c' && } {layout === 'current' && } -
-
- Domain - fire.* - rain.* -
-
-
- Layout - now - A - B - C + {showProtoSwitcher && ( +
+ {showProtoDomainGroup && ( + <> +
+ Domain + fire.* + rain.* +
+ + + )} +
+ Layout + now + A + B + C +
-
+ )}