Files
supabase/apps/docs/features/docs/Reference.introduction.tsx
T
Ivan VasilovandJoshen Lim 9fa96977be chore: Minor prettier fixes (#43849)
This PR fixes some prettier issues:
- Bump and unify all prettier versions to 3.7.3 across teh whole repo
- Bump the SQL prettier plugin
- When running `test:prettier`, check `mdx` files also
- Run the new prettier format on all files

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-17 11:17:42 +01:00

70 lines
2.1 KiB
TypeScript

import { AlertTriangle } from 'lucide-react'
import Link from 'next/link'
import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, cn } from 'ui'
import { getRefMarkdown, MDXRemoteRefs } from '~/features/docs/Reference.mdx'
import { ReferenceSectionWrapper } from '~/features/docs/Reference.ui.client'
import commonClientLibSections from '~/spec/common-client-libs-sections.json' with { type: 'json' }
function hasIntro(sections: typeof commonClientLibSections, excludeName?: string) {
return Boolean(
sections[0]?.type === 'markdown' &&
sections[0]?.slug === 'introduction' &&
(!excludeName ||
!(
'excludes' in sections[0] &&
Array.isArray(sections[0].excludes) &&
sections[0].excludes?.includes(excludeName)
))
)
}
interface ClientLibIntroductionProps {
libPath: string
excludeName?: string
version: string
isLatestVersion: boolean
className?: string
}
export async function ClientLibIntroduction({
libPath,
excludeName,
version,
isLatestVersion,
className,
}: ClientLibIntroductionProps) {
if (!hasIntro(commonClientLibSections, excludeName)) return null
const content = await getRefMarkdown(
`${libPath}/${isLatestVersion ? '' : `${version}/`}introduction`
)
return (
<ReferenceSectionWrapper
id="introduction"
link={`/docs/reference/${libPath}/${isLatestVersion ? '' : `${version}/`}introduction`}
className={cn('prose', className)}
>
<MDXRemoteRefs source={content} />
</ReferenceSectionWrapper>
)
}
export function OldVersionAlert({ libPath, className }: { libPath: string; className?: string }) {
return (
<Alert_Shadcn_ variant="warning" className={cn('not-prose', className)}>
<AlertTriangle />
<AlertTitle_Shadcn_ className="font-medium">Version out of date</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
There&apos;s a newer version of this library! Migrate to the{' '}
<Link href={`/reference/${libPath}`} className="underline underline-offset-2">
newest version
</Link>
.
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)
}