| 1 | /** |
| 2 | * The tabs under the header. Each shows its own part of the sidebar: the |
| 3 | * groups whose pages fit its `match`. A page belongs to the tab whose |
| 4 | * `match` it fits. |
| 5 | */ |
| 6 | export type Tab = { label: string; href: string; match: (slug: string) => boolean }; |
| 7 | |
| 8 | export const TABS: Tab[] = [ |
| 9 | { |
| 10 | label: 'Documentation', |
| 11 | href: '/', |
| 12 | match: (slug) => !slug.startsWith('reference/'), |
| 13 | }, |
| 14 | { |
| 15 | label: 'API reference', |
| 16 | href: '/reference/api/', |
| 17 | match: (slug) => slug.startsWith('reference/'), |
| 18 | }, |
| 19 | ]; |
| 20 | |
| 21 | export function tabFor(slug: string): Tab { |
| 22 | return TABS.find((tab) => tab.match(slug)) ?? TABS[0]; |
| 23 | } |