pr_01m47d15m3e54sn21z27rpy5n9/apps/docs/src/tabs.ts

23 lines601 bytesCodeBlame
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 */
6export type Tab = { label: string; href: string; match: (slug: string) => boolean };
7
8export 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
21export function tabFor(slug: string): Tab {
22 return TABS.find((tab) => tab.match(slug)) ?? TABS[0];
23}