Files
supabase/apps/docs/features/docs/Reference.apiPage.tsx
T
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

116 lines
4.4 KiB
TypeScript

import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'
import { reference_api } from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'
import { GuideTocMenu, TocAnchorsProvider } from '~/features/docs/GuidesMdx.client'
import { getSectionsBySlug } from '~/features/docs/Reference.generated.singleton'
import { getRefFrontmatter } from '~/features/docs/Reference.mdx'
import { ReferenceNavigation } from '~/features/docs/Reference.navigation'
import { ReferenceContentScrollHandler } from '~/features/docs/Reference.navigation.client'
import { SectionSwitch } from '~/features/docs/Reference.sections'
import {
ReferenceLinks,
ReferenceSidebar,
type ReferenceLink,
} from '~/features/docs/Reference.sidebar'
import { LayoutMainContent } from '~/layouts/DefaultLayout'
import { SidebarSkeleton } from '~/layouts/MainSkeleton'
import { PROD_URL } from '~/lib/constants'
import { serializeJsonLd, techArticleSchema } from '~/lib/json-ld'
import { notFound, redirect } from 'next/navigation'
import { cn } from 'ui'
export async function ApiReferencePage({ path }: { path: Array<string> }) {
const operationSlug = path[0]
if (!operationSlug) {
redirect('/reference/api/introduction')
}
return <ApiOperationPage operationSlug={operationSlug} />
}
// DOCS-1268: one endpoint per page, reusing the same SectionSwitch (and
// therefore the same ApiEndpointSection/MarkdownSection) that used to render
// every operation on the single monolithic /reference/api page.
async function ApiOperationPage({ operationSlug }: { operationSlug: string }) {
const sectionsBySlug = await getSectionsBySlug('api', 'latest')
const section = sectionsBySlug?.get(operationSlug)
if (!section) notFound()
const navigationProps = {
libraryId: 'api',
name: 'Management API',
menuData: reference_api,
libPath: 'api',
version: 'latest',
isLatestVersion: true,
realNavigation: true,
}
const isIntroduction = section.type === 'markdown'
const additionalLinks = isIntroduction
? (((await getRefFrontmatter(`api/${section.id}`)).links as ReferenceLink[] | undefined) ?? [])
: []
const title = section.title ?? operationSlug
const techArticleJsonLd = serializeJsonLd(
techArticleSchema({
url: `${PROD_URL}/reference/api/${operationSlug}`,
headline: `Management API: ${title}`,
description: `Management API reference for the Supabase API: ${title}`,
})
)
return (
<ReferenceContentScrollHandler
libPath={navigationProps.libPath}
version={navigationProps.version}
isLatestVersion={navigationProps.isLatestVersion}
>
<SidebarSkeleton
menuId={MenuId.RefApi}
hasRightRail={isIntroduction}
NavigationMenu={<ReferenceNavigation {...navigationProps} />}
>
<LayoutMainContent className="layout-v2:mx-0 layout-v2:pt-6">
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: techArticleJsonLd }}
/>
{isIntroduction ? (
<TocAnchorsProvider>
<div className="grid grid-cols-12 relative gap-4">
<article
id="sb-docs-guide-main-article"
className="@container/article col-span-12 md:col-span-8 layout-v2:md:col-span-12 min-w-0"
>
<GuideTocMenu />
<SectionSwitch libraryId="api" version="latest" section={section} />
{additionalLinks.length !== 0 && (
<ReferenceLinks
links={additionalLinks}
className="mt-8 md:hidden layout-v2:md:block layout-v2:lg:hidden"
/>
)}
</article>
<ReferenceSidebar
links={additionalLinks}
className={cn(
'hidden md:flex md:col-span-3 md:col-start-10',
'self-start sticky',
'top-[calc(var(--header-height)+3rem)]',
'max-h-[calc(100vh-var(--header-height)-4rem)]'
)}
/>
</div>
</TocAnchorsProvider>
) : (
<article className="@container/article">
<SectionSwitch libraryId="api" version="latest" section={section} tag="h1" />
</article>
)}
</LayoutMainContent>
</SidebarSkeleton>
</ReferenceContentScrollHandler>
)
}