mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
create-pull-request/patch
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f59c795eb5 |
feat(docs): render Option 1 on the server when the variant is forced (#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) |
||
|
|
2182a9100f |
fix(docs): nav first paint (#52679)
## Problem - the docs nav experiment from #52191 hides the top bar links and the sidebar nav until the feature flags load - the flags load after auth, posthog and configcat, so each visitor waits up to 1s after hydration ## Solution - changes the docs nav to show the server links on first paint, so most visitors do not wait for the flags - adds a cache of the experiment value from the last visit, so a returning visitor gets their variant at hydration - adds a head script that hides the nav only for visitors cached on option-1, so the control menu does not flash - fixes the nav swap when the posthog request fails, because the nav keeps the cached variant - fixes the stale option-1 cache after the flag is deleted, because the cache saves `false` when posthog returns no flag - changes the experiment exposure to wait for loaded flags, so a stale cached variant is never recorded <!-- ## Preview links If relevant, include links to changed pages for easy review access. Copy the preview base URL from the Vercel bot comment on this PR. Use the following table as an example template. | Site | Live | Preview | Search for | | -------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- | | WWW | [/blog/your-post](https://supabase.com/blog/your-post) | [/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post) | unique phrase from the change | | Docs | [/docs/guides/your-page](https://supabase.com/docs/guides/your-page) | [/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page) | unique phrase from the change | | Studio | [/dashboard](https://supabase.com/dashboard) | [/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard) | unique phrase from the change | | Design system | [/design-system](https://supabase.com/design-system) | [/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system) | unique phrase from the change | | UI library | [/library](https://supabase.com/library) | [/library](https://ui-library-git-branch-name-supabase.vercel.app/library) | unique phrase from the change | | Knowledge base | [/kb/guides/your-page](https://supabase.com/kb/guides/your-page) | [/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page) | unique phrase from the change | --> <!-- ## Additional context Optionally add any other context or screenshots. --> ## Review instructions 1. open [/docs/guides/auth](https://docs-git-antlio-fix-docs-nav-first-paint-supabase.vercel.app/docs/guides/auth) on desktop and reload the page 2. make sure that the top bar links and the sidebar nav show on first paint 3. open [/docs/guides/auth?docs-ia-mvp-v1=option-1](https://docs-git-antlio-fix-docs-nav-first-paint-supabase.vercel.app/docs/guides/auth?docs-ia-mvp-v1=option-1) and make sure that the top bar shows "Develop and deploy" and "Run and manage" 4. at a mobile width, open the menu and make sure that the menu sections show 5. run `pnpm --filter docs exec vitest run features/IaNav` and make sure that all 18 tests pass ## 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) |
||
|
|
4b7af187a4 |
feat(docs): add Option 1 navigation behind the flag (#52191)
Closes DOCS-1469 ## Problem Option 1 in the navigation proposal groups the docs into Start, Build, Develop and deploy, Run and manage, Self-Hosting, Reference, and Resources. The `docs-ia-mvp-v1` flag from #52049 switches to an Option 1 config. That config is still a copy of today's navigation. ## Solution - **Top nav:** reads Start, Build, Develop and deploy, Run and manage, Self-Hosting, Reference, and Resources. Menus still open sidebars by URL prefix, as they do today. - **Run and manage:** pages under `/guides/platform`, `/guides/security`, and `/guides/observability` share one sidebar with the outline's seven groups. - **Other sidebars:** follow the outline. REST, GraphQL and Realtime share one sidebar, and Cron and Queues share one sidebar. - **Seven new topics:** keep their outline labels and link to the section on their source page, for example `getting-started/api-keys#leaked-key`. - **No flash of today's nav:** flags load in the browser, so the nav stays invisible until the query param or the flags resolve, with a 1-second fallback. The links stay in the HTML for agents. - **Tests:** each page appears once across the sidebars, and every link goes to a page in today's navigation. With the flag off, `useNavItems` returns today's navigation. **Not changed:** no URLs move. Breadcrumbs still show today's trail, which DOCS-1470 covers. ## Manual testing 1. Open [Database Backups with the flag on](https://docs-git-docs-ia-nav-option-1-supabase.vercel.app/docs/guides/platform/backups?docs-ia-mvp-v1=option-1). The top nav reads Start, Build, Develop and deploy, Run and manage, Self-Hosting, Reference, and Resources. The sidebar shows the seven Run and manage groups. 2. Open [the same page with the flag off](https://docs-git-docs-ia-nav-option-1-supabase.vercel.app/docs/guides/platform/backups?docs-ia-mvp-v1=control). Today's navigation shows. 3. Open [Database with the flag on](https://docs-git-docs-ia-nav-option-1-supabase.vercel.app/docs/guides/database/overview?docs-ia-mvp-v1=option-1). The sidebar starts with Connect to your database. 4. In the sidebar, open Row Level Security, roles and Vault, and select Test RLS policies with pgTAP. The testing overview opens at Database unit testing with pgTAP. |
||
|
|
447cfa5227 |
feat(docs): add docs-ia-mvp-v1 flag for the new navigation (#52049)
Closes DOCS-1464 ## Problem The new docs navigation, Option 1, needs an A/B test against today's navigation. The docs app has no flag that switches the navigation per visitor. `docs:*` keys in this repo are build-time toggles from `enabled-features`. They are the same for every visitor, so they can't run an A/B. The flag is `docs-ia-mvp-v1`, a PostHog multivariate flag, like `docs-search-v2`. ## Solution - **Variant hook:** `useIaNavVariant` reads `docs-ia-mvp-v1` and returns `control` or `option-1`. It copies `useSearchV2Variant`. It returns `control` until the flag resolves, records exposure once resolved, and respects consent. - **Query param override:** `?docs-ia-mvp-v1=option-1` or `?docs-ia-mvp-v1=control` forces a variant for dogfooding and evals. A forced variant records no exposure. - **Option 1 config:** `features/IaNav/option1.constants.ts` re-exports today's navigation constants. An export defined in that file replaces the re-exported one, so Option 1 in DOCS-1469 overrides only what changes. - **Consumers:** The top nav, the mobile menu, and the guide sidebar read from `useNavItems`, which picks the config for the variant. **Not changed:** Reference sidebars, breadcrumbs, and hub pages. Breadcrumbs and hub pages can read `useIaNavVariant` in DOCS-1470 and DOCS-1471. **PostHog:** The flag doesn't exist in PostHog yet. Until it does, every visitor gets `control`, and the query param still works. ## Manual testing 1. Open [Auth with Option 1 forced](https://docs-git-docs-ia-nav-flag-supabase.vercel.app/docs/guides/auth?docs-ia-mvp-v1=option-1). The top nav and sidebar match today's navigation, because the Option 1 config is a copy. Locally, you can make a change to see the variant. 2. Open [Auth with no param](https://docs-git-docs-ia-nav-flag-supabase.vercel.app/docs/guides/auth). The navigation is unchanged. |