From ee3253bb644cf00488e0b5803af1622743226c73 Mon Sep 17 00:00:00 2001 From: liuxuezhuo Date: Tue, 29 Sep 2026 23:38:01 +0800 Subject: [PATCH] docs(site): fix homepage redirect loop and double locale path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The router resolved its target without the site baseUrl, so the navbar logo linked to a path outside /Qoderian/ (404 on GitHub Pages). Replacing it with a full-page redirect, driven by siteConfig.baseUrl — which already carries the locale prefix in non-default locales — lands both locales on the right introduction page. --- docs/src/pages/index.jsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/src/pages/index.jsx b/docs/src/pages/index.jsx index be03cd9..d03a3d4 100644 --- a/docs/src/pages/index.jsx +++ b/docs/src/pages/index.jsx @@ -1,8 +1,15 @@ -import { Redirect } from "react-router-dom"; import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; +// Full-page redirect, not a router : Docusaurus router targets are +// resolved without the site baseUrl, so a router-level redirect lands outside +// the /Qoderian/ prefix on GitHub Pages. In non-default locales, siteConfig +// .baseUrl already carries the locale prefix (e.g. /Qoderian/zh-Hans/), so no +// manual locale handling is needed. export default function Home() { - const { i18n } = useDocusaurusContext(); - const prefix = i18n.currentLocale === i18n.defaultLocale ? "" : `/${i18n.currentLocale}`; - return ; + const { siteConfig } = useDocusaurusContext(); + if (typeof window !== "undefined") { + const base = siteConfig.baseUrl.replace(/\/$/, ""); + window.location.replace(`${base}/docs/introduction`); + } + return null; }