mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 23:49:03 +00:00
## Problem Dupe content and workflows when this content now all lives in the KB. ## Solution Removes various artifacts from the docs repo (content files, github workflows, etc.) from the docs app. These paths have already been redirected to /kb in #52095 and we haven't seen any meaningful 404 traffic indicating the redirects were done incorrectly. ## Preview links TBD
74 lines
2.0 KiB
TypeScript
74 lines
2.0 KiB
TypeScript
import * as NavItems from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'
|
|
|
|
export interface BreadcrumbItem {
|
|
name?: string
|
|
title?: string
|
|
url?: string
|
|
}
|
|
|
|
const SECTION_PATH_TO_KEY: Record<string, keyof typeof NavItems> = {
|
|
ai: 'ai',
|
|
api: 'api',
|
|
auth: 'auth',
|
|
contributing: 'contributing',
|
|
cron: 'cron',
|
|
database: 'database',
|
|
deployment: 'deployment',
|
|
functions: 'functions',
|
|
'getting-started': 'gettingstarted',
|
|
graphql: 'graphql',
|
|
integrations: 'integrations',
|
|
'local-development': 'local_development',
|
|
platform: 'platform',
|
|
queues: 'queues',
|
|
realtime: 'realtime',
|
|
resources: 'resources',
|
|
security: 'security',
|
|
'self-hosting': 'self_hosting',
|
|
storage: 'storage',
|
|
observability: 'telemetry',
|
|
}
|
|
|
|
function getSectionMenu(pathname: string) {
|
|
const trimmed = pathname.replace(/^\/guides\/?/, '')
|
|
const top = trimmed.split('/')[0]
|
|
const key = SECTION_PATH_TO_KEY[top] ?? 'gettingstarted'
|
|
return (NavItems as Record<string, any>)[key]
|
|
}
|
|
|
|
function findMenuItemByUrl(
|
|
menu: any,
|
|
targetUrl: string,
|
|
parents: BreadcrumbItem[] = []
|
|
): BreadcrumbItem[] | null {
|
|
if (menu.items) {
|
|
for (const item of menu.items) {
|
|
const result = findMenuItemByUrl(item, targetUrl, [...parents, menu])
|
|
if (result) return result
|
|
}
|
|
}
|
|
if (menu.url === targetUrl) {
|
|
return [...parents, menu]
|
|
}
|
|
return null
|
|
}
|
|
|
|
export function resolveBreadcrumbs(pathname: string): BreadcrumbItem[] {
|
|
if (pathname.startsWith('/guides/getting-started/ai-prompts')) {
|
|
return [
|
|
{ name: 'Getting started', url: '/guides/getting-started' },
|
|
{ name: 'AI Tools' },
|
|
{ name: 'Prompts', url: '/guides/getting-started/ai-prompts' },
|
|
]
|
|
}
|
|
if (pathname.startsWith('/guides/getting-started/ai-skills')) {
|
|
return [
|
|
{ name: 'Getting started', url: '/guides/getting-started' },
|
|
{ name: 'AI Tools' },
|
|
{ name: 'Agent Skills', url: '/guides/getting-started/ai-skills' },
|
|
]
|
|
}
|
|
const menu = getSectionMenu(pathname)
|
|
return findMenuItemByUrl(menu, pathname) ?? []
|
|
}
|