Skip to content

Commit c267141

Browse files
authored
docs(site): fix homepage redirect loop and double locale path (#84)
The router <Redirect> 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.
1 parent c1e21f3 commit c267141

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎docs/src/pages/index.jsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { Redirect } from "react-router-dom";
21
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
32

3+
// Full-page redirect, not a router <Redirect>: Docusaurus router targets are
4+
// resolved without the site baseUrl, so a router-level redirect lands outside
5+
// the /Qoderian/ prefix on GitHub Pages. In non-default locales, siteConfig
6+
// .baseUrl already carries the locale prefix (e.g. /Qoderian/zh-Hans/), so no
7+
// manual locale handling is needed.
48
export default function Home() {
5-
const { i18n } = useDocusaurusContext();
6-
const prefix = i18n.currentLocale === i18n.defaultLocale ? "" : `/${i18n.currentLocale}`;
7-
return <Redirect to={`${prefix}/docs/introduction`} />;
9+
const { siteConfig } = useDocusaurusContext();
10+
if (typeof window !== "undefined") {
11+
const base = siteConfig.baseUrl.replace(/\/$/, "");
12+
window.location.replace(`${base}/docs/introduction`);
13+
}
14+
return null;
815
}

0 commit comments

Comments
 (0)