Files
supabase/apps/docs/features/IaNav/option1.test.ts
anthony lio 02e61b9cda fix(docs): layout v2 reference fixtures (#54233)
## Problem

- after #53761 the option-1 sidebar reference list has no row for
server, middleware and tanstack db
- list marks no row as current on a library page, for example on
`/reference/javascript/select`
- management api intro shows its endpoint list in the right rail and its
toc in an extra column inside the content

## Solution

- adds the server, middleware and tanstack db rows with the new and
experimental badges of the current nav
- fixes the reference list so it marks the library of the current page
- changes the management api to open as its own sidebar level with the
endpoint list on the left
- moves the toc, the links and the feedback of the management api intro
into the right rail + removes the rail on endpoint pages
- adds the "on this page" menu to the management api intro below `lg`
- adds the reference library column to the option-1 nav size allowlist
because it is a list of peer libraries

| before | after |
| -------|------|
| <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/3a216c0b-31c1-4629-82a1-0590c7e639ae"
/> | <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/c53afc0e-8d15-45d7-9dc8-320443761ed2"
/> |

| before | after |
| -------|------|
| <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/5dc79bb9-b160-44e6-a3c5-39182fb71d4f"
/> | <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/9e0dff3c-5261-4c70-b1f1-f74314231a08"
/> |

<!--
## 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/reference?docs-ia-mvp-v1=option-1](https://docs-ivb0vb1qq-supabase.vercel.app/docs/reference?docs-ia-mvp-v1=option-1)
and do all steps in the same tab because the flag override lasts only
for the tab
2. make sure that the reference list shows server and middleware
3. open
[/docs/reference/javascript/select](https://docs-ivb0vb1qq-supabase.vercel.app/docs/reference/javascript/select)
and make sure that the sidebar marks only the javascript row
4. click `Management API` in the sidebar and make sure that the sidebar
shows `< Management API` with the endpoint list
5. make sure that the right rail shows the toc, the additional links and
the feedback buttons
6. open
[/docs/guides/database/overview](https://docs-ivb0vb1qq-supabase.vercel.app/docs/guides/database/overview)
and make sure that the sidebar and the right rail did not change

## 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)
2026-11-30 20:19:04 +00:00

73 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import * as option1 from './option1.constants'
import { clientSdkIds, REFERENCES } from '@/content/navigation.references'
import * as today from '@/components/Navigation/NavigationMenu/NavigationMenu.constants'
type NavNode = {
title?: string
name?: string
url?: string
href?: string
items?: NavNode[]
menuItems?: NavNode[][]
}
const walk = (node: NavNode): string[] => [
...[node.url, node.href].filter((url): url is string => Boolean(url)),
...(node.items ?? []).flatMap((child) => walk(child)),
...(node.menuItems ?? []).flat().flatMap((child) => walk(child)),
]
// A sidebar shared by several URL prefixes is exported under each name.
const sidebars = (navItems: Record<string, unknown>): NavNode[] => [
...new Set(
Object.values(navItems).filter(
(value): value is NavNode =>
typeof value === 'object' && value !== null && 'title' in value && 'items' in value
)
),
]
function sidebarUrls(navItems: Record<string, unknown>): string[] {
return sidebars(navItems).flatMap((sidebar) =>
(sidebar.items ?? []).flatMap((item) => walk(item))
)
}
function navUrls(navItems: Record<string, unknown>): string[] {
return [
...(navItems.GLOBAL_MENU_ITEMS as NavNode[][]).flat().flatMap((item) => walk(item)),
...sidebarUrls(navItems),
]
}
describe('Option 1 navigation', () => {
it('lists each page once across its sidebars', () => {
const urls = sidebarUrls(option1)
expect(urls.filter((url, index) => urls.indexOf(url) !== index)).toEqual([])
})
it("links only to pages already in today's navigation", () => {
const page = (url: string) => url.split('#')[0]
const todayPages = new Set(navUrls(today).map((url) => page(url)))
// the migration guides moved to the knowledge base
const isKbPage = (url: string) => url.startsWith('https://supabase.com/kb/')
expect(navUrls(option1).filter((url) => !isKbPage(url) && !todayPages.has(page(url)))).toEqual(
[]
)
})
it('lists every enabled client library in the reference section', () => {
const referenceSection = option1.GLOBAL_MENU_ITEMS.flat().find(
(section) => section.label === 'Reference'
)
const referenceLinks = new Set(walk(referenceSection ?? {}))
const libraryLinks = clientSdkIds.map((sdkId) => `/reference/${REFERENCES[sdkId].libPath}`)
expect(libraryLinks.filter((href) => !referenceLinks.has(href))).toEqual([])
})
})