feat(i18n): default the cn build to Chinese

The .cn site exists for Chinese readers, so the unprefixed routes should
serve Chinese there. Rspress omits the prefix for the default locale, so
this also moves the routes:

              .com                      .cn
  English     /                         /en-gb/
  Chinese     /zh-hans/                 /

- Make the default locale a per-target value rather than a constant, and
  move the localePrefix helper inside createConfig so a prefix can no
  longer be hardcoded elsewhere.
- Build the sitemap priority map from localePrefix. The keys are full
  route paths, so the previous hardcoded "/zh-hans/..." entries would
  have silently stopped matching on .cn.
- Widen the nav Home activeMatch to cover either prefixed home, since the
  two targets put a different locale behind the prefix.

Note: README.md also carries the licence wording changed in the next
commit — a single file's hunks cannot be split non-interactively.
This commit is contained in:
zihluwang committed 2026-09-25 15:38:03 +08:00
1 parent 861852961f
commit 164c319ac1
5 files changed
+110 -45

No files matched your search

+8 -3
View File
@@ -19,9 +19,14 @@ pnpm format # Prettier — format all files
`rspress.config.ts` exports a `createConfig(target)` factory; `rspress.cn.config.ts`
is a three-line wrapper calling it with `"cn"`, passed via `--config`. The two
targets differ in the canonical origin used for `head`, the sitemap and
`robots.txt`, and in which social links are rendered. Both write to `doc_build/`,
so build and deploy one target at a time.
targets differ in the default (unprefixed) language, the canonical origin used
for `head`, the sitemap and `robots.txt`, and in which social links are rendered.
Both write to `doc_build/`, so build and deploy one target at a time.
`.com` defaults to `en-gb` and `.cn` to `zh-hans`, so the same content is served
at different paths per target — Rspress omits the prefix for the default locale.
Anything referencing a locale prefix must go through the `localePrefix` helper
inside `createConfig`, never a hardcoded `/zh-hans`.
## Architecture