mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
## Context Missing `TechArticle` schemas from Mgmt API docs. ## Preview links [preview url](https://docs-git-kody-devrel-878-mgmt-api-structured-data-supabase.vercel.app/docs/reference/api/introduction) [validation](https://validator.schema.org/#url=https%3A%2F%2Fdocs-git-kody-devrel-878-mgmt-api-structured-data-supabase.vercel.app%2Fdocs%2Freference%2Fapi%2Fintroduction) **Screenshot** <img width="1024" height="670" alt="image" src="https://github.com/user-attachments/assets/cc3578ff-330f-461b-bf5d-c4b29053fbba" />
96 lines
3.6 KiB
TypeScript
96 lines
3.6 KiB
TypeScript
import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'
|
|
import { reference_api } from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'
|
|
import { TocAnchorsProvider } from '~/features/docs/GuidesMdx.client'
|
|
import { getSectionsBySlug } from '~/features/docs/Reference.generated.singleton'
|
|
import { getRefFrontmatter } from '~/features/docs/Reference.mdx'
|
|
import { SectionSwitch } from '~/features/docs/Reference.sections'
|
|
import { ReferencePageShell } from '~/features/docs/Reference.shell'
|
|
import {
|
|
ReferenceLinks,
|
|
ReferenceSidebar,
|
|
type ReferenceLink,
|
|
} from '~/features/docs/Reference.sidebar'
|
|
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 (
|
|
<ReferencePageShell menuId={MenuId.RefApi} navigation={navigationProps}>
|
|
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: techArticleJsonLd }} />
|
|
{isIntroduction ? (
|
|
<TocAnchorsProvider>
|
|
<div className="grid grid-cols-12 relative gap-4">
|
|
<article
|
|
// Used to get headings for the table of contents
|
|
id="sb-docs-guide-main-article"
|
|
className="@container/article col-span-12 md:col-span-8 min-w-0"
|
|
>
|
|
<SectionSwitch libraryId="api" version="latest" section={section} />
|
|
{/* The sidebar is hidden below `md`, so keep the links reachable */}
|
|
{additionalLinks.length !== 0 && (
|
|
<ReferenceLinks links={additionalLinks} className="mt-8 md: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>
|
|
)}
|
|
</ReferencePageShell>
|
|
)
|
|
}
|