Files
supabase/apps/docs/app/reference/[...slug]/page.tsx
Charis eed0f6e7ce fix: don't render hidden pages (#38477)
* fix: remove hidden guide pages from render

Guide pages hidden from nav are still rendered. This change removes them
from both build-time and on-demand rendering.

* fix: build llms script

The build llms script does not run in an environment where React is
available, so it must import from 'common/enabled-features', not from
'common', to avoid errors.

* fix: don't render hidden reference pages

Similar to guides, but for client SDK references. If a page is hidden
from the navigation (its feature flag is toggled off), don't render it
at all. This includes (a) at build time, (b) at request time, and (c) at
crawler request time.

* fix: types
2025-09-08 13:05:38 -04:00

61 lines
2.0 KiB
TypeScript

import { notFound } from 'next/navigation'
import { REFERENCES } from '~/content/navigation.references'
import { ApiReferencePage } from '~/features/docs/Reference.apiPage'
import { CliReferencePage } from '~/features/docs/Reference.cliPage'
import { ClientSdkReferencePage } from '~/features/docs/Reference.sdkPage'
import { SelfHostingReferencePage } from '~/features/docs/Reference.selfHostingPage'
import {
generateReferenceMetadata,
generateReferenceStaticParams,
parseReferencePath,
redirectNonexistentReferenceSection,
} from '~/features/docs/Reference.utils'
export const dynamicParams = false
export default async function ReferencePage(props: { params: Promise<{ slug: Array<string> }> }) {
const params = await props.params
const { slug } = params
if (!Object.keys(REFERENCES).includes(slug[0].replaceAll('-', '_'))) {
notFound()
}
const parsedPath = parseReferencePath(slug)
const isClientSdkReference = parsedPath.__type === 'clientSdk'
const isCliReference = parsedPath.__type === 'cli'
const isApiReference = parsedPath.__type === 'api'
const isSelfHostingReference = parsedPath.__type === 'self-hosting'
if (isClientSdkReference) {
const { sdkId, maybeVersion, path } = parsedPath
const sdkData = REFERENCES[sdkId]
if (sdkData.enabled === false) {
notFound()
}
const latestVersion = sdkData.versions[0]
const version = maybeVersion ?? latestVersion
await redirectNonexistentReferenceSection(sdkId, version, path, version === latestVersion)
return <ClientSdkReferencePage sdkId={sdkId} libVersion={version} />
} else if (isCliReference) {
return <CliReferencePage />
} else if (isApiReference) {
return <ApiReferencePage />
} else if (isSelfHostingReference) {
return (
<SelfHostingReferencePage service={parsedPath.service} servicePath={parsedPath.servicePath} />
)
} else {
notFound()
}
}
export const generateStaticParams = generateReferenceStaticParams
export const generateMetadata = generateReferenceMetadata