-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathsidebar.tsx
More file actions
173 lines (164 loc) · 6.39 KB
/
sidebar.tsx
File metadata and controls
173 lines (164 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { NavLink, useLocation } from 'react-router-dom';
import { cn } from '../../lib/utils';
interface SidebarLink {
title: string;
href: string;
}
interface SidebarSection {
title: string;
links: SidebarLink[];
}
const sections: SidebarSection[] = [
{
title: 'Getting Started',
links: [
{ title: 'Introduction', href: '/docs' },
{ title: 'Server-side / Node.js', href: '/docs/server-side' },
// { title: 'Releases', href: '/releases' },
],
},
{
title: 'Installation',
links: [{ title: 'Setup Guide', href: '/installation' }],
},
{
title: 'AI Tools',
links: [
{ title: 'MCP Server', href: '/mcp?tab=mcp' },
{ title: 'Skills File', href: '/mcp?tab=skills' },
],
},
{
title: 'Components',
links: [
{ title: 'Alert', href: '/components/alert' },
{ title: 'Badge', href: '/components/badge' },
{ title: 'Card', href: '/components/card' },
{ title: 'DataTable', href: '/components/data-table' },
{ title: 'Divider', href: '/components/divider' },
{ title: 'Form', href: '/components/form' },
{ title: 'Graph', href: '/components/graph' },
{ title: 'Heading', href: '/components/heading' },
{ title: 'Image', href: '/components/pdf-image' },
{ title: 'KeepTogether', href: '/components/keep-together' },
{ title: 'KeyValue', href: '/components/key-value' },
{ title: 'Link', href: '/components/link' },
{ title: 'List', href: '/components/list' },
{ title: 'PageBreak', href: '/components/page-break' },
{ title: 'PageFooter', href: '/components/page-footer' },
{ title: 'PageHeader', href: '/components/page-header' },
{ title: 'PageNumber', href: '/components/page-number' },
{ title: 'QRCode', href: '/components/qrcode' },
{ title: 'Section', href: '/components/section' },
{ title: 'Signature', href: '/components/signature' },
{ title: 'Stack', href: '/components/stack' },
{ title: 'Table', href: '/components/table' },
{ title: 'Text', href: '/components/text' },
{ title: 'Watermark', href: '/components/watermark' },
],
},
{
title: 'Blocks',
links: [
// { title: 'Overview', href: '/blocks' },
{ title: 'Invoices', href: '/blocks/invoices' },
{ title: 'Receipts', href: '/blocks/receipts' },
{ title: 'Reports', href: '/blocks/reports' },
],
},
];
export function Sidebar() {
const location = useLocation();
const isMCPPage = location.pathname.startsWith('/mcp');
const showSidebar =
location.pathname.startsWith('/docs') ||
location.pathname.startsWith('/releases') ||
location.pathname.startsWith('/components') ||
location.pathname.startsWith('/installation') ||
location.pathname.startsWith('/templates') ||
location.pathname.startsWith('/blocks') ||
isMCPPage;
const isComponentsIndex = location.pathname === '/components';
if (!showSidebar) return null;
// Determine active AI Tools link by checking search params
const activeHref = location.pathname + location.search;
return (
<aside className="hidden lg:block w-52 shrink-0 border-r">
<nav className="sticky top-16 h-[calc(100vh-4rem)] overflow-y-auto overflow-x-hidden py-6 pr-4 scrollbar-hide">
{sections.map((section, sectionIndex) => {
if (section.title === 'Components' && isComponentsIndex) {
return (
<div
key={section.title}
className={cn(sectionIndex > 0 && 'mt-6 pt-6 border-t border-border/60')}
>
<div className="mb-2 px-3 flex items-center gap-2">
<span className="w-1 h-3 rounded-full bg-primary/50 shrink-0" />
<h4 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
{section.title}
</h4>
</div>
<p className="px-3 text-xs text-muted-foreground/70">
Browse all components in the main view
</p>
</div>
);
}
return (
<div
key={section.title}
className={cn(sectionIndex > 0 && 'mt-6 pt-6 border-t border-border/60')}
>
<div className="mb-2 px-3 flex items-center gap-2">
<span className="w-1 h-3 rounded-full bg-primary/50 shrink-0" />
<h4 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
{section.title}
</h4>
</div>
<ul className="space-y-0.5">
{section.links.map((link) => {
// For AI Tools links, check if current tab matches
const isAIToolsLink = section.title === 'AI Tools';
const isActive = isAIToolsLink
? activeHref.includes(link.href.split('?')[1] ?? '') && isMCPPage
: undefined;
return (
<li key={link.href}>
{isAIToolsLink ? (
<NavLink
to={link.href}
className={cn(
'block rounded-md px-3 py-1.5 text-sm transition-colors',
isActive
? 'bg-accent text-accent-foreground font-medium'
: 'text-muted-foreground hover:text-foreground hover:bg-accent/50'
)}
>
{link.title}
</NavLink>
) : (
<NavLink
to={link.href}
className={({ isActive: navActive }) =>
cn(
'block rounded-md px-3 py-1.5 text-sm transition-colors',
navActive
? 'bg-accent text-accent-foreground font-medium'
: 'text-muted-foreground hover:text-foreground hover:bg-accent/50'
)
}
>
{link.title}
</NavLink>
)}
</li>
);
})}
</ul>
</div>
);
})}
</nav>
</aside>
);
}