Repository navigation
fix(docs): nav first paint - #52679
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
04c836f to
03fb2d7
Compare
03fb2d7 to
9feffd8
Compare
9feffd8 to
fffa99d
Compare
…52735) Closes DOCS-1520 ## Problem The original PR was only client-side. This is adding server-side integration. The docs-nav evals fetch each page's HTML with no JavaScript and add `?docs-ia-mvp-v1=option-1` to every request. The option-1 arm gets the control navigation anyway. Guide pages are statically generated, so the server can't read the query parameter. `useIaNavVariant` reads the override from the URL after the page loads, so the fetched HTML always has today's nav, hidden with an `invisible` class. The top nav dropdowns have a second gap. Their panels mount on the client, so their links are not in the server HTML for either variant. Every eval case starts at `/docs`, where those links are the only way into the Option 1 groups. ## Solution - **Rewrite option-1 requests:** `proxy.ts` sends `/docs` and guide pages with `?docs-ia-mvp-v1=option-1` to `/docs/ia/option-1/…`. Pages there render on the first request and are then cached, so nothing is added to the build. Requests without the parameter, and `.md` requests, are not rewritten. - **Read the variant from the route:** `IaNavRouteProvider`, in the root layout, reads the variant from the layout segments. `useIaNavVariant` returns it on the server and records no PostHog exposure for it. `useIaNavReady` is ready at once, so the nav has no `invisible` class. - **Strip the route prefix:** on the server, `usePathname` returns the rewritten path. The nav components, breadcrumbs, and `AiTools` use `useDocsPathname`, which strips the `/ia/option-1` prefix. - **Breadcrumbs follow the variant:** they resolve from the visitor's nav config, not always today's. - **Top nav subheads in the HTML:** a `<noscript>` block next to the top nav lists the dropdown links for the visitor's variant, inside an `sr-only` nav. Browsers with JavaScript ignore it. - **No index for the route:** direct visits to `/docs/ia/option-1/…` get `noindex`. Canonical URLs point to the real guide. **Not changed:** - **Reference pages:** they keep today's nav, even with the parameter. - **Config pages:** the five generated config pages under `self-hosting` and `local-development/cli` are not in the markdown manifest, so they keep today's nav too. - **Links:** they don't carry the query parameter, so a click in the browser leaves the forced variant. This was already the case before this PR. - **Conflicts with #52679:** it changes the same hooks. Whichever PR merges second needs a rebase. ## Review instructions `grep -c` counts the lines of server HTML that contain the text. A count of 1 or more means the text is in the HTML that an agent fetches without JavaScript. A count of 0 means it is not. 1. Run `curl -s "https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth/sessions?docs-ia-mvp-v1=option-1" | grep -c "Run and manage"`. The count is 1 or more. "Run and manage" is an Option 1 top nav label, so this checks that the parameter gets Option 1's nav from the server. 2. Run `curl -s "https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth/sessions" | grep -c "Run and manage"`. The count is 0. This checks that a request without the parameter still gets today's nav. 3. Run `curl -s "https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs?docs-ia-mvp-v1=option-1" | grep -c "guides/platform/ssl-enforcement"`. The count is 1 or more. The home page has no sidebar, and this link sits only in the "Run and manage" dropdown, so this checks that the top nav subhead links are in the server HTML. 4. Run `curl -s -o /dev/null -w "%{http_code}" "https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth.md?docs-ia-mvp-v1=option-1"`. It returns `200`. This checks that the markdown version still loads with the parameter. 5. Open [/docs/guides/auth](https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth) in a browser and hover over the top nav. You see today's nav and dropdowns. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
Problem
Solution
falsewhen posthog returns no flagReview instructions
pnpm --filter docs exec vitest run features/IaNavand make sure that all 18 tests passChecklist
Check all before review:
/write-the-docsor/edit-the-docsskill, which applies the docs style guide