mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
Migrates client SDK References to App Router. (Management and CLI API references aren't migrated yet, nor are self-hosting config references.) Some notes: Big changes to the way crawler pages are built and individual section URLs (e.g., javascript/select) are served. All of these used to be SSG-generated pages, but the number of heavy pages was just too much to handle -- slow as molasses and my laptop sounded like it was taking off, and CI sometimes refuses to build it all at all. Tried various tricks with caching and pre-generating data but no dice. So I changed to only building one copy of each SDK+version page, then serving the sub-URLs through a response rewrite. That's for the actual user-visible pages. For the bot pages, each sub-URL needs to be its own page, but prebuilding it doesn't work, and rendering on demand from React components is too slow (looking for super-fast response here for SEO). Instead I changed to using an API route that serves very minimal, hand-crafted HTML. It looks ugly, but it's purely for the search bots. You can test what bots see by running curl --user-agent "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" <URL_OF_PAGE> Also added some smoke tests to run against prod for the crawler routes, since we don't keep an eye on those regularly, and Vercel config changes could surprise-break them. Tested the meta images on Open Graph and all seems to work fine. With this approach, full production builds are really fast: ~5 minutes Starts using the new type spec handling, which is better at finding params automatically, so I could remove some of the manually written ones from the spec files.
106 lines
2.9 KiB
TypeScript
106 lines
2.9 KiB
TypeScript
import { Fragment, type PropsWithChildren } from 'react'
|
|
|
|
import { cn } from 'ui'
|
|
|
|
import MenuIconPicker from '~/components/Navigation/NavigationMenu/MenuIconPicker'
|
|
import RefVersionDropdown from '~/components/RefVersionDropdown'
|
|
import { getReferenceSections } from '~/features/docs/Reference.generated.singleton'
|
|
import {
|
|
RefLink,
|
|
ReferenceNavigationScrollHandler,
|
|
} from '~/features/docs/Reference.navigation.client'
|
|
import { type AbbrevCommonClientLibSection } from '~/features/docs/Reference.utils'
|
|
|
|
interface ClientSdkNavigationProps {
|
|
sdkId: string
|
|
name: string
|
|
menuData: { icon?: string }
|
|
libPath: string
|
|
version: string
|
|
isLatestVersion: boolean
|
|
}
|
|
|
|
async function ClientSdkNavigation({
|
|
sdkId,
|
|
name,
|
|
menuData,
|
|
libPath,
|
|
version,
|
|
isLatestVersion,
|
|
}: ClientSdkNavigationProps) {
|
|
const navSections = await getReferenceSections(sdkId, version)
|
|
|
|
const basePath = `/reference/${libPath}${isLatestVersion ? '' : `/${version}`}`
|
|
|
|
return (
|
|
<ReferenceNavigationScrollHandler className="w-full flex flex-col pt-3 pb-5 gap-3">
|
|
<div className="flex items-center gap-3">
|
|
{'icon' in menuData && <MenuIconPicker icon={menuData.icon} width={21} height={21} />}
|
|
<span className="text-base text-brand-600">{name}</span>
|
|
<RefVersionDropdown library={libPath} currentVersion={version} />
|
|
</div>
|
|
<ul className="flex flex-col gap-2">
|
|
{navSections.map((section) => (
|
|
<Fragment key={section.id}>
|
|
{section.type === 'category' ? (
|
|
<li>
|
|
<RefCategory basePath={basePath} section={section} />
|
|
</li>
|
|
) : (
|
|
<li className={topLvlRefNavItemStyles}>
|
|
<RefLink basePath={basePath} section={section} />
|
|
</li>
|
|
)}
|
|
</Fragment>
|
|
))}
|
|
</ul>
|
|
</ReferenceNavigationScrollHandler>
|
|
)
|
|
}
|
|
|
|
const topLvlRefNavItemStyles = 'leading-5'
|
|
|
|
function RefCategory({
|
|
basePath,
|
|
section,
|
|
}: {
|
|
basePath: string
|
|
section: AbbrevCommonClientLibSection
|
|
}) {
|
|
if (!('items' in section && section.items.length > 0)) return null
|
|
|
|
return (
|
|
<>
|
|
<Divider />
|
|
{'title' in section && <SideMenuTitle className="py-2">{section.title}</SideMenuTitle>}
|
|
<ul className="space-y-2">
|
|
{section.items.map((item) => (
|
|
<li key={item.id} className={topLvlRefNavItemStyles}>
|
|
<RefLink basePath={basePath} section={item} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</>
|
|
)
|
|
}
|
|
|
|
function Divider() {
|
|
return <hr className="w-full h-px my-3 bg-control" />
|
|
}
|
|
|
|
function SideMenuTitle({ children, className }: PropsWithChildren<{ className?: string }>) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'font-mono font-medium text-xs text-foreground tracking-wider uppercase',
|
|
className
|
|
)}
|
|
>
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export { ClientSdkNavigation }
|
|
export type { AbbrevCommonClientLibSection }
|