From aad17d2ee264495d9493aa6bb024e7226fa20fbb Mon Sep 17 00:00:00 2001 From: Pamela Chia Date: Tue, 3 Nov 2026 12:48:08 +0000 Subject: [PATCH] fix: server-render /open-source repos and library docs code (#52655) Two page templates still served their main content only after JavaScript ran, so crawlers that don't run it never saw it. The /open-source repo cards came from a GitHub fetch in a `useEffect`. The library docs install command and the default code view on the client pages were `dynamic(..., { ssr: false })`. **Changed:** - **/open-source repo cards render in the HTML**: I added `getStaticProps` with hourly ISR that fetches the org repos once, keeps only the repos the tabs list, and seeds `Repos`. Any failure (non-2xx, timeout, unexpected body) falls back to `null`, which keeps today's client fetch, and that result is cached for 60s so a rate-limited regeneration heals quickly. I made counts format as `en-US` until hydration so non-US browsers don't hit a hydration mismatch, and I switched the star sort to a consistent comparator so ties hydrate in the same order in every engine. - **Library docs install command renders on the server**: I made the app's `useLocalStorage` read storage in a layout effect instead of the `useState` initializer, so `Command` no longer needs `ssr: false`. Returning users who picked another package manager see npm until hydration, then their choice, where before the box was empty until then. - **Library docs code shows instead of "Loading code preview..."**: I kept `CodeBlock` client-only because it reads the resolved theme, and I changed its loading fallback to render the selected file's code in a plain `
`.

**Note:** the GitHub fetch is unauthenticated, since the www project has
no general-purpose GitHub token. If regeneration keeps getting
rate-limited, adding a read-only token to the www env is a few-line
follow-up.

## To test
Tested on the PR previews, compared with prod:
- [x] `curl -sL` /open-source with a Chrome user agent and strip
`