Files
9a50d0cc65 fix(docs): stop default-locale pages failing hydration with React #418 (MUL-8013) (#9244)
* fix(docs): stop default-locale pages failing hydration with React #418

SSG prerenders each page under its canonical `[lang]` route, so client
components see `/en/agents` as the pathname at build time, while the
browser URL for the hidden default locale is `/agents` (the i18n
middleware rewrites it). Fumadocs resolves the page tree path with
`usePathname()`, and the tree stores default-locale URLs without the
prefix — so the prerendered HTML rendered tree-path fallbacks ("On this
page" in the TOC popover trigger) while hydration resolved the real
page name ("Agents"). The text mismatch threw React error #418 on every
EN page load and React regenerated the whole tree on the client,
dropping SSR-injected elements such as the next/font preload links.
Non-default locales matched on both sides and were unaffected.

Wrap the docs layout in fumadocs' `FrameworkProvider` with a
`usePathname` that strips the hidden default-locale prefix, so prerender
and hydration see the same locale-less path the page tree uses. The
prerendered HTML now carries the real page names as well. Non-default
locales keep their `/zh`-style prefix and behave exactly as before.

Fixes #9243

* fix(docs): preserve static image imports in framework provider

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: Bohan-J <[email protected]>
Co-authored-by: multica-agent <[email protected]>
2026-10-19 01:58:16 -04:00
..