From fd8fa9a5100bf985d992b54306850095d3621cb6 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sun, 30 Nov 2025 00:00:58 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E8=8E=B7=E5=8F=96=20`IS=5FCHINA=5FSITE`=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复浏览 `/services` 页面时无法获取 NodeJS的 process 从而无法正确获取 IS_CHINA_SITE 环境变量,参考 https://docusaurus.io/docs/deployment#using-environment-variables --- package.json | 2 +- src/components/GlobalContent.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c1f0fc711..1e5287108 100644 --- a/package.json +++ b/package.json @@ -86,5 +86,5 @@ "engines": { "node": ">=18.0" }, - "packageManager": "pnpm@10.12.1" + "packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a" } diff --git a/src/components/GlobalContent.js b/src/components/GlobalContent.js index 81f1330cf..187c5ebd1 100644 --- a/src/components/GlobalContent.js +++ b/src/components/GlobalContent.js @@ -1,15 +1,13 @@ import React from "react"; import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; -const IS_CHINA_SITE = process.env.CHINA === "true"; - /** - * A component that conditionally renders its children based on the CHINA environment variable. - * If CHINA is 'true', the children (typically Markdown content) will not be rendered. + * A component that conditionally renders its children based on the `IS_CHINA_SITE` environment variable. + * If `IS_CHINA_SITE` is 'true', the children (typically Markdown content) will not be rendered. */ export default function GlobalContent({ children }) { - if (IS_CHINA_SITE) { - return null; // Do not render children if in China site context + if (useDocusaurusContext().siteConfig.customFields.IS_CHINA_SITE) { + return null; // Do not render children if in the China site context } return <>{children}; // Render children otherwise }