Skip to content

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

fix(docs) Prevent dashboard links from breaking (#47897)

Miranda Limonczenkoa9115b694f57
diff --git a/apps/docs/lib/content-listings.test.ts b/apps/docs/lib/content-listings.test.ts
index 61a067ad726..b22f0ffc7db 100644
--- a/apps/docs/lib/content-listings.test.ts
+++ b/apps/docs/lib/content-listings.test.ts
@@ -1,3 +1,4 @@
+import { CONTENT_LISTINGS } from '~/data/content-listings'
import { storageGetStarted } from '~/data/content-listings/storage.data'
import {
ContentListings as ContentListingsMarkdownHandler,
@@ -6,6 +7,21 @@ import {
import { isExternalContentListingHref } from '~/lib/content-listings.utils'
import { describe, expect, it } from 'vitest'
+const SUPABASE_DASHBOARD_ORIGIN = 'https://supabase.com/dashboard'
+
+function isDashboardHref(href: string): boolean {
+ try {
+ const url = new URL(href, 'https://supabase.com')
+ return url.pathname === '/dashboard' || url.pathname.startsWith('/dashboard/')
+ } catch {
+ return href === '/dashboard' || href.startsWith('/dashboard/')
+ }
+}
+
+function isAbsoluteSupabaseDashboardHref(href: string): boolean {
+ return href === SUPABASE_DASHBOARD_ORIGIN || href.startsWith(`${SUPABASE_DASHBOARD_ORIGIN}/`)
+}
+
describe('isExternalContentListingHref', () => {
it('treats protocol-relative URLs as external', () => {
expect(isExternalContentListingHref('//example.com/path')).toBe(true)
@@ -150,6 +166,25 @@ describe('ContentListings markdown handler', () => {
})
})
+describe('dashboard content listing hrefs', () => {
+ // Root-relative /dashboard hrefs get the docs basePath and 404; use absolute URLs.
+ it('uses absolute https://supabase.com dashboard URLs', () => {
+ const dashboardLinks = Object.values(CONTENT_LISTINGS).flatMap((group) =>
+ group.items
+ .filter((item) => isDashboardHref(item.href))
+ .map((item) => ({ listingId: group.id, title: item.title, href: item.href }))
+ )
+
+ expect(dashboardLinks.length).toBeGreaterThan(0)
+
+ const relativeOrNonCanonical = dashboardLinks.filter(
+ (link) => !isAbsoluteSupabaseDashboardHref(link.href)
+ )
+
+ expect(relativeOrNonCanonical).toEqual([])
+ })
+})
+
describe('TelemetryEvent union', () => {
it('includes docs_content_listing_clicked', () => {
const event = {