mirror of
https://github.com/supabase/supabase.git
synced 2026-06-17 21:23:59 +08:00
Reverts supabase/supabase#46848 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes **Refactor** * Standardized 404 error handling across documentation pages to use Next.js built-in features instead of custom utilities * Enhanced consistency for missing documentation entries, guides, and references when users navigate to unavailable pages <!-- end of auto-generated comment: release notes by coderabbit.ai -->
61 lines
2.0 KiB
TypeScript
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
|