Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

perf: snappy nav links in reference docs

Greg Richardson52cf9443d48e
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx
index f7fc346557b..eb352b1d7e5 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx
@@ -57,20 +57,30 @@ const FunctionLink = React.memo(function FunctionLink({
const router = useRouter()
const activeAccordionItem = useMenuActiveRefId()
+ const url = `${router.basePath}${basePath}/${slug}`
const active = activeAccordionItem === id
+
return (
<li className="function-link-item">
- <Link href={`${basePath}/${slug}`} passHref>
- <a
- className={[
- 'cursor-pointer transition text-sm hover:text-brand-900 flex gap-3',
- active ? 'text-brand-900' : 'text-scale-1000',
- ].join(' ')}
- >
- {icon && <Image width={16} height={16} alt={icon} src={`${router.basePath}${icon}`} />}
- {title}
- </a>
- </Link>
+ <a
+ href={url}
+ /**
+ * We don't actually want to navigate or re-render anything
+ * since ref links are all sub-sections on the same page
+ */
+ onClick={(e) => {
+ e.preventDefault()
+ history.pushState({}, '', url)
+ document.getElementById(slug)?.scrollIntoView()
+ }}
+ className={[
+ 'cursor-pointer transition text-sm hover:text-brand-900 flex gap-3',
+ active ? 'text-brand-900' : 'text-scale-1000',
+ ].join(' ')}
+ >
+ {icon && <Image width={16} height={16} alt={icon} src={`${router.basePath}${icon}`} />}
+ {title}
+ </a>
</li>
)
})