From e46b243edd264acb0340d59e990bd512ba762e13 Mon Sep 17 00:00:00 2001 From: Li Xin Date: Fri, 2 May 2025 21:09:31 +0800 Subject: [PATCH] feat: add STATIC_WEBSITE_ONLY mode --- web/src/app/landing/components/jumbotron.tsx | 36 +++++++++++++++----- web/src/core/replay/hooks.ts | 7 +++- web/src/env.js | 3 ++ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/web/src/app/landing/components/jumbotron.tsx b/web/src/app/landing/components/jumbotron.tsx index 5ce9f10..5881c39 100644 --- a/web/src/app/landing/components/jumbotron.tsx +++ b/web/src/app/landing/components/jumbotron.tsx @@ -8,10 +8,11 @@ import Link from "next/link"; import { AuroraText } from "~/components/magicui/aurora-text"; import { FlickeringGrid } from "~/components/magicui/flickering-grid"; import { Button } from "~/components/ui/button"; +import { env } from "~/env"; export function Jumbotron() { return ( -
+
- + {!env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY && ( + + )}
diff --git a/web/src/core/replay/hooks.ts b/web/src/core/replay/hooks.ts index a4e9b1c..27f1f4c 100644 --- a/web/src/core/replay/hooks.ts +++ b/web/src/core/replay/hooks.ts @@ -4,6 +4,8 @@ import { useSearchParams } from "next/navigation"; import { useMemo } from "react"; +import { env } from "~/env"; + import { extractReplayIdFromSearchParams } from "./get-replay-id"; export function useReplay() { @@ -12,5 +14,8 @@ export function useReplay() { () => extractReplayIdFromSearchParams(searchParams.toString()), [searchParams], ); - return { isReplay: replayId != null, replayId }; + return { + isReplay: replayId != null || env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY, + replayId, + }; } diff --git a/web/src/env.js b/web/src/env.js index 38c10ea..7d4448a 100644 --- a/web/src/env.js +++ b/web/src/env.js @@ -20,6 +20,7 @@ export const env = createEnv({ */ client: { NEXT_PUBLIC_API_URL: z.string().optional(), + NEXT_PUBLIC_STATIC_WEBSITE_ONLY: z.boolean().optional(), }, /** @@ -29,6 +30,8 @@ export const env = createEnv({ runtimeEnv: { NODE_ENV: process.env.NODE_ENV, NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, + NEXT_PUBLIC_STATIC_WEBSITE_ONLY: + process.env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true", }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially