@veluai/velu 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +80 -80
  2. package/dist/cli.js +18 -18
  3. package/package.json +3 -2
  4. package/runtime/velu-ui/components/Accordion.jsx +64 -64
  5. package/runtime/velu-ui/components/ApiClient.jsx +121 -121
  6. package/runtime/velu-ui/components/ApiField.jsx +87 -87
  7. package/runtime/velu-ui/components/ApiPath.jsx +63 -63
  8. package/runtime/velu-ui/components/ApiSidebar.jsx +122 -122
  9. package/runtime/velu-ui/components/AskBar.jsx +71 -71
  10. package/runtime/velu-ui/components/Callout.jsx +114 -114
  11. package/runtime/velu-ui/components/Card.jsx +131 -131
  12. package/runtime/velu-ui/components/Chatbot.jsx +596 -596
  13. package/runtime/velu-ui/components/CodeBlock.jsx +375 -375
  14. package/runtime/velu-ui/components/Columns.jsx +56 -56
  15. package/runtime/velu-ui/components/ErrorCard.jsx +138 -138
  16. package/runtime/velu-ui/components/Field.jsx +81 -81
  17. package/runtime/velu-ui/components/Image.jsx +163 -163
  18. package/runtime/velu-ui/components/MethodBadge.jsx +31 -31
  19. package/runtime/velu-ui/components/NavSelect.jsx +108 -108
  20. package/runtime/velu-ui/components/PageFeedback.jsx +219 -219
  21. package/runtime/velu-ui/components/PageFooter.jsx +213 -213
  22. package/runtime/velu-ui/components/PageHeader.jsx +414 -414
  23. package/runtime/velu-ui/components/PageNav.jsx +77 -77
  24. package/runtime/velu-ui/components/PoweredBy.jsx +51 -51
  25. package/runtime/velu-ui/components/Prompt.jsx +115 -115
  26. package/runtime/velu-ui/components/Search.jsx +411 -366
  27. package/runtime/velu-ui/components/Sidebar.jsx +191 -191
  28. package/runtime/velu-ui/components/Steps.jsx +65 -65
  29. package/runtime/velu-ui/components/ThemeToggle.jsx +48 -48
  30. package/runtime/velu-ui/components/Toc.jsx +537 -537
  31. package/runtime/velu-ui/components/TocBar.jsx +195 -195
  32. package/runtime/velu-ui/components/Tree.jsx +87 -87
  33. package/runtime/velu-ui/components/TryItBar.jsx +90 -90
  34. package/runtime/velu-ui/components/accordion.css +92 -92
  35. package/runtime/velu-ui/components/api.css +479 -479
  36. package/runtime/velu-ui/components/ask-bar.css +94 -94
  37. package/runtime/velu-ui/components/card.css +105 -105
  38. package/runtime/velu-ui/components/chatbot.css +617 -617
  39. package/runtime/velu-ui/components/code-block.css +263 -263
  40. package/runtime/velu-ui/components/docs-layout.css +784 -775
  41. package/runtime/velu-ui/components/field.css +82 -82
  42. package/runtime/velu-ui/components/image.css +237 -237
  43. package/runtime/velu-ui/components/nav-select.css +157 -157
  44. package/runtime/velu-ui/components/page-feedback.css +241 -241
  45. package/runtime/velu-ui/components/page-footer.css +130 -130
  46. package/runtime/velu-ui/components/page-header.css +520 -520
  47. package/runtime/velu-ui/components/page-nav.css +50 -50
  48. package/runtime/velu-ui/components/powered-by.css +66 -66
  49. package/runtime/velu-ui/components/prompt.css +99 -99
  50. package/runtime/velu-ui/components/search.css +307 -307
  51. package/runtime/velu-ui/components/sidebar.css +144 -144
  52. package/runtime/velu-ui/components/steps.css +77 -77
  53. package/runtime/velu-ui/components/theme-toggle.css +101 -101
  54. package/runtime/velu-ui/components/toc-bar.css +234 -234
  55. package/runtime/velu-ui/components/tree.css +49 -49
  56. package/runtime/velu-ui/index.js +46 -46
  57. package/runtime/velu-ui/lib/component-schemas.js +100 -100
  58. package/runtime/velu-ui/lib/copyText.js +64 -64
  59. package/runtime/velu-ui/lib/lang-icons.jsx +147 -147
  60. package/runtime/velu-ui/lib/prism-langs.js +957 -957
  61. package/runtime/velu-ui/lib/prism-loader.js +74 -74
  62. package/runtime/velu-ui/lib/resolveIcon.jsx +29 -29
  63. package/runtime/velu-ui/lib/scrollIntoNearestView.js +66 -66
  64. package/runtime/velu-ui/mdx-components.jsx +105 -105
  65. package/runtime/velu-ui/primitives/Cluster.jsx +49 -49
  66. package/runtime/velu-ui/primitives/Stack.jsx +63 -63
  67. package/runtime/velu-ui/primitives/Switcher.jsx +57 -57
  68. package/runtime/velu-ui/primitives/stack.css +3 -3
  69. package/runtime/velu-ui/primitives/switcher.css +25 -25
  70. package/runtime/velu-ui/styles.css +43 -43
  71. package/runtime/velu-ui/tokens.css +4 -4
  72. package/schema/velu.schema.json +167 -167
  73. package/src/lib/extract-mdx-error.js +170 -170
  74. package/src/lib/issues.js +159 -159
  75. package/src/lib/known-components.js +34 -34
  76. package/src/navigation.js +434 -434
  77. package/src/runtime/App.jsx +1490 -1476
  78. package/src/runtime/ErrorBoundary.jsx +54 -54
  79. package/src/runtime/client-entry.jsx +22 -22
  80. package/src/runtime/server-entry.jsx +16 -16
  81. package/src/template.html +48 -48
  82. package/templates/starter/ai-tools/claude-code.mdx +26 -26
  83. package/templates/starter/ai-tools/cursor.mdx +17 -17
  84. package/templates/starter/api-reference/endpoint/create.mdx +24 -24
  85. package/templates/starter/api-reference/endpoint/get.mdx +27 -27
  86. package/templates/starter/api-reference/introduction.mdx +28 -28
  87. package/templates/starter/development.mdx +19 -19
  88. package/templates/starter/essentials/code.mdx +29 -29
  89. package/templates/starter/essentials/images.mdx +29 -29
  90. package/templates/starter/essentials/markdown.mdx +25 -25
  91. package/templates/starter/essentials/navigation.mdx +39 -39
  92. package/templates/starter/essentials/settings.mdx +30 -30
  93. package/templates/starter/favicon.svg +6 -6
  94. package/templates/starter/index.mdx +31 -31
  95. package/templates/starter/quickstart.mdx +31 -31
  96. package/templates/starter/velu.json +33 -33
@@ -1,1476 +1,1490 @@
1
- import React from 'react';
2
- import { Routes, Route, useLocation, Link } from 'react-router-dom';
3
- import { MDXProvider } from '@mdx-js/react';
4
- // The project's pages + navigation, generated from velu.json by
5
- // vite-plugin-velu-site (see src/vite-plugin-velu-site.js). `pages` is
6
- // url → { Component, frontmatter, toc } (or { missing:true }).
7
- import { pages, navigation } from 'virtual:velu-site';
8
- import { resolve, normalizeUrl } from '../navigation.js';
9
- import {
10
- Stack,
11
- Cluster,
12
- ThemeToggle,
13
- Sidebar,
14
- NavSelect,
15
- Toc,
16
- TocBar,
17
- Callout,
18
- Accordion,
19
- AccordionGroup,
20
- Card,
21
- CardGroup,
22
- Switcher,
23
- Image,
24
- CodeBlock,
25
- CodeGroup,
26
- Columns,
27
- Field,
28
- Prompt,
29
- Steps,
30
- Step,
31
- AskBar,
32
- Chatbot,
33
- PageFeedback,
34
- PageNav,
35
- PageFooter,
36
- PageHeader,
37
- PoweredBy,
38
- defaultMdxComponents,
39
- resolveIcon,
40
- Search,
41
- Tree,
42
- Folder,
43
- File,
44
- TryItBar,
45
- ApiClient,
46
- ApiField,
47
- ApiSidebar,
48
- VeluMark,
49
- } from 'velu-ui';
50
- import { X, ChevronDown, ChevronUp } from 'lucide-react';
51
- import ErrorBoundary from './ErrorBoundary.jsx';
52
-
53
- const CALLOUT_TYPES = [
54
- 'note',
55
- 'warning',
56
- 'info',
57
- 'tip',
58
- 'check',
59
- 'danger',
60
- 'callout',
61
- ];
62
-
63
- function CalloutGallery() {
64
- return (
65
- <Stack space="var(--s0)">
66
- {CALLOUT_TYPES.map((t) => (
67
- <Callout key={t} type={t}>
68
- This is a {t}. This is a {t}. This is a {t}. This is a {t}.
69
- </Callout>
70
- ))}
71
- <p style={{ color: 'var(--muted-color)' }}>
72
- Custom callouts can be built with a custom icon &amp; color:
73
- </p>
74
- <Callout
75
- icon="sparkles"
76
- stroke="var(--accent-color)"
77
- bg="color-mix(in srgb, var(--accent-color) 8%, transparent)"
78
- >
79
- A custom callout — lucide id <code>"sparkles"</code> with custom{' '}
80
- <code>stroke</code> &amp; <code>bg</code>.
81
- </Callout>
82
-
83
- <Callout type="info">
84
- This is a multi-line callout. It keeps going and going so the text
85
- wraps onto several lines the icon sits on the first line, the text
86
- wraps beside it, and every line after flows back under the icon (no
87
- hanging indent). Resize the window to watch the wrapping reflow while
88
- the icon stays put on line one. This is a multi-line callout. It keeps
89
- going so the text wraps onto several lines.
90
- </Callout>
91
- </Stack>
92
- );
93
- }
94
-
95
- function AccordionDemo() {
96
- return (
97
- <Stack space="var(--s1)">
98
- <Accordion title="This is an accordion">
99
- This is content inside the accordion. Hover the header to see the
100
- surface tint; the chevron rotates when expanded.
101
- </Accordion>
102
- <Accordion title="This is an accordion (open by default)" defaultOpen>
103
- This one renders expanded — header takes the surface tint and a
104
- divider separates it from this content.
105
- </Accordion>
106
- <AccordionGroup>
107
- <Accordion title="This is an accordion">
108
- Grouped items share one bordered box with dividers between them.
109
- </Accordion>
110
- <Accordion title="This is an accordion" defaultOpen>
111
- This is content inside the accordion.
112
- </Accordion>
113
- <Accordion title="This is an accordion">
114
- No per-item border or radius the group owns the chrome.
115
- </Accordion>
116
- </AccordionGroup>
117
- </Stack>
118
- );
119
- }
120
-
121
- function CardDemo() {
122
- return (
123
- <Stack space="var(--s2)">
124
- <Card icon="align-justify" title="Card Title">
125
- This is how you use a card with an icon and a link. (Cards are not
126
- clickable — only the CTA card's link is.)
127
- </Card>
128
-
129
- <Card icon="align-justify" title="Card Title" horizontal>
130
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
131
- tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
132
- veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
133
- commodo consequat.
134
- </Card>
135
-
136
- <Card
137
- img="https://picsum.photos/seed/velu/1200/560"
138
- imgAlt="Yosemite valley"
139
- title="Card Title"
140
- >
141
- This is how you use a card with an icon. The image fills the container
142
- and is clipped to the card radius.
143
- </Card>
144
-
145
- <Card
146
- icon="align-justify"
147
- title="Card Title"
148
- cta={{ label: 'Click Here', href: '#cards' }}
149
- >
150
- This is how you use a card with an icon and a link. The "Click Here"
151
- link below is the only clickable element.
152
- </Card>
153
-
154
- <CardGroup>
155
- <Card icon="align-justify" title="Card Title">
156
- This is how you use a card with an icon and a link.
157
- </Card>
158
- <Card icon="align-justify" title="Card Title">
159
- This is how you use a card with an icon and a link.
160
- </Card>
161
- </CardGroup>
162
- </Stack>
163
- );
164
- }
165
-
166
- function SwitcherBox({ children }) {
167
- return (
168
- <div
169
- style={{
170
- border: 'var(--border-width) solid var(--border-color)',
171
- borderRadius: 'var(--radius-sm)',
172
- padding: 'var(--s0) var(--s3)',
173
- }}
174
- >
175
- {children}
176
- </div>
177
- );
178
- }
179
-
180
- function SwitcherDemo() {
181
- return (
182
- <Stack space="var(--s1)">
183
- <p style={{ color: 'var(--muted-color)' }}>
184
- Resize the window — these flip between a row and a column at the
185
- container threshold, with no media queries.
186
- </p>
187
- <Switcher space="var(--s0)" threshold="30rem">
188
- <SwitcherBox>One</SwitcherBox>
189
- <SwitcherBox>Two</SwitcherBox>
190
- <SwitcherBox>Three</SwitcherBox>
191
- </Switcher>
192
- <p style={{ color: 'var(--muted-color)' }}>
193
- With <code>limit={2}</code>: more than 2 items forces vertical
194
- regardless of width.
195
- </p>
196
- <Switcher space="var(--s0)" threshold="30rem" limit={2}>
197
- <SwitcherBox>One</SwitcherBox>
198
- <SwitcherBox>Two</SwitcherBox>
199
- <SwitcherBox>Three</SwitcherBox>
200
- </Switcher>
201
- </Stack>
202
- );
203
- }
204
-
205
- const DEMO_JS = `let greeting = function (name) {
206
- console.log(\`Hello, \${name}!\`);
207
- };`;
208
- const DEMO_RB = `def greeting(name)
209
- puts "Hello, #{name}!"
210
- end`;
211
- const DEMO_PY = `def greeting(name):
212
- print(f"Hello, {name}!")`;
213
-
214
- function CodeBlockDemo() {
215
- return (
216
- <Stack space="var(--s2)">
217
- <p style={{ color: 'var(--muted-color)' }}>Code Group</p>
218
- <CodeGroup>
219
- <CodeBlock title="Javascript" language="javascript">
220
- {DEMO_JS}
221
- </CodeBlock>
222
- <CodeBlock title="Ruby" language="ruby">
223
- {DEMO_RB}
224
- </CodeBlock>
225
- <CodeBlock title="Python" language="python">
226
- {DEMO_PY}
227
- </CodeBlock>
228
- </CodeGroup>
229
-
230
- <p style={{ color: 'var(--muted-color)' }}>Code (with file name)</p>
231
- <CodeBlock filename="index.js" language="javascript">
232
- {DEMO_JS}
233
- </CodeBlock>
234
-
235
- <p style={{ color: 'var(--muted-color)' }}>
236
- With line numbers (icon suppressed via <code>withIcon={'{false}'}</code>)
237
- </p>
238
- <CodeBlock
239
- filename="index.js"
240
- language="javascript"
241
- withIcon={false}
242
- lineNumbers
243
- >
244
- {DEMO_JS}
245
- </CodeBlock>
246
-
247
- <p style={{ color: 'var(--muted-color)' }}>
248
- Line highlight — single line (<code>highlight="2"</code>)
249
- </p>
250
- <CodeBlock
251
- filename="index.js"
252
- language="javascript"
253
- lineNumbers
254
- highlight="2"
255
- >
256
- {DEMO_JS}
257
- </CodeBlock>
258
-
259
- <p style={{ color: 'var(--muted-color)' }}>
260
- Line highlight — range + single (<code>highlight="1-2,4"</code>)
261
- </p>
262
- <CodeBlock
263
- filename="server.js"
264
- language="javascript"
265
- lineNumbers
266
- highlight="1-2,4"
267
- >
268
- {`const express = require('express');
269
- const app = express();
270
-
271
- app.get('/', (req, res) => res.send('Hello'));
272
-
273
- app.listen(3000);`}
274
- </CodeBlock>
275
- </Stack>
276
- );
277
- }
278
-
279
- function ApiDemo() {
280
- const path = '/project/preview/{projectId}';
281
- const curl = `curl --request POST \\
282
- --url https://api.mintlify.com/v1/project/update/{projectId} \\
283
- --header 'Authorization: Bearer <token>'`;
284
- return (
285
- <Stack space="var(--s2)">
286
- <p style={{ color: 'var(--muted-color)' }}>Try-it bar</p>
287
- <Stack space="var(--s-1)">
288
- <TryItBar method="POST" path={path} />
289
- <TryItBar method="GET" path={path} />
290
- <TryItBar method="PUT" path={path} />
291
- <TryItBar method="DELETE" path={path} />
292
- <TryItBar method="PATCH" path={path} />
293
- </Stack>
294
-
295
- <p style={{ color: 'var(--muted-color)' }}>API sidebar</p>
296
- <ApiSidebar
297
- activeHref="/api/status"
298
- sections={[
299
- {
300
- title: 'Admin',
301
- icon: 'rocket',
302
- endpoints: [
303
- { method: 'POST', label: 'Trigger', href: '/api/trigger' },
304
- {
305
- method: 'GET',
306
- label: 'Get deployment-status',
307
- href: '/api/status',
308
- },
309
- {
310
- method: 'DELETE',
311
- label: 'Trigger Preview deployment',
312
- href: '/api/preview',
313
- },
314
- ],
315
- },
316
- ]}
317
- />
318
-
319
- <p style={{ color: 'var(--muted-color)' }}>API Client</p>
320
- {/* Only the ApiClient breaks out of the 46rem prose column — the
321
- TryItBars above stay at the normal column width. clamp keeps
322
- it ≥ 100% (so it never collapses when the main-area calc goes
323
- negative on narrow screens) and ≤ 64rem. */}
324
- <div
325
- style={{
326
- width:
327
- 'clamp(100%, calc(100vw - 240px - 280px - var(--s4) * 2), 64rem)',
328
- }}
329
- >
330
- <ApiClient
331
- method="DELETE"
332
- label="Trigger Delete"
333
- path={path}
334
- onClose={() => {}}
335
- description="Trigger a documentation deployment programmatically to publish updates outside of Git workflows."
336
- aside={
337
- <Stack space="var(--s1)">
338
- <Callout type="danger">401 — Unauthorized</Callout>
339
- <CodeGroup>
340
- <CodeBlock title="Response" language="json">
341
- {`{\n "status": 401,\n "error": "Unauthorized"\n}`}
342
- </CodeBlock>
343
- <CodeBlock title="Headers" language="http">
344
- {`HTTP/1.1 401 Unauthorized
345
- date: Mon, 27 Apr 2026 12:00:55 GMT
346
- content-type: application/json; charset=utf-8
347
- content-length: 24
348
- connection: close
349
- x-powered-by: Express
350
- access-control-allow-origin: *`}
351
- </CodeBlock>
352
- </CodeGroup>
353
- <CodeGroup>
354
- <CodeBlock title="Curl" language="bash">
355
- {curl}
356
- </CodeBlock>
357
- <CodeBlock title="Ruby" language="ruby">
358
- {`require 'net/http'
359
- uri = URI('https://api.mintlify.com/v1/project/update/<projectId>')
360
- req = Net::HTTP::Post.new(uri)
361
- req['Authorization'] = 'Bearer <token>'
362
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }`}
363
- </CodeBlock>
364
- <CodeBlock title="Python" language="python">
365
- {`import requests
366
- requests.post(
367
- 'https://api.mintlify.com/v1/project/update/<projectId>',
368
- headers={'Authorization': 'Bearer <token>'},
369
- )`}
370
- </CodeBlock>
371
- </CodeGroup>
372
- <CodeGroup>
373
- <CodeBlock title="202" language="json">
374
- {`{\n "statusId": "<string>"\n}`}
375
- </CodeBlock>
376
- <CodeBlock title="200" language="json">
377
- {`{\n "statusId": "<string>",\n "completedAt": "2026-04-27T12:00:55Z"\n}`}
378
- </CodeBlock>
379
- </CodeGroup>
380
- </Stack>
381
- }
382
- >
383
- <AccordionGroup>
384
- <Accordion title="Authorization" defaultOpen>
385
- <Stack space="var(--s1)">
386
- <ApiField
387
- name="Authorization"
388
- type="string"
389
- required
390
- prefix="Bearer"
391
- >
392
- The Authorization header expects a Bearer token. Use an
393
- admin API key (prefixed with <code>mint_</code>).
394
- </ApiField>
395
- </Stack>
396
- </Accordion>
397
- <Accordion title="Path" defaultOpen>
398
- <Stack space="var(--s1)">
399
- <ApiField name="projectId" type="string" required>
400
- Your project ID. Copy it from the API keys page.
401
- </ApiField>
402
- <ApiField name="bodyId" type="string" required>
403
- Your body ID. Copy it from the API keys page.
404
- </ApiField>
405
- </Stack>
406
- </Accordion>
407
- <Accordion title="Query">
408
- <Stack space="var(--s1)">
409
- <ApiField name="branch" type="string">
410
- Git branch to deploy. Defaults to the production branch.
411
- </ApiField>
412
- <ApiField name="dryRun" type="boolean" default="false">
413
- When true, validates the deployment without publishing.
414
- </ApiField>
415
- </Stack>
416
- </Accordion>
417
- <Accordion title="Headers">
418
- <Stack space="var(--s1)">
419
- <ApiField name="X-Idempotency-Key" type="string">
420
- Optional unique key so retried requests don't trigger
421
- duplicate deployments.
422
- </ApiField>
423
- </Stack>
424
- </Accordion>
425
- <Accordion title="Body">
426
- <Stack space="var(--s1)">
427
- <ApiField name="message" type="string">
428
- Deployment message shown in the activity log.
429
- </ApiField>
430
- <ApiField name="notify" type="boolean" default="true">
431
- Whether to notify when the deployment completes.
432
- </ApiField>
433
- </Stack>
434
- </Accordion>
435
- </AccordionGroup>
436
- </ApiClient>
437
- </div>
438
- </Stack>
439
- );
440
- }
441
-
442
- function TreeDemo() {
443
- return (
444
- <Tree>
445
- <Folder name="app">
446
- <File name="layout.tsx" />
447
- <File name="page.tsx" />
448
- <Folder name="api" defaultOpen={false}>
449
- <File name="route.ts" />
450
- </Folder>
451
- </Folder>
452
- <File name="package.json" />
453
- </Tree>
454
- );
455
- }
456
-
457
- function StepsDemo() {
458
- return (
459
- <Steps>
460
- <Step title="Install the CLI">Run the install script.</Step>
461
- <Step title="Bootstrap a new project">
462
- Scaffold a fresh velu project with a single command, then drop in the
463
- starter MDX so you can begin editing right away. The CLI prompts for a
464
- project name and target directory, copies the template files, and
465
- installs dependencies in the background while you keep working.
466
- </Step>
467
- <Step title="Add your first page">
468
- Drop an MDX file into the <code>content/</code> directory.
469
- </Step>
470
- <Step title="Configure navigation">
471
- Edit <code>velu.config.js</code> and add your page paths under the
472
- sidebar tree. Nested groups are supported, every item can carry an
473
- icon, and external links are flagged automatically. Save the file and
474
- the dev server hot-reloads with the new structure.
475
- </Step>
476
- <Step title="Preview locally">
477
- Run <code>velu dev</code> the local preview opens at
478
- <code> localhost:5173</code> with SSR + HMR. Edits to any MDX or React
479
- component reflect instantly. The right-rail TOC is generated from the
480
- page's headings; the comet trail follows scroll.
481
- </Step>
482
- <Step title="Push and ship">Open a PR. Done.</Step>
483
- </Steps>
484
- );
485
- }
486
-
487
- function PromptDemo() {
488
- return (
489
- <Prompt title="Generate clear, concise documentation." openInCursor>
490
- {`You are a **technical writing assistant**. Write documentation that is clear, accurate, and concise.
491
- - Use second-person voice
492
- - Avoid jargon
493
- - Lead with what the reader can do, not how it works internally
494
- - Code blocks use the project's language conventions
495
- - Every example must be runnable as-is`}
496
- </Prompt>
497
- );
498
- }
499
-
500
- function FieldDemo() {
501
- const desc =
502
- 'An example of a parameter field. An example of a parameter field. An example of a parameter field. An example of a parameter field. An example of a parameter field. An example of a parameter field';
503
- return (
504
- <div>
505
- <Field
506
- name="param"
507
- pre="pre"
508
- type="string"
509
- required
510
- default={3}
511
- post="post"
512
- >
513
- {desc}
514
- </Field>
515
- <Field
516
- name="param"
517
- pre="pre"
518
- type="string"
519
- required
520
- default={3}
521
- post="post"
522
- >
523
- {desc}
524
- </Field>
525
- <Field
526
- name="param"
527
- pre="pre"
528
- type="string"
529
- required
530
- default={3}
531
- post="post"
532
- >
533
- {desc}
534
- </Field>
535
- </div>
536
- );
537
- }
538
-
539
- function ColumnsDemo() {
540
- return (
541
- <Stack space="var(--s2)">
542
- <p style={{ color: 'var(--muted-color)' }}>
543
- Two equal columns (<code>cols=&#123;2&#125;</code>) — collapses to a
544
- single stack when items would fall below their per-item min width.
545
- </p>
546
- <Columns cols={2}>
547
- <Card
548
- icon="align-justify"
549
- title="Card Title"
550
- cta={{ label: 'Click Here', href: '#columns' }}
551
- >
552
- This is how you use a card with an icon and a link. Clicking on
553
- this card brings you to the Columns page.
554
- </Card>
555
- <Card
556
- icon="align-justify"
557
- title="Card Title"
558
- cta={{ label: 'Click Here', href: '#columns' }}
559
- >
560
- This is how you use a card with an icon and a link. Clicking on
561
- this card brings you to the Columns page.
562
- </Card>
563
- </Columns>
564
-
565
- <p style={{ color: 'var(--muted-color)' }}>
566
- Heterogeneous children a Card alongside a CodeBlock.
567
- </p>
568
- <Columns cols={2}>
569
- <Card icon="sparkles" title="With a card">
570
- Cards, callouts, code, images — anything composes in a column.
571
- </Card>
572
- <CodeBlock filename="hello.js" language="javascript">
573
- {DEMO_JS}
574
- </CodeBlock>
575
- </Columns>
576
-
577
- <p style={{ color: 'var(--muted-color)' }}>
578
- Three columns (<code>cols=&#123;3&#125;</code>) with a stacked column
579
- in the middle.
580
- </p>
581
- <Columns cols={3}>
582
- <Card icon="rocket" title="Left">
583
- Single card on the left.
584
- </Card>
585
- <Stack space="var(--s0)">
586
- <Card icon="book" title="Top">
587
- Two cards stacked via Stack inside one column.
588
- </Card>
589
- <Card icon="brain" title="Bottom">
590
- Stack lets a column carry heterogeneous, multi-item content.
591
- </Card>
592
- </Stack>
593
- <Card icon="zap" title="Right">
594
- Single card on the right.
595
- </Card>
596
- </Columns>
597
- </Stack>
598
- );
599
- }
600
-
601
- const DEMO_IMG = 'https://picsum.photos/seed/velu-yosemite/1200/600';
602
- const DEMO_SHOT = 'https://picsum.photos/seed/velu-shot/600/1000';
603
-
604
- function ImageDemo() {
605
- return (
606
- <Stack space="var(--s2)">
607
- <p style={{ color: 'var(--muted-color)' }}>Image</p>
608
- <Image src={DEMO_IMG} alt="" />
609
-
610
- <p style={{ color: 'var(--muted-color)' }}>
611
- Image with caption (caption can be markdown later)
612
- </p>
613
- <Image src={DEMO_IMG} alt="" caption="Caption for this image" />
614
-
615
- <p style={{ color: 'var(--muted-color)' }}>Image with window chrome</p>
616
- <Image src={DEMO_IMG} alt="" chrome="window" />
617
-
618
- <p style={{ color: 'var(--muted-color)' }}>Image with display frame</p>
619
- <Image src={DEMO_SHOT} alt="" chrome="frame" caption="Caption can also be added" />
620
- </Stack>
621
- );
622
- }
623
-
624
- const RouterLink = ({ href, ...rest }) => <Link to={href} {...rest} />;
625
-
626
- // Flatten a nested TOC tree to {id, label, depth} for scroll-spy.
627
- function flat(nodes, depth = 0, out = []) {
628
- for (const n of nodes) {
629
- out.push({ id: n.id, label: n.label, depth });
630
- if (n.children) flat(n.children, depth + 1, out);
631
- }
632
- return out;
633
- }
634
-
635
- // Scroll-spy: active = the section whose top last crossed the trigger line.
636
- /**
637
- * useScrollSpy — tracks the section currently in view, with an
638
- * explicit "lock" override for click-driven scrolls.
639
- *
640
- * Without the lock, clicking a TOC item triggers a smooth-scroll
641
- * animation; during the ~500ms animation the scroll listener fires
642
- * many times with the page at intermediate positions, and the
643
- * "closest section" answer flickers across multiple sections
644
- * before settling visible as the TocBar label briefly showing
645
- * the wrong heading. The lock blocks spy updates for a configurable
646
- * window so the click's intended `activeId` survives the animation.
647
- *
648
- * Returns `[activeId, setActive]` where `setActive(id)` writes the
649
- * active id directly AND locks the spy for ~800ms.
650
- */
651
- function useScrollSpy(ids) {
652
- const [activeId, setActiveId] = React.useState(ids[0]);
653
- const lockUntilRef = React.useRef(0);
654
- React.useEffect(() => {
655
- const onScroll = () => {
656
- if (Date.now() < lockUntilRef.current) return;
657
- // Trigger line reads from --velu-scroll-offset (published by
658
- // App.jsx as header + tocbar-toggle + 1rem). Same offset CSS
659
- // uses for scroll-margin, so a heading freshly scrolled into
660
- // view sits exactly at the trigger. Semantics: pick the
661
- // section whose top is CLOSEST to the trigger; tie-break
662
- // favours later sections in document order.
663
- const trigger =
664
- parseFloat(
665
- getComputedStyle(document.documentElement).getPropertyValue(
666
- '--velu-scroll-offset',
667
- ),
668
- ) || 0;
669
- const vh = window.innerHeight;
670
- let best = ids[0];
671
- let bestDist = Infinity;
672
- for (const id of ids) {
673
- const node = document.getElementById(id);
674
- if (!node) continue;
675
- const top = node.getBoundingClientRect().top;
676
- if (top >= vh) continue;
677
- const dist = Math.abs(top - trigger);
678
- if (dist <= bestDist) {
679
- bestDist = dist;
680
- best = id;
681
- }
682
- }
683
- setActiveId(best);
684
- };
685
- window.addEventListener('scroll', onScroll, { passive: true });
686
- onScroll();
687
- return () => window.removeEventListener('scroll', onScroll);
688
- }, [ids]);
689
-
690
- const setActive = React.useCallback((id) => {
691
- setActiveId(id);
692
- // ~800ms covers the default smooth-scroll animation duration.
693
- lockUntilRef.current = Date.now() + 800;
694
- }, []);
695
-
696
- return [activeId, setActive];
697
- }
698
-
699
- // Slugger used for the frontmatter-derived h1 id — same library as
700
- // extract-toc + rehype-slug, so the id we render in the DOM matches
701
- // what the TOC's `pageId` will compute. (One instance per page render
702
- // is fine; the slugger is stateful only across calls on the SAME
703
- // instance.)
704
- import GithubSlugger from 'github-slugger';
705
-
706
- function DocsPage() {
707
- // Resolve the current route page entry + navigation context. Both
708
- // SSR and client compute these from the same pathname + the same
709
- // shared `resolve()`, so the render is identical (hydration-safe).
710
- const location = useLocation();
711
- const pathname = normalizeUrl(location.pathname);
712
- const entry = pages[pathname];
713
- const nav = React.useMemo(
714
- () => resolve(pathname, navigation, pages),
715
- [pathname],
716
- );
717
-
718
- const frontmatter = entry?.frontmatter ?? {};
719
- const PageComponent = entry?.Component ?? null;
720
- const pageToc = entry?.toc ?? [];
721
-
722
- // Switcher option sets (only render a switcher when an axis has >1
723
- // option). Anchors are pinned sidebar links shown in the context zone.
724
- const productOptions = nav?.products ?? [];
725
- const versionOptions = nav?.versions ?? [];
726
- const languageOptions = nav?.languages ?? [];
727
- const anchors = nav?.anchors ?? [];
728
- const versionSwitcher = versionOptions.length > 1 && (
729
- <NavSelect
730
- size="sm"
731
- value={nav.activeVersion}
732
- options={versionOptions}
733
- linkComponent={RouterLink}
734
- ariaLabel="Version"
735
- />
736
- );
737
- const languageSwitcher = languageOptions.length > 1 && (
738
- <NavSelect
739
- bare
740
- icon="globe"
741
- value={nav.activeLanguage}
742
- valueCode={nav.activeLanguageCode}
743
- options={languageOptions}
744
- linkComponent={RouterLink}
745
- ariaLabel="Language"
746
- />
747
- );
748
- const productSwitcher = productOptions.length > 1 && (
749
- <NavSelect
750
- value={nav.activeProduct}
751
- options={productOptions}
752
- linkComponent={RouterLink}
753
- ariaLabel="Product"
754
- />
755
- );
756
-
757
- // Frontmatter title needs an id so scroll-spy + click-to-scroll work
758
- // against it like any other heading.
759
- const pageId = React.useMemo(() => {
760
- if (!frontmatter.title) return null;
761
- return new GithubSlugger().slug(frontmatter.title);
762
- }, [frontmatter.title]);
763
-
764
- // Combined TOC: the frontmatter title is the page's top-level entry,
765
- // and the MDX-derived headings (h2s) become its children. Without this,
766
- // the right rail starts from the first h2 — orphaning the page title
767
- // that sits visibly above the article.
768
- const toc = React.useMemo(() => {
769
- if (!frontmatter.title || !pageId) return pageToc;
770
- return [{ id: pageId, label: frontmatter.title, children: pageToc }];
771
- }, [pageId, frontmatter.title, pageToc]);
772
-
773
- // Flat list of section ids for scroll-spy — sourced from the same
774
- // nested TOC tree we pass to the right-rail <Toc>, so spy + render
775
- // can't drift out of sync with the MDX content.
776
- const ids = React.useMemo(() => flat(toc).map((s) => s.id), [toc]);
777
- const [activeId, setActive] = useScrollSpy(ids);
778
-
779
- // Ask-AI chatbot: opens (slides in from the side) when a question is
780
- // submitted in the AskBar. While it's open the TOC is hidden.
781
- const [chatOpen, setChatOpen] = React.useState(false);
782
- const [chatQuestion, setChatQuestion] = React.useState('');
783
-
784
- // Left sidebar open/closed (narrow widths) — chevron toggle. Defaults
785
- // open per design; safe to default true since the narrow-width
786
- // sidebar is in-flow and doesn't obscure content.
787
- const [sidebarOpen, setSidebarOpen] = React.useState(true);
788
- // Mobile drawer open/closed (< 640px) — burger / breadcrumb / X /
789
- // scrim drive this. Defaults closed so refreshing the page at
790
- // mobile doesn't surface the drawer over the article. Independent
791
- // of sidebarOpen so neither breakpoint's default leaks into the
792
- // other.
793
- const [drawerOpen, setDrawerOpen] = React.useState(false);
794
-
795
- // Drawer's nav dropdown list of section links (Home/Docs/Blog),
796
- // mirrors the desktop tabs. Click-outside + Escape close.
797
- const [navOpen, setNavOpen] = React.useState(false);
798
- const navRef = React.useRef(null);
799
- React.useEffect(() => {
800
- if (!navOpen) return;
801
- const onDocClick = (e) => {
802
- if (!navRef.current?.contains(e.target)) setNavOpen(false);
803
- };
804
- const onKey = (e) => {
805
- if (e.key === 'Escape') setNavOpen(false);
806
- };
807
- document.addEventListener('mousedown', onDocClick);
808
- document.addEventListener('keydown', onKey);
809
- return () => {
810
- document.removeEventListener('mousedown', onDocClick);
811
- document.removeEventListener('keydown', onKey);
812
- };
813
- }, [navOpen]);
814
- // Mobile drawer's section picker = the resolved tabs (top-level
815
- // navigation), so it mirrors the desktop tabs row instead of a
816
- // hardcoded list. Its button shows the active tab's label.
817
- const navItems = nav?.tabs ?? [];
818
- const activeNavLabel =
819
- navItems.find((t) => t.href === nav?.activeTab)?.label ??
820
- navItems[0]?.label ??
821
- '';
822
- const askAI = React.useCallback((q) => {
823
- setChatQuestion(q);
824
- setChatOpen(true);
825
- }, []);
826
-
827
- // Measure the live sticky chrome — header + (collapsed) TocBar
828
- // toggle and publish three CSS variables on `:root`:
829
- //
830
- // --velu-header-height live header height
831
- // --velu-tocbar-height TocBar's TOGGLE row height (always-
832
- // visible bit; 0 when the bar isn't shown)
833
- // --velu-scroll-offset header + tocbar-toggle + 1rem
834
- //
835
- // Measuring just the toggle row (NOT the expanded list) is
836
- // important: the expanded dropdown's max-block-size is large, and
837
- // including it in the offset would inflate scroll-margin /
838
- // scroll-spy trigger as soon as the user expands the dropdown —
839
- // causing the page geometry to lurch and the spy / active label
840
- // to flicker.
841
- React.useEffect(() => {
842
- if (typeof window === 'undefined') return;
843
- const header = document.querySelector('.velu-header');
844
- if (!header) return;
845
- const root = document.documentElement;
846
- const remPx = parseFloat(getComputedStyle(root).fontSize) || 16;
847
- const apply = () => {
848
- const headerH = header.getBoundingClientRect().height;
849
- // Re-query each apply — the TocBar toggle button is mounted
850
- // after first paint and its parent may also remount on
851
- // theme/viewport changes.
852
- const tocBarToggle = document.querySelector('.velu-toc-bar__toggle');
853
- const tocBarH = tocBarToggle
854
- ? tocBarToggle.getBoundingClientRect().height
855
- : 0;
856
- if (headerH > 0)
857
- root.style.setProperty('--velu-header-height', `${headerH}px`);
858
- root.style.setProperty('--velu-tocbar-height', `${tocBarH}px`);
859
- // +1rem of breathing room between the chrome and the heading
860
- // it's anchoring. The rem is read live so it stays in tokens.
861
- root.style.setProperty(
862
- '--velu-scroll-offset',
863
- `${headerH + tocBarH + remPx}px`,
864
- );
865
- };
866
- apply();
867
- const ro = new ResizeObserver(apply);
868
- ro.observe(header);
869
- // Observe the toggle row only (not the expanded list) so the
870
- // offset stays put when the user opens the dropdown.
871
- const tocBarToggle = document.querySelector('.velu-toc-bar__toggle');
872
- if (tocBarToggle) ro.observe(tocBarToggle);
873
- return () => ro.disconnect();
874
- }, []);
875
-
876
- // The asides (left sidebar + right TOC) scroll independently of the
877
- // page. On scroll/resize we set data-fade-top/-bottom on each scroll
878
- // region so CSS can fade its edges (and reveal the nav arrows) only
879
- // when there's content beyond them. Written imperatively (no
880
- // re-render). Re-binds on chatOpen toggle (the right TOC
881
- // mounts/unmounts with it).
882
- const leftAsideRef = React.useRef(null);
883
- const rightAsideRef = React.useRef(null);
884
- React.useEffect(() => {
885
- const els = [leftAsideRef.current, rightAsideRef.current].filter(Boolean);
886
- if (!els.length) return;
887
- const update = () => {
888
- for (const el of els) {
889
- el.dataset.fadeTop = el.scrollTop > 0 ? 'true' : 'false';
890
- el.dataset.fadeBottom =
891
- el.scrollTop + el.clientHeight < el.scrollHeight - 1
892
- ? 'true'
893
- : 'false';
894
- }
895
- };
896
- update();
897
- // Recompute on scroll AND on any size change of the scroll region
898
- // or its content (ResizeObserver) + window resize — so the fade
899
- // reflects hidden content persistently, not just during a scroll
900
- // gesture (e.g. after a route change shifts the nav's height).
901
- const ro = new ResizeObserver(update);
902
- els.forEach((el) => {
903
- el.addEventListener('scroll', update, { passive: true });
904
- ro.observe(el);
905
- if (el.firstElementChild) ro.observe(el.firstElementChild);
906
- });
907
- window.addEventListener('resize', update);
908
- return () => {
909
- els.forEach((el) => el.removeEventListener('scroll', update));
910
- ro.disconnect();
911
- window.removeEventListener('resize', update);
912
- };
913
- }, [chatOpen, pathname]);
914
-
915
- // Flag the sidebar section heading currently pinned at the top of the
916
- // scroll region (CSS sticky gives no "is-stuck" hook). When the pinned
917
- // heading changes as you scroll, the new one gets data-stuck and
918
- // animates in (see sidebar.css). Re-binds on page/tab change since the
919
- // section set changes with it.
920
- React.useEffect(() => {
921
- const scroller = leftAsideRef.current;
922
- if (!scroller) return;
923
- let prev = null;
924
- const update = () => {
925
- const top = scroller.getBoundingClientRect().top;
926
- let stuck = null;
927
- for (const h of scroller.querySelectorAll('.velu-sidebar__section')) {
928
- if (h.getBoundingClientRect().top <= top + 1) stuck = h;
929
- }
930
- if (stuck !== prev) {
931
- prev?.removeAttribute('data-stuck');
932
- stuck?.setAttribute('data-stuck', 'true');
933
- prev = stuck;
934
- }
935
- };
936
- update();
937
- scroller.addEventListener('scroll', update, { passive: true });
938
- return () => scroller.removeEventListener('scroll', update);
939
- }, [pathname, chatOpen]);
940
-
941
- const footerRef = React.useRef(null);
942
- const [footerOverlap, setFooterOverlap] = React.useState(0);
943
- React.useEffect(() => {
944
- const node = footerRef.current;
945
- if (!node) return;
946
- const update = () => {
947
- const rect = node.getBoundingClientRect();
948
- setFooterOverlap(Math.max(0, window.innerHeight - rect.top));
949
- };
950
- update();
951
- window.addEventListener('scroll', update, { passive: true });
952
- window.addEventListener('resize', update);
953
- return () => {
954
- window.removeEventListener('scroll', update);
955
- window.removeEventListener('resize', update);
956
- };
957
- }, []);
958
-
959
- // Sticky AskBar fades out once the user scrolls near the PageFeedback
960
- // widget — so it doesn't sit on top of the page-foot widgets.
961
- const feedbackRef = React.useRef(null);
962
- const [askBarHidden, setAskBarHidden] = React.useState(false);
963
- React.useEffect(() => {
964
- const node = feedbackRef.current;
965
- if (!node) return;
966
- const FADE_BUFFER = 64; // matches the rootMargin below
967
- const apply = (rect) => {
968
- // Hide whenever the feedback's top has reached the (effective)
969
- // viewport-bottom line — covers both "feedback is in view" AND
970
- // "feedback is already scrolled past" without flickering back on.
971
- // Threshold matches the IO's rootMargin so the show/hide flip is
972
- // exactly at the same line in both scroll directions.
973
- setAskBarHidden(rect.top < window.innerHeight - FADE_BUFFER);
974
- };
975
- apply(node.getBoundingClientRect());
976
- const io = new IntersectionObserver(
977
- ([entry]) => apply(entry.boundingClientRect),
978
- // Trigger ~64px before the feedback enters the viewport, so the
979
- // AskBar fades just as the widget starts to peek up from below.
980
- { rootMargin: '0px 0px -64px 0px' },
981
- );
982
- io.observe(node);
983
- return () => io.disconnect();
984
- }, []);
985
-
986
- const scrollTo = React.useCallback(
987
- (id) => {
988
- const node = document.getElementById(id);
989
- if (!node) return;
990
- // 1) Set + lock the active id IMMEDIATELY so the spy doesn't
991
- // overwrite it during the smooth-scroll animation.
992
- setActive(id);
993
- // 2) Compute the target scroll position MANUALLY (instead of
994
- // scrollIntoView). The browser clamps to max-scroll
995
- // automatically; the target is baked in at click time and
996
- // doesn't drift if layout shifts mid-animation.
997
- const offset =
998
- parseFloat(
999
- getComputedStyle(document.documentElement).getPropertyValue(
1000
- '--velu-scroll-offset',
1001
- ),
1002
- ) || 0;
1003
- const top = node.getBoundingClientRect().top + window.scrollY - offset;
1004
- window.scrollTo({ top, behavior: 'smooth' });
1005
- },
1006
- [setActive],
1007
- );
1008
-
1009
- const kicker = {
1010
- fontFamily: 'var(--font-mono)',
1011
- fontSize: 11,
1012
- letterSpacing: '0.6px',
1013
- textTransform: 'uppercase',
1014
- color: 'var(--muted-color)',
1015
- };
1016
-
1017
- return (
1018
- <div
1019
- className="velu-docs-layout"
1020
- data-chat-open={chatOpen ? 'true' : 'false'}
1021
- data-sidebar-open={sidebarOpen ? 'true' : 'false'}
1022
- data-drawer-open={drawerOpen ? 'true' : 'false'}
1023
- >
1024
- {/* Scrim — visible at mobile while the drawer OR the chatbot
1025
- sheet is open. Sits between the article (z-0) and the
1026
- drawer/chatbot (z-35 / z-50) and blocks pointer events to
1027
- everything beneath; click closes whichever surface is up. */}
1028
- <div
1029
- className="velu-docs-layout__scrim"
1030
- aria-hidden="true"
1031
- onClick={() => {
1032
- setDrawerOpen(false);
1033
- setChatOpen(false);
1034
- }}
1035
- />
1036
- {/* Site header — brand, centered search, right-side actions,
1037
- tabs row. Configurable: pass any number of actions / tabs. */}
1038
- <PageHeader
1039
- linkComponent={RouterLink}
1040
- brand={{ label: 'Velu', href: '/' }}
1041
- brandTrailing={
1042
- versionSwitcher && (
1043
- <span className="velu-hide-on-mobile">{versionSwitcher}</span>
1044
- )
1045
- }
1046
- tabsTrailing={languageSwitcher || undefined}
1047
- center={
1048
- <Cluster space="var(--s-6)" align="center">
1049
- <Search style={{ inlineSize: '30ch' }} />
1050
- <button
1051
- type="button"
1052
- className="velu-header__action velu-header__action--outlined"
1053
- onClick={() => askAI('')}
1054
- >
1055
- <span className="velu-header__action-icon" aria-hidden="true">
1056
- {resolveIcon('sparkles', { size: '1.5em' })}
1057
- </span>
1058
- <span>Ask AI</span>
1059
- </button>
1060
- </Cluster>
1061
- }
1062
- actions={[
1063
- {
1064
- label: 'Book Demo',
1065
- kind: 'primary',
1066
- href: '#',
1067
- },
1068
- ]}
1069
- trailing={<ThemeToggle />}
1070
- onMenuClick={() => setDrawerOpen((v) => !v)}
1071
- breadcrumb={nav?.breadcrumb ?? []}
1072
- activeTab={nav?.activeTab}
1073
- tabs={nav?.tabs ?? []}
1074
- />
1075
-
1076
- {/* Fixed left sidebar — pinned to viewport-left below the header.
1077
- Does NOT scroll with the page; the footer rises over its bottom
1078
- edge thanks to the higher z-index on the footer below.
1079
- `top` + `bottom` give a robust height (some browsers don't
1080
- honour `inset-block-start` for fixed positioning the same way
1081
- as plain `top`). */}
1082
- <aside
1083
- className="velu-docs-layout__aside velu-docs-layout__aside--left"
1084
- style={{
1085
- /* Bottom edge stays a fixed gap above the viewport bottom,
1086
- AND lifts to keep that gap above the footer as it scrolls
1087
- into view (footerOverlap = how far the footer intrudes).
1088
- Set as a custom prop so the mobile drawer's
1089
- `inset-block-end: 0` override still wins. */
1090
- '--velu-aside-bottom': `calc(${footerOverlap}px + var(--s4))`,
1091
- }}
1092
- >
1093
- {/* Drawer body — Stack with 32px gap composes the slots
1094
- (topbar / tab-dropdown / context / nav). The aside is a flex
1095
- column (CSS): the pinned slots keep their height and only the
1096
- nav region scrolls (see velu-docs-nav-scroll below). At wide
1097
- widths the topbar + docselect are `display: none`. */}
1098
- <Stack space="var(--s0)" className="velu-docs-aside-stack">
1099
- <div className="velu-docs-layout__drawer-head">
1100
- <RouterLink
1101
- href="/"
1102
- className="velu-docs-layout__drawer-brand"
1103
- >
1104
- <VeluMark />
1105
- <span className="velu-header__wordmark">Velu</span>
1106
- </RouterLink>
1107
- <ThemeToggle />
1108
- <button
1109
- type="button"
1110
- className="velu-docs-layout__drawer-close"
1111
- aria-label="Close navigation"
1112
- onClick={() => setDrawerOpen(false)}
1113
- >
1114
- <X aria-hidden="true" focusable="false" />
1115
- </button>
1116
- </div>
1117
- {/* Nav dropdown — custom button + menu, fills drawer width.
1118
- Items mirror the desktop tabs (Home / Docs / Blog).
1119
- Click-outside + Escape close (see navOpen useEffect
1120
- above). Chevron rotates 180° on open. */}
1121
- <div
1122
- ref={navRef}
1123
- className="velu-docs-layout__drawer-docselect"
1124
- data-open={navOpen ? 'true' : 'false'}
1125
- >
1126
- <button
1127
- type="button"
1128
- className="velu-docs-layout__drawer-docselect-btn"
1129
- onClick={() => setNavOpen((o) => !o)}
1130
- aria-haspopup="menu"
1131
- aria-expanded={navOpen}
1132
- >
1133
- <span className="velu-docs-layout__drawer-docselect-label">
1134
- {activeNavLabel}
1135
- </span>
1136
- <ChevronDown
1137
- className="velu-docs-layout__drawer-docselect-chev"
1138
- aria-hidden="true"
1139
- focusable="false"
1140
- />
1141
- </button>
1142
- <ul
1143
- className="velu-docs-layout__drawer-docselect-menu"
1144
- role="menu"
1145
- aria-hidden={!navOpen}
1146
- >
1147
- {navItems.map((it) => (
1148
- <li key={it.href} role="none">
1149
- <a
1150
- role="menuitem"
1151
- className="velu-docs-layout__drawer-docselect-item"
1152
- href={it.href}
1153
- tabIndex={navOpen ? 0 : -1}
1154
- onClick={() => setNavOpen(false)}
1155
- >
1156
- {it.label}
1157
- </a>
1158
- </li>
1159
- ))}
1160
- </ul>
1161
- </div>
1162
- {/* Context zone — product switcher + anchors at the top of
1163
- the sidebar (all breakpoints), plus version/language
1164
- switchers that only show on mobile (desktop has them in
1165
- the header). Rendered only when there's something to show
1166
- so simple projects keep a bare sidebar. */}
1167
- {(productSwitcher ||
1168
- versionSwitcher ||
1169
- languageSwitcher ||
1170
- anchors.length > 0) && (
1171
- <Stack space="var(--s-1)" className="velu-docs-context">
1172
- {productSwitcher}
1173
- {versionSwitcher && (
1174
- <span className="velu-show-on-mobile">{versionSwitcher}</span>
1175
- )}
1176
- {languageSwitcher && (
1177
- <span className="velu-show-on-mobile">{languageSwitcher}</span>
1178
- )}
1179
- {anchors.length > 0 && (
1180
- <ul className="velu-docs-anchors">
1181
- {anchors.map((a, i) => (
1182
- <li key={i}>
1183
- <a
1184
- className="velu-docs-anchors__link"
1185
- href={a.href}
1186
- target="_blank"
1187
- rel="noreferrer"
1188
- >
1189
- {a.icon && (
1190
- <span
1191
- className="velu-docs-anchors__icon"
1192
- aria-hidden="true"
1193
- >
1194
- {resolveIcon(a.icon, { size: '1em' })}
1195
- </span>
1196
- )}
1197
- <span>{a.label}</span>
1198
- </a>
1199
- </li>
1200
- ))}
1201
- </ul>
1202
- )}
1203
- </Stack>
1204
- )}
1205
- {/* Only this region scrolls — the context zone above stays
1206
- pinned. The up/down arrows overlay its top/bottom edges and
1207
- appear (via the data-fade-* attrs the scroll handler sets)
1208
- when there's content beyond that edge; clicking jumps the
1209
- nav fully to that end. */}
1210
- <div className="velu-docs-nav-region">
1211
- <div
1212
- ref={leftAsideRef}
1213
- className="velu-docs-nav-scroll velu-hide-scrollbar"
1214
- style={{
1215
- /* Just breathing room — the aside's bottom edge already
1216
- stays above the footer (see --velu-aside-bottom). */
1217
- paddingBlockEnd: 'var(--s1)',
1218
- scrollPaddingBlockEnd: 'var(--s1)',
1219
- }}
1220
- >
1221
- <Sidebar
1222
- sections={nav?.sidebarSections ?? []}
1223
- activeHref={pathname}
1224
- linkComponent={RouterLink}
1225
- />
1226
- </div>
1227
- <button
1228
- type="button"
1229
- className="velu-docs-nav-arrow velu-docs-nav-arrow--up"
1230
- aria-label="Scroll navigation to top"
1231
- onClick={() =>
1232
- leftAsideRef.current?.scrollTo({ top: 0, behavior: 'smooth' })
1233
- }
1234
- >
1235
- <ChevronUp aria-hidden="true" focusable="false" />
1236
- </button>
1237
- <button
1238
- type="button"
1239
- className="velu-docs-nav-arrow velu-docs-nav-arrow--down"
1240
- aria-label="Scroll navigation to bottom"
1241
- onClick={() =>
1242
- leftAsideRef.current?.scrollTo({
1243
- top: leftAsideRef.current.scrollHeight,
1244
- behavior: 'smooth',
1245
- })
1246
- }
1247
- >
1248
- <ChevronDown aria-hidden="true" focusable="false" />
1249
- </button>
1250
- </div>
1251
- </Stack>
1252
- </aside>
1253
-
1254
- {/* No separate rail element — at narrow widths the sidebar's
1255
- aside ANIMATES its `inline-size` between 240px (open) and
1256
- --velu-rail-width (closed), and its inner Sidebar nav fades
1257
- out via opacity. The aside's border-inline-end therefore
1258
- becomes the rail's right border when collapsed. This makes
1259
- the collapse a smooth width+opacity transition instead of a
1260
- display:none snap. See docs-layout.css. */}
1261
-
1262
- {/* Fixed right TOC — pinned to viewport-right. Hidden while the
1263
- Ask-AI chatbot is open (the panel takes that edge). */}
1264
- {!chatOpen && (
1265
- <aside
1266
- ref={rightAsideRef}
1267
- className="velu-docs-layout__aside velu-docs-layout__aside--right velu-hide-scrollbar"
1268
- style={{
1269
- /* Dynamic footer-overlap padding only static geometry
1270
- lives in docs-layout.css. */
1271
- paddingBlockEnd: `calc(var(--s3) + ${footerOverlap}px + 2rem)`,
1272
- scrollPaddingBlockEnd: `calc(${footerOverlap}px + 2rem)`,
1273
- }}
1274
- >
1275
- <Toc items={toc} activeId={activeId} onSelect={scrollTo} />
1276
- </aside>
1277
- )}
1278
-
1279
- {/* Center column. Margin to reserve aside space lives in
1280
- docs-layout.css (drops to 0 at narrow widths via @container,
1281
- and the right margin collapses to 0 while the chatbot is
1282
- open via [data-chat-open="true"]). */}
1283
- <div className="velu-docs-layout__center">
1284
- {/* Narrow-layout TOC bar — always in DOM, only visible at
1285
- < 1024px (toggled by @container in toc-bar.css). Shares
1286
- its `items` + `activeId` + `onSelect` API with the
1287
- right-rail <Toc> so both views are driven by the same
1288
- data; whichever one is visible at a given width responds
1289
- to the same scroll-spy state. */}
1290
- <TocBar items={toc} activeId={activeId} onSelect={scrollTo} />
1291
- <main
1292
- className="velu-docs-layout__main"
1293
- style={{
1294
- /* No padding-block-endthe article's last child (PoweredBy)
1295
- owns the gap to the footer via its own margin-bottom, so
1296
- padding-bottom here would double-count it. `position:
1297
- relative` makes <main> the offsetParent for the absolutely
1298
- positioned sidebar-toggle below so its `top: 0` lands
1299
- at the top of the article area, BELOW the sticky TocBar
1300
- (which lives outside <main>). Padding-inline lives in CSS
1301
- so the @container query can collapse the start side when
1302
- the sidebar is closed (no "ghost column" on the left). */
1303
- position: 'relative',
1304
- color: 'var(--text-color)',
1305
- }}
1306
- >
1307
- {/* Sidebar toggle narrow-layout only (hidden by @container
1308
- at wide widths). Lives inside <main> so its absolute
1309
- position is relative to the article area, not the centre
1310
- column, and therefore sits BELOW the TocBar rather than
1311
- overlapping it. Chevron flips direction with the
1312
- `data-sidebar-open` data attribute on the layout root. */}
1313
- <button
1314
- type="button"
1315
- className="velu-docs-layout__sidebar-toggle"
1316
- onClick={() => setSidebarOpen((v) => !v)}
1317
- aria-label={sidebarOpen ? 'Collapse sidebar' : 'Expand sidebar'}
1318
- aria-expanded={sidebarOpen}
1319
- >
1320
- <span aria-hidden="true">
1321
- {resolveIcon(sidebarOpen ? 'chevron-left' : 'chevron-right', {
1322
- size: '1em',
1323
- })}
1324
- </span>
1325
- </button>
1326
- <div className="velu-docs-layout__article">
1327
- {/* Page hero from MDX frontmatter. `.velu-hero` rules
1328
- (in base.css) keep the title and description tightly
1329
- grouped and create a clear break before the prose body. */}
1330
- {(frontmatter.title || frontmatter.description) && (
1331
- <div className="velu-hero">
1332
- {frontmatter.title && <h1 id={pageId}>{frontmatter.title}</h1>}
1333
- {frontmatter.description && (
1334
- <p
1335
- style={{
1336
- color: 'var(--muted-color)',
1337
- fontSize: 'var(--f-h4)',
1338
- lineHeight: 'var(--lh-h4)',
1339
- }}
1340
- >
1341
- {frontmatter.description}
1342
- </p>
1343
- )}
1344
- </div>
1345
- )}
1346
-
1347
- {/* Article body — the current route's MDX page, rendered
1348
- through the velu-ui MDX component registry. `velu-prose`
1349
- gives a consistent vertical rhythm scaled by heading
1350
- level. Falls back to a not-found / missing-file notice
1351
- when the route has no page (or its file is absent). */}
1352
- <MDXProvider components={defaultMdxComponents}>
1353
- <div className="velu-prose">
1354
- {PageComponent ? (
1355
- <ErrorBoundary key={pathname} file={entry?.relPath}>
1356
- <PageComponent />
1357
- </ErrorBoundary>
1358
- ) : (
1359
- <p style={{ color: 'var(--muted-color)' }}>
1360
- {entry?.missing
1361
- ? 'This page is listed in navigation but its .mdx file was not found.'
1362
- : 'Page not found.'}
1363
- </p>
1364
- )}
1365
- </div>
1366
- </MDXProvider>
1367
- {/* Page-foot feedback widget — ref'd so the sticky AskBar
1368
- above can hide as the user scrolls near it. */}
1369
- <div ref={feedbackRef} style={{ marginTop: 'var(--s3)' }}>
1370
- <PageFeedback />
1371
- </div>
1372
- {/* Previous / next page navigation — derived from the
1373
- sidebar reading order of the active section. */}
1374
- {(nav?.prev || nav?.next) && (
1375
- <PageNav
1376
- style={{ marginTop: 'var(--s2)' }}
1377
- prev={nav?.prev}
1378
- next={nav?.next}
1379
- linkComponent={RouterLink}
1380
- />
1381
- )}
1382
- {/* "Ask a question" barsticky to viewport-bottom while the
1383
- article column is in view; lives inside the prose-column
1384
- div so its width matches the article. Submitting opens
1385
- the Ask-AI chatbot; fades out as the PageFeedback widget
1386
- approaches (see IntersectionObserver above). */}
1387
- <AskBar
1388
- onSubmit={askAI}
1389
- style={{
1390
- position: 'sticky',
1391
- insetBlockEnd: 'var(--s1)',
1392
- /* Once the user has scrolled near the feedback widget the
1393
- AskBar fades and collapses to zero flow space — height,
1394
- margin, padding all drop to 0 so the next element
1395
- (PoweredBy) sits directly under PageNav at its own
1396
- 32px margin, with no phantom gap. */
1397
- marginTop: askBarHidden ? 0 : 'var(--s2)',
1398
- height: askBarHidden ? 0 : 'auto',
1399
- overflow: 'hidden',
1400
- opacity: askBarHidden ? 0 : 1,
1401
- transform: askBarHidden ? 'translateY(20%)' : 'translateY(0)',
1402
- pointerEvents: askBarHidden ? 'none' : 'auto',
1403
- transition: 'opacity 0.2s ease, transform 0.2s ease',
1404
- }}
1405
- />
1406
- {/* "Powered by Velu" attribution bottom-right of the
1407
- article column, just under the AskBar. Muted so it reads
1408
- as a footer-of-content note, not a brand statement. */}
1409
- <PoweredBy />
1410
- </div>
1411
- </main>
1412
- </div>
1413
-
1414
- {/* Site footer spans full width below the article. Its raised
1415
- z-index ensures it visually eclipses the bottoms of the fixed
1416
- left sidebar and right TOC as the page scrolls into it. The
1417
- ref is watched so the asides can pad their bottom by the same
1418
- overlap amount, keeping every item scrollable into view. */}
1419
- <div
1420
- ref={footerRef}
1421
- data-velu-footer
1422
- style={{ position: 'relative', zIndex: 20 }}
1423
- >
1424
- <PageFooter
1425
- brand={{ href: '#' }}
1426
- columns={[
1427
- {
1428
- title: 'Resources',
1429
- items: [
1430
- { label: 'Showcase', href: '#' },
1431
- { label: 'Enterprise', href: '#' },
1432
- { label: 'Status', href: '#' },
1433
- ],
1434
- },
1435
- {
1436
- title: 'Company',
1437
- items: [
1438
- { label: 'Careers', href: '#' },
1439
- { label: 'Blog', href: '#' },
1440
- { label: 'Community', href: '#' },
1441
- ],
1442
- },
1443
- {
1444
- title: 'Policies',
1445
- items: [
1446
- { label: 'Subprocessors', href: '#' },
1447
- { label: 'Terms of Service', href: '#' },
1448
- ],
1449
- },
1450
- ]}
1451
- socials={[
1452
- { kind: 'github', href: 'https://github.com/aravindc26/velu-cli' },
1453
- { kind: 'x', href: 'https://x.com/' },
1454
- { kind: 'youtube', href: 'https://youtube.com/' },
1455
- { kind: 'linkedin', href: 'https://linkedin.com/' },
1456
- ]}
1457
- />
1458
- </div>
1459
-
1460
- {/* Ask-AI chatbot slides in from the inline-end edge. */}
1461
- <Chatbot
1462
- open={chatOpen}
1463
- seedQuestion={chatQuestion}
1464
- onClose={() => setChatOpen(false)}
1465
- />
1466
- </div>
1467
- );
1468
- }
1469
-
1470
- export default function App() {
1471
- return (
1472
- <Routes>
1473
- <Route path="*" element={<DocsPage />} />
1474
- </Routes>
1475
- );
1476
- }
1
+ import React from 'react';
2
+ import { Routes, Route, useLocation, Link } from 'react-router-dom';
3
+ import { MDXProvider } from '@mdx-js/react';
4
+ // The project's pages + navigation, generated from velu.json by
5
+ // vite-plugin-velu-site (see src/vite-plugin-velu-site.js). `pages` is
6
+ // url → { Component, frontmatter, toc } (or { missing:true }).
7
+ import { pages, navigation } from 'virtual:velu-site';
8
+ import { resolve, normalizeUrl } from '../navigation.js';
9
+ import {
10
+ Stack,
11
+ Cluster,
12
+ ThemeToggle,
13
+ Sidebar,
14
+ NavSelect,
15
+ Toc,
16
+ TocBar,
17
+ Callout,
18
+ Accordion,
19
+ AccordionGroup,
20
+ Card,
21
+ CardGroup,
22
+ Switcher,
23
+ Image,
24
+ CodeBlock,
25
+ CodeGroup,
26
+ Columns,
27
+ Field,
28
+ Prompt,
29
+ Steps,
30
+ Step,
31
+ AskBar,
32
+ Chatbot,
33
+ PageFeedback,
34
+ PageNav,
35
+ PageFooter,
36
+ PageHeader,
37
+ PoweredBy,
38
+ defaultMdxComponents,
39
+ resolveIcon,
40
+ Search,
41
+ Tree,
42
+ Folder,
43
+ File,
44
+ TryItBar,
45
+ ApiClient,
46
+ ApiField,
47
+ ApiSidebar,
48
+ VeluMark,
49
+ } from 'velu-ui';
50
+ import { X, ChevronDown, ChevronUp } from 'lucide-react';
51
+ import ErrorBoundary from './ErrorBoundary.jsx';
52
+
53
+ // True under `velu dev`, false in the deployed production build (Vite injects
54
+ // this). AI features (Ask AI, the Ask-a-question bar) and full-text search run
55
+ // on the deployed site, so they're hidden / shown-as-unavailable in the local
56
+ // preview. Identical on SSR + client in each mode, so no hydration mismatch.
57
+ const IS_DEV_PREVIEW = import.meta.env.DEV;
58
+
59
+ const CALLOUT_TYPES = [
60
+ 'note',
61
+ 'warning',
62
+ 'info',
63
+ 'tip',
64
+ 'check',
65
+ 'danger',
66
+ 'callout',
67
+ ];
68
+
69
+ function CalloutGallery() {
70
+ return (
71
+ <Stack space="var(--s0)">
72
+ {CALLOUT_TYPES.map((t) => (
73
+ <Callout key={t} type={t}>
74
+ This is a {t}. This is a {t}. This is a {t}. This is a {t}.
75
+ </Callout>
76
+ ))}
77
+ <p style={{ color: 'var(--muted-color)' }}>
78
+ Custom callouts can be built with a custom icon &amp; color:
79
+ </p>
80
+ <Callout
81
+ icon="sparkles"
82
+ stroke="var(--accent-color)"
83
+ bg="color-mix(in srgb, var(--accent-color) 8%, transparent)"
84
+ >
85
+ A custom calloutlucide id <code>"sparkles"</code> with custom{' '}
86
+ <code>stroke</code> &amp; <code>bg</code>.
87
+ </Callout>
88
+
89
+ <Callout type="info">
90
+ This is a multi-line callout. It keeps going and going so the text
91
+ wraps onto several lines — the icon sits on the first line, the text
92
+ wraps beside it, and every line after flows back under the icon (no
93
+ hanging indent). Resize the window to watch the wrapping reflow while
94
+ the icon stays put on line one. This is a multi-line callout. It keeps
95
+ going so the text wraps onto several lines.
96
+ </Callout>
97
+ </Stack>
98
+ );
99
+ }
100
+
101
+ function AccordionDemo() {
102
+ return (
103
+ <Stack space="var(--s1)">
104
+ <Accordion title="This is an accordion">
105
+ This is content inside the accordion. Hover the header to see the
106
+ surface tint; the chevron rotates when expanded.
107
+ </Accordion>
108
+ <Accordion title="This is an accordion (open by default)" defaultOpen>
109
+ This one renders expanded — header takes the surface tint and a
110
+ divider separates it from this content.
111
+ </Accordion>
112
+ <AccordionGroup>
113
+ <Accordion title="This is an accordion">
114
+ Grouped items share one bordered box with dividers between them.
115
+ </Accordion>
116
+ <Accordion title="This is an accordion" defaultOpen>
117
+ This is content inside the accordion.
118
+ </Accordion>
119
+ <Accordion title="This is an accordion">
120
+ No per-item border or radius — the group owns the chrome.
121
+ </Accordion>
122
+ </AccordionGroup>
123
+ </Stack>
124
+ );
125
+ }
126
+
127
+ function CardDemo() {
128
+ return (
129
+ <Stack space="var(--s2)">
130
+ <Card icon="align-justify" title="Card Title">
131
+ This is how you use a card with an icon and a link. (Cards are not
132
+ clickable only the CTA card's link is.)
133
+ </Card>
134
+
135
+ <Card icon="align-justify" title="Card Title" horizontal>
136
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
137
+ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
138
+ veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
139
+ commodo consequat.
140
+ </Card>
141
+
142
+ <Card
143
+ img="https://picsum.photos/seed/velu/1200/560"
144
+ imgAlt="Yosemite valley"
145
+ title="Card Title"
146
+ >
147
+ This is how you use a card with an icon. The image fills the container
148
+ and is clipped to the card radius.
149
+ </Card>
150
+
151
+ <Card
152
+ icon="align-justify"
153
+ title="Card Title"
154
+ cta={{ label: 'Click Here', href: '#cards' }}
155
+ >
156
+ This is how you use a card with an icon and a link. The "Click Here"
157
+ link below is the only clickable element.
158
+ </Card>
159
+
160
+ <CardGroup>
161
+ <Card icon="align-justify" title="Card Title">
162
+ This is how you use a card with an icon and a link.
163
+ </Card>
164
+ <Card icon="align-justify" title="Card Title">
165
+ This is how you use a card with an icon and a link.
166
+ </Card>
167
+ </CardGroup>
168
+ </Stack>
169
+ );
170
+ }
171
+
172
+ function SwitcherBox({ children }) {
173
+ return (
174
+ <div
175
+ style={{
176
+ border: 'var(--border-width) solid var(--border-color)',
177
+ borderRadius: 'var(--radius-sm)',
178
+ padding: 'var(--s0) var(--s3)',
179
+ }}
180
+ >
181
+ {children}
182
+ </div>
183
+ );
184
+ }
185
+
186
+ function SwitcherDemo() {
187
+ return (
188
+ <Stack space="var(--s1)">
189
+ <p style={{ color: 'var(--muted-color)' }}>
190
+ Resize the window — these flip between a row and a column at the
191
+ container threshold, with no media queries.
192
+ </p>
193
+ <Switcher space="var(--s0)" threshold="30rem">
194
+ <SwitcherBox>One</SwitcherBox>
195
+ <SwitcherBox>Two</SwitcherBox>
196
+ <SwitcherBox>Three</SwitcherBox>
197
+ </Switcher>
198
+ <p style={{ color: 'var(--muted-color)' }}>
199
+ With <code>limit={2}</code>: more than 2 items forces vertical
200
+ regardless of width.
201
+ </p>
202
+ <Switcher space="var(--s0)" threshold="30rem" limit={2}>
203
+ <SwitcherBox>One</SwitcherBox>
204
+ <SwitcherBox>Two</SwitcherBox>
205
+ <SwitcherBox>Three</SwitcherBox>
206
+ </Switcher>
207
+ </Stack>
208
+ );
209
+ }
210
+
211
+ const DEMO_JS = `let greeting = function (name) {
212
+ console.log(\`Hello, \${name}!\`);
213
+ };`;
214
+ const DEMO_RB = `def greeting(name)
215
+ puts "Hello, #{name}!"
216
+ end`;
217
+ const DEMO_PY = `def greeting(name):
218
+ print(f"Hello, {name}!")`;
219
+
220
+ function CodeBlockDemo() {
221
+ return (
222
+ <Stack space="var(--s2)">
223
+ <p style={{ color: 'var(--muted-color)' }}>Code Group</p>
224
+ <CodeGroup>
225
+ <CodeBlock title="Javascript" language="javascript">
226
+ {DEMO_JS}
227
+ </CodeBlock>
228
+ <CodeBlock title="Ruby" language="ruby">
229
+ {DEMO_RB}
230
+ </CodeBlock>
231
+ <CodeBlock title="Python" language="python">
232
+ {DEMO_PY}
233
+ </CodeBlock>
234
+ </CodeGroup>
235
+
236
+ <p style={{ color: 'var(--muted-color)' }}>Code (with file name)</p>
237
+ <CodeBlock filename="index.js" language="javascript">
238
+ {DEMO_JS}
239
+ </CodeBlock>
240
+
241
+ <p style={{ color: 'var(--muted-color)' }}>
242
+ With line numbers (icon suppressed via <code>withIcon={'{false}'}</code>)
243
+ </p>
244
+ <CodeBlock
245
+ filename="index.js"
246
+ language="javascript"
247
+ withIcon={false}
248
+ lineNumbers
249
+ >
250
+ {DEMO_JS}
251
+ </CodeBlock>
252
+
253
+ <p style={{ color: 'var(--muted-color)' }}>
254
+ Line highlight — single line (<code>highlight="2"</code>)
255
+ </p>
256
+ <CodeBlock
257
+ filename="index.js"
258
+ language="javascript"
259
+ lineNumbers
260
+ highlight="2"
261
+ >
262
+ {DEMO_JS}
263
+ </CodeBlock>
264
+
265
+ <p style={{ color: 'var(--muted-color)' }}>
266
+ Line highlight — range + single (<code>highlight="1-2,4"</code>)
267
+ </p>
268
+ <CodeBlock
269
+ filename="server.js"
270
+ language="javascript"
271
+ lineNumbers
272
+ highlight="1-2,4"
273
+ >
274
+ {`const express = require('express');
275
+ const app = express();
276
+
277
+ app.get('/', (req, res) => res.send('Hello'));
278
+
279
+ app.listen(3000);`}
280
+ </CodeBlock>
281
+ </Stack>
282
+ );
283
+ }
284
+
285
+ function ApiDemo() {
286
+ const path = '/project/preview/{projectId}';
287
+ const curl = `curl --request POST \\
288
+ --url https://api.mintlify.com/v1/project/update/{projectId} \\
289
+ --header 'Authorization: Bearer <token>'`;
290
+ return (
291
+ <Stack space="var(--s2)">
292
+ <p style={{ color: 'var(--muted-color)' }}>Try-it bar</p>
293
+ <Stack space="var(--s-1)">
294
+ <TryItBar method="POST" path={path} />
295
+ <TryItBar method="GET" path={path} />
296
+ <TryItBar method="PUT" path={path} />
297
+ <TryItBar method="DELETE" path={path} />
298
+ <TryItBar method="PATCH" path={path} />
299
+ </Stack>
300
+
301
+ <p style={{ color: 'var(--muted-color)' }}>API sidebar</p>
302
+ <ApiSidebar
303
+ activeHref="/api/status"
304
+ sections={[
305
+ {
306
+ title: 'Admin',
307
+ icon: 'rocket',
308
+ endpoints: [
309
+ { method: 'POST', label: 'Trigger', href: '/api/trigger' },
310
+ {
311
+ method: 'GET',
312
+ label: 'Get deployment-status',
313
+ href: '/api/status',
314
+ },
315
+ {
316
+ method: 'DELETE',
317
+ label: 'Trigger Preview deployment',
318
+ href: '/api/preview',
319
+ },
320
+ ],
321
+ },
322
+ ]}
323
+ />
324
+
325
+ <p style={{ color: 'var(--muted-color)' }}>API Client</p>
326
+ {/* Only the ApiClient breaks out of the 46rem prose column — the
327
+ TryItBars above stay at the normal column width. clamp keeps
328
+ it ≥ 100% (so it never collapses when the main-area calc goes
329
+ negative on narrow screens) and ≤ 64rem. */}
330
+ <div
331
+ style={{
332
+ width:
333
+ 'clamp(100%, calc(100vw - 240px - 280px - var(--s4) * 2), 64rem)',
334
+ }}
335
+ >
336
+ <ApiClient
337
+ method="DELETE"
338
+ label="Trigger Delete"
339
+ path={path}
340
+ onClose={() => {}}
341
+ description="Trigger a documentation deployment programmatically to publish updates outside of Git workflows."
342
+ aside={
343
+ <Stack space="var(--s1)">
344
+ <Callout type="danger">401 Unauthorized</Callout>
345
+ <CodeGroup>
346
+ <CodeBlock title="Response" language="json">
347
+ {`{\n "status": 401,\n "error": "Unauthorized"\n}`}
348
+ </CodeBlock>
349
+ <CodeBlock title="Headers" language="http">
350
+ {`HTTP/1.1 401 Unauthorized
351
+ date: Mon, 27 Apr 2026 12:00:55 GMT
352
+ content-type: application/json; charset=utf-8
353
+ content-length: 24
354
+ connection: close
355
+ x-powered-by: Express
356
+ access-control-allow-origin: *`}
357
+ </CodeBlock>
358
+ </CodeGroup>
359
+ <CodeGroup>
360
+ <CodeBlock title="Curl" language="bash">
361
+ {curl}
362
+ </CodeBlock>
363
+ <CodeBlock title="Ruby" language="ruby">
364
+ {`require 'net/http'
365
+ uri = URI('https://api.mintlify.com/v1/project/update/<projectId>')
366
+ req = Net::HTTP::Post.new(uri)
367
+ req['Authorization'] = 'Bearer <token>'
368
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }`}
369
+ </CodeBlock>
370
+ <CodeBlock title="Python" language="python">
371
+ {`import requests
372
+ requests.post(
373
+ 'https://api.mintlify.com/v1/project/update/<projectId>',
374
+ headers={'Authorization': 'Bearer <token>'},
375
+ )`}
376
+ </CodeBlock>
377
+ </CodeGroup>
378
+ <CodeGroup>
379
+ <CodeBlock title="202" language="json">
380
+ {`{\n "statusId": "<string>"\n}`}
381
+ </CodeBlock>
382
+ <CodeBlock title="200" language="json">
383
+ {`{\n "statusId": "<string>",\n "completedAt": "2026-04-27T12:00:55Z"\n}`}
384
+ </CodeBlock>
385
+ </CodeGroup>
386
+ </Stack>
387
+ }
388
+ >
389
+ <AccordionGroup>
390
+ <Accordion title="Authorization" defaultOpen>
391
+ <Stack space="var(--s1)">
392
+ <ApiField
393
+ name="Authorization"
394
+ type="string"
395
+ required
396
+ prefix="Bearer"
397
+ >
398
+ The Authorization header expects a Bearer token. Use an
399
+ admin API key (prefixed with <code>mint_</code>).
400
+ </ApiField>
401
+ </Stack>
402
+ </Accordion>
403
+ <Accordion title="Path" defaultOpen>
404
+ <Stack space="var(--s1)">
405
+ <ApiField name="projectId" type="string" required>
406
+ Your project ID. Copy it from the API keys page.
407
+ </ApiField>
408
+ <ApiField name="bodyId" type="string" required>
409
+ Your body ID. Copy it from the API keys page.
410
+ </ApiField>
411
+ </Stack>
412
+ </Accordion>
413
+ <Accordion title="Query">
414
+ <Stack space="var(--s1)">
415
+ <ApiField name="branch" type="string">
416
+ Git branch to deploy. Defaults to the production branch.
417
+ </ApiField>
418
+ <ApiField name="dryRun" type="boolean" default="false">
419
+ When true, validates the deployment without publishing.
420
+ </ApiField>
421
+ </Stack>
422
+ </Accordion>
423
+ <Accordion title="Headers">
424
+ <Stack space="var(--s1)">
425
+ <ApiField name="X-Idempotency-Key" type="string">
426
+ Optional unique key so retried requests don't trigger
427
+ duplicate deployments.
428
+ </ApiField>
429
+ </Stack>
430
+ </Accordion>
431
+ <Accordion title="Body">
432
+ <Stack space="var(--s1)">
433
+ <ApiField name="message" type="string">
434
+ Deployment message shown in the activity log.
435
+ </ApiField>
436
+ <ApiField name="notify" type="boolean" default="true">
437
+ Whether to notify when the deployment completes.
438
+ </ApiField>
439
+ </Stack>
440
+ </Accordion>
441
+ </AccordionGroup>
442
+ </ApiClient>
443
+ </div>
444
+ </Stack>
445
+ );
446
+ }
447
+
448
+ function TreeDemo() {
449
+ return (
450
+ <Tree>
451
+ <Folder name="app">
452
+ <File name="layout.tsx" />
453
+ <File name="page.tsx" />
454
+ <Folder name="api" defaultOpen={false}>
455
+ <File name="route.ts" />
456
+ </Folder>
457
+ </Folder>
458
+ <File name="package.json" />
459
+ </Tree>
460
+ );
461
+ }
462
+
463
+ function StepsDemo() {
464
+ return (
465
+ <Steps>
466
+ <Step title="Install the CLI">Run the install script.</Step>
467
+ <Step title="Bootstrap a new project">
468
+ Scaffold a fresh velu project with a single command, then drop in the
469
+ starter MDX so you can begin editing right away. The CLI prompts for a
470
+ project name and target directory, copies the template files, and
471
+ installs dependencies in the background while you keep working.
472
+ </Step>
473
+ <Step title="Add your first page">
474
+ Drop an MDX file into the <code>content/</code> directory.
475
+ </Step>
476
+ <Step title="Configure navigation">
477
+ Edit <code>velu.config.js</code> and add your page paths under the
478
+ sidebar tree. Nested groups are supported, every item can carry an
479
+ icon, and external links are flagged automatically. Save the file and
480
+ the dev server hot-reloads with the new structure.
481
+ </Step>
482
+ <Step title="Preview locally">
483
+ Run <code>velu dev</code> — the local preview opens at
484
+ <code> localhost:5173</code> with SSR + HMR. Edits to any MDX or React
485
+ component reflect instantly. The right-rail TOC is generated from the
486
+ page's headings; the comet trail follows scroll.
487
+ </Step>
488
+ <Step title="Push and ship">Open a PR. Done.</Step>
489
+ </Steps>
490
+ );
491
+ }
492
+
493
+ function PromptDemo() {
494
+ return (
495
+ <Prompt title="Generate clear, concise documentation." openInCursor>
496
+ {`You are a **technical writing assistant**. Write documentation that is clear, accurate, and concise.
497
+ - Use second-person voice
498
+ - Avoid jargon
499
+ - Lead with what the reader can do, not how it works internally
500
+ - Code blocks use the project's language conventions
501
+ - Every example must be runnable as-is`}
502
+ </Prompt>
503
+ );
504
+ }
505
+
506
+ function FieldDemo() {
507
+ const desc =
508
+ 'An example of a parameter field. An example of a parameter field. An example of a parameter field. An example of a parameter field. An example of a parameter field. An example of a parameter field';
509
+ return (
510
+ <div>
511
+ <Field
512
+ name="param"
513
+ pre="pre"
514
+ type="string"
515
+ required
516
+ default={3}
517
+ post="post"
518
+ >
519
+ {desc}
520
+ </Field>
521
+ <Field
522
+ name="param"
523
+ pre="pre"
524
+ type="string"
525
+ required
526
+ default={3}
527
+ post="post"
528
+ >
529
+ {desc}
530
+ </Field>
531
+ <Field
532
+ name="param"
533
+ pre="pre"
534
+ type="string"
535
+ required
536
+ default={3}
537
+ post="post"
538
+ >
539
+ {desc}
540
+ </Field>
541
+ </div>
542
+ );
543
+ }
544
+
545
+ function ColumnsDemo() {
546
+ return (
547
+ <Stack space="var(--s2)">
548
+ <p style={{ color: 'var(--muted-color)' }}>
549
+ Two equal columns (<code>cols=&#123;2&#125;</code>) — collapses to a
550
+ single stack when items would fall below their per-item min width.
551
+ </p>
552
+ <Columns cols={2}>
553
+ <Card
554
+ icon="align-justify"
555
+ title="Card Title"
556
+ cta={{ label: 'Click Here', href: '#columns' }}
557
+ >
558
+ This is how you use a card with an icon and a link. Clicking on
559
+ this card brings you to the Columns page.
560
+ </Card>
561
+ <Card
562
+ icon="align-justify"
563
+ title="Card Title"
564
+ cta={{ label: 'Click Here', href: '#columns' }}
565
+ >
566
+ This is how you use a card with an icon and a link. Clicking on
567
+ this card brings you to the Columns page.
568
+ </Card>
569
+ </Columns>
570
+
571
+ <p style={{ color: 'var(--muted-color)' }}>
572
+ Heterogeneous children — a Card alongside a CodeBlock.
573
+ </p>
574
+ <Columns cols={2}>
575
+ <Card icon="sparkles" title="With a card">
576
+ Cards, callouts, code, images — anything composes in a column.
577
+ </Card>
578
+ <CodeBlock filename="hello.js" language="javascript">
579
+ {DEMO_JS}
580
+ </CodeBlock>
581
+ </Columns>
582
+
583
+ <p style={{ color: 'var(--muted-color)' }}>
584
+ Three columns (<code>cols=&#123;3&#125;</code>) with a stacked column
585
+ in the middle.
586
+ </p>
587
+ <Columns cols={3}>
588
+ <Card icon="rocket" title="Left">
589
+ Single card on the left.
590
+ </Card>
591
+ <Stack space="var(--s0)">
592
+ <Card icon="book" title="Top">
593
+ Two cards stacked via Stack inside one column.
594
+ </Card>
595
+ <Card icon="brain" title="Bottom">
596
+ Stack lets a column carry heterogeneous, multi-item content.
597
+ </Card>
598
+ </Stack>
599
+ <Card icon="zap" title="Right">
600
+ Single card on the right.
601
+ </Card>
602
+ </Columns>
603
+ </Stack>
604
+ );
605
+ }
606
+
607
+ const DEMO_IMG = 'https://picsum.photos/seed/velu-yosemite/1200/600';
608
+ const DEMO_SHOT = 'https://picsum.photos/seed/velu-shot/600/1000';
609
+
610
+ function ImageDemo() {
611
+ return (
612
+ <Stack space="var(--s2)">
613
+ <p style={{ color: 'var(--muted-color)' }}>Image</p>
614
+ <Image src={DEMO_IMG} alt="" />
615
+
616
+ <p style={{ color: 'var(--muted-color)' }}>
617
+ Image with caption (caption can be markdown later)
618
+ </p>
619
+ <Image src={DEMO_IMG} alt="" caption="Caption for this image" />
620
+
621
+ <p style={{ color: 'var(--muted-color)' }}>Image with window chrome</p>
622
+ <Image src={DEMO_IMG} alt="" chrome="window" />
623
+
624
+ <p style={{ color: 'var(--muted-color)' }}>Image with display frame</p>
625
+ <Image src={DEMO_SHOT} alt="" chrome="frame" caption="Caption can also be added" />
626
+ </Stack>
627
+ );
628
+ }
629
+
630
+ const RouterLink = ({ href, ...rest }) => <Link to={href} {...rest} />;
631
+
632
+ // Flatten a nested TOC tree to {id, label, depth} for scroll-spy.
633
+ function flat(nodes, depth = 0, out = []) {
634
+ for (const n of nodes) {
635
+ out.push({ id: n.id, label: n.label, depth });
636
+ if (n.children) flat(n.children, depth + 1, out);
637
+ }
638
+ return out;
639
+ }
640
+
641
+ // Scroll-spy: active = the section whose top last crossed the trigger line.
642
+ /**
643
+ * useScrollSpy — tracks the section currently in view, with an
644
+ * explicit "lock" override for click-driven scrolls.
645
+ *
646
+ * Without the lock, clicking a TOC item triggers a smooth-scroll
647
+ * animation; during the ~500ms animation the scroll listener fires
648
+ * many times with the page at intermediate positions, and the
649
+ * "closest section" answer flickers across multiple sections
650
+ * before settling — visible as the TocBar label briefly showing
651
+ * the wrong heading. The lock blocks spy updates for a configurable
652
+ * window so the click's intended `activeId` survives the animation.
653
+ *
654
+ * Returns `[activeId, setActive]` where `setActive(id)` writes the
655
+ * active id directly AND locks the spy for ~800ms.
656
+ */
657
+ function useScrollSpy(ids) {
658
+ const [activeId, setActiveId] = React.useState(ids[0]);
659
+ const lockUntilRef = React.useRef(0);
660
+ React.useEffect(() => {
661
+ const onScroll = () => {
662
+ if (Date.now() < lockUntilRef.current) return;
663
+ // Trigger line reads from --velu-scroll-offset (published by
664
+ // App.jsx as header + tocbar-toggle + 1rem). Same offset CSS
665
+ // uses for scroll-margin, so a heading freshly scrolled into
666
+ // view sits exactly at the trigger. Semantics: pick the
667
+ // section whose top is CLOSEST to the trigger; tie-break
668
+ // favours later sections in document order.
669
+ const trigger =
670
+ parseFloat(
671
+ getComputedStyle(document.documentElement).getPropertyValue(
672
+ '--velu-scroll-offset',
673
+ ),
674
+ ) || 0;
675
+ const vh = window.innerHeight;
676
+ let best = ids[0];
677
+ let bestDist = Infinity;
678
+ for (const id of ids) {
679
+ const node = document.getElementById(id);
680
+ if (!node) continue;
681
+ const top = node.getBoundingClientRect().top;
682
+ if (top >= vh) continue;
683
+ const dist = Math.abs(top - trigger);
684
+ if (dist <= bestDist) {
685
+ bestDist = dist;
686
+ best = id;
687
+ }
688
+ }
689
+ setActiveId(best);
690
+ };
691
+ window.addEventListener('scroll', onScroll, { passive: true });
692
+ onScroll();
693
+ return () => window.removeEventListener('scroll', onScroll);
694
+ }, [ids]);
695
+
696
+ const setActive = React.useCallback((id) => {
697
+ setActiveId(id);
698
+ // ~800ms covers the default smooth-scroll animation duration.
699
+ lockUntilRef.current = Date.now() + 800;
700
+ }, []);
701
+
702
+ return [activeId, setActive];
703
+ }
704
+
705
+ // Slugger used for the frontmatter-derived h1 id — same library as
706
+ // extract-toc + rehype-slug, so the id we render in the DOM matches
707
+ // what the TOC's `pageId` will compute. (One instance per page render
708
+ // is fine; the slugger is stateful only across calls on the SAME
709
+ // instance.)
710
+ import GithubSlugger from 'github-slugger';
711
+
712
+ function DocsPage() {
713
+ // Resolve the current route → page entry + navigation context. Both
714
+ // SSR and client compute these from the same pathname + the same
715
+ // shared `resolve()`, so the render is identical (hydration-safe).
716
+ const location = useLocation();
717
+ const pathname = normalizeUrl(location.pathname);
718
+ const entry = pages[pathname];
719
+ const nav = React.useMemo(
720
+ () => resolve(pathname, navigation, pages),
721
+ [pathname],
722
+ );
723
+
724
+ const frontmatter = entry?.frontmatter ?? {};
725
+ const PageComponent = entry?.Component ?? null;
726
+ const pageToc = entry?.toc ?? [];
727
+
728
+ // Switcher option sets (only render a switcher when an axis has >1
729
+ // option). Anchors are pinned sidebar links shown in the context zone.
730
+ const productOptions = nav?.products ?? [];
731
+ const versionOptions = nav?.versions ?? [];
732
+ const languageOptions = nav?.languages ?? [];
733
+ const anchors = nav?.anchors ?? [];
734
+ const versionSwitcher = versionOptions.length > 1 && (
735
+ <NavSelect
736
+ size="sm"
737
+ value={nav.activeVersion}
738
+ options={versionOptions}
739
+ linkComponent={RouterLink}
740
+ ariaLabel="Version"
741
+ />
742
+ );
743
+ const languageSwitcher = languageOptions.length > 1 && (
744
+ <NavSelect
745
+ bare
746
+ icon="globe"
747
+ value={nav.activeLanguage}
748
+ valueCode={nav.activeLanguageCode}
749
+ options={languageOptions}
750
+ linkComponent={RouterLink}
751
+ ariaLabel="Language"
752
+ />
753
+ );
754
+ const productSwitcher = productOptions.length > 1 && (
755
+ <NavSelect
756
+ value={nav.activeProduct}
757
+ options={productOptions}
758
+ linkComponent={RouterLink}
759
+ ariaLabel="Product"
760
+ />
761
+ );
762
+
763
+ // Frontmatter title needs an id so scroll-spy + click-to-scroll work
764
+ // against it like any other heading.
765
+ const pageId = React.useMemo(() => {
766
+ if (!frontmatter.title) return null;
767
+ return new GithubSlugger().slug(frontmatter.title);
768
+ }, [frontmatter.title]);
769
+
770
+ // Combined TOC: the frontmatter title is the page's top-level entry,
771
+ // and the MDX-derived headings (h2s) become its children. Without this,
772
+ // the right rail starts from the first h2 — orphaning the page title
773
+ // that sits visibly above the article.
774
+ const toc = React.useMemo(() => {
775
+ if (!frontmatter.title || !pageId) return pageToc;
776
+ return [{ id: pageId, label: frontmatter.title, children: pageToc }];
777
+ }, [pageId, frontmatter.title, pageToc]);
778
+
779
+ // Flat list of section ids for scroll-spy sourced from the same
780
+ // nested TOC tree we pass to the right-rail <Toc>, so spy + render
781
+ // can't drift out of sync with the MDX content.
782
+ const ids = React.useMemo(() => flat(toc).map((s) => s.id), [toc]);
783
+ const [activeId, setActive] = useScrollSpy(ids);
784
+
785
+ // Ask-AI chatbot: opens (slides in from the side) when a question is
786
+ // submitted in the AskBar. While it's open the TOC is hidden.
787
+ const [chatOpen, setChatOpen] = React.useState(false);
788
+ const [chatQuestion, setChatQuestion] = React.useState('');
789
+
790
+ // Left sidebar open/closed (narrow widths) chevron toggle. Defaults
791
+ // open per design; safe to default true since the narrow-width
792
+ // sidebar is in-flow and doesn't obscure content.
793
+ const [sidebarOpen, setSidebarOpen] = React.useState(true);
794
+ // Mobile drawer open/closed (< 640px) — burger / breadcrumb / X /
795
+ // scrim drive this. Defaults closed so refreshing the page at
796
+ // mobile doesn't surface the drawer over the article. Independent
797
+ // of sidebarOpen so neither breakpoint's default leaks into the
798
+ // other.
799
+ const [drawerOpen, setDrawerOpen] = React.useState(false);
800
+
801
+ // Drawer's nav dropdown — list of section links (Home/Docs/Blog),
802
+ // mirrors the desktop tabs. Click-outside + Escape close.
803
+ const [navOpen, setNavOpen] = React.useState(false);
804
+ const navRef = React.useRef(null);
805
+ React.useEffect(() => {
806
+ if (!navOpen) return;
807
+ const onDocClick = (e) => {
808
+ if (!navRef.current?.contains(e.target)) setNavOpen(false);
809
+ };
810
+ const onKey = (e) => {
811
+ if (e.key === 'Escape') setNavOpen(false);
812
+ };
813
+ document.addEventListener('mousedown', onDocClick);
814
+ document.addEventListener('keydown', onKey);
815
+ return () => {
816
+ document.removeEventListener('mousedown', onDocClick);
817
+ document.removeEventListener('keydown', onKey);
818
+ };
819
+ }, [navOpen]);
820
+ // Mobile drawer's section picker = the resolved tabs (top-level
821
+ // navigation), so it mirrors the desktop tabs row instead of a
822
+ // hardcoded list. Its button shows the active tab's label.
823
+ const navItems = nav?.tabs ?? [];
824
+ const activeNavLabel =
825
+ navItems.find((t) => t.href === nav?.activeTab)?.label ??
826
+ navItems[0]?.label ??
827
+ '';
828
+ const askAI = React.useCallback((q) => {
829
+ setChatQuestion(q);
830
+ setChatOpen(true);
831
+ }, []);
832
+
833
+ // Measure the live sticky chrome — header + (collapsed) TocBar
834
+ // toggle — and publish three CSS variables on `:root`:
835
+ //
836
+ // --velu-header-height live header height
837
+ // --velu-tocbar-height TocBar's TOGGLE row height (always-
838
+ // visible bit; 0 when the bar isn't shown)
839
+ // --velu-scroll-offset header + tocbar-toggle + 1rem
840
+ //
841
+ // Measuring just the toggle row (NOT the expanded list) is
842
+ // important: the expanded dropdown's max-block-size is large, and
843
+ // including it in the offset would inflate scroll-margin /
844
+ // scroll-spy trigger as soon as the user expands the dropdown —
845
+ // causing the page geometry to lurch and the spy / active label
846
+ // to flicker.
847
+ React.useEffect(() => {
848
+ if (typeof window === 'undefined') return;
849
+ const header = document.querySelector('.velu-header');
850
+ if (!header) return;
851
+ const root = document.documentElement;
852
+ const remPx = parseFloat(getComputedStyle(root).fontSize) || 16;
853
+ const apply = () => {
854
+ const headerH = header.getBoundingClientRect().height;
855
+ // Re-query each apply — the TocBar toggle button is mounted
856
+ // after first paint and its parent may also remount on
857
+ // theme/viewport changes.
858
+ const tocBarToggle = document.querySelector('.velu-toc-bar__toggle');
859
+ const tocBarH = tocBarToggle
860
+ ? tocBarToggle.getBoundingClientRect().height
861
+ : 0;
862
+ if (headerH > 0)
863
+ root.style.setProperty('--velu-header-height', `${headerH}px`);
864
+ root.style.setProperty('--velu-tocbar-height', `${tocBarH}px`);
865
+ // +1rem of breathing room between the chrome and the heading
866
+ // it's anchoring. The rem is read live so it stays in tokens.
867
+ root.style.setProperty(
868
+ '--velu-scroll-offset',
869
+ `${headerH + tocBarH + remPx}px`,
870
+ );
871
+ };
872
+ apply();
873
+ const ro = new ResizeObserver(apply);
874
+ ro.observe(header);
875
+ // Observe the toggle row only (not the expanded list) so the
876
+ // offset stays put when the user opens the dropdown.
877
+ const tocBarToggle = document.querySelector('.velu-toc-bar__toggle');
878
+ if (tocBarToggle) ro.observe(tocBarToggle);
879
+ return () => ro.disconnect();
880
+ }, []);
881
+
882
+ // The asides (left sidebar + right TOC) scroll independently of the
883
+ // page. On scroll/resize we set data-fade-top/-bottom on each scroll
884
+ // region so CSS can fade its edges (and reveal the nav arrows) only
885
+ // when there's content beyond them. Written imperatively (no
886
+ // re-render). Re-binds on chatOpen toggle (the right TOC
887
+ // mounts/unmounts with it).
888
+ const leftAsideRef = React.useRef(null);
889
+ const rightAsideRef = React.useRef(null);
890
+ React.useEffect(() => {
891
+ const els = [leftAsideRef.current, rightAsideRef.current].filter(Boolean);
892
+ if (!els.length) return;
893
+ const update = () => {
894
+ for (const el of els) {
895
+ el.dataset.fadeTop = el.scrollTop > 0 ? 'true' : 'false';
896
+ el.dataset.fadeBottom =
897
+ el.scrollTop + el.clientHeight < el.scrollHeight - 1
898
+ ? 'true'
899
+ : 'false';
900
+ }
901
+ };
902
+ update();
903
+ // Recompute on scroll AND on any size change of the scroll region
904
+ // or its content (ResizeObserver) + window resize — so the fade
905
+ // reflects hidden content persistently, not just during a scroll
906
+ // gesture (e.g. after a route change shifts the nav's height).
907
+ const ro = new ResizeObserver(update);
908
+ els.forEach((el) => {
909
+ el.addEventListener('scroll', update, { passive: true });
910
+ ro.observe(el);
911
+ if (el.firstElementChild) ro.observe(el.firstElementChild);
912
+ });
913
+ window.addEventListener('resize', update);
914
+ return () => {
915
+ els.forEach((el) => el.removeEventListener('scroll', update));
916
+ ro.disconnect();
917
+ window.removeEventListener('resize', update);
918
+ };
919
+ }, [chatOpen, pathname]);
920
+
921
+ // Flag the sidebar section heading currently pinned at the top of the
922
+ // scroll region (CSS sticky gives no "is-stuck" hook). When the pinned
923
+ // heading changes as you scroll, the new one gets data-stuck and
924
+ // animates in (see sidebar.css). Re-binds on page/tab change since the
925
+ // section set changes with it.
926
+ React.useEffect(() => {
927
+ const scroller = leftAsideRef.current;
928
+ if (!scroller) return;
929
+ let prev = null;
930
+ const update = () => {
931
+ const top = scroller.getBoundingClientRect().top;
932
+ let stuck = null;
933
+ for (const h of scroller.querySelectorAll('.velu-sidebar__section')) {
934
+ if (h.getBoundingClientRect().top <= top + 1) stuck = h;
935
+ }
936
+ if (stuck !== prev) {
937
+ prev?.removeAttribute('data-stuck');
938
+ stuck?.setAttribute('data-stuck', 'true');
939
+ prev = stuck;
940
+ }
941
+ };
942
+ update();
943
+ scroller.addEventListener('scroll', update, { passive: true });
944
+ return () => scroller.removeEventListener('scroll', update);
945
+ }, [pathname, chatOpen]);
946
+
947
+ const footerRef = React.useRef(null);
948
+ const [footerOverlap, setFooterOverlap] = React.useState(0);
949
+ React.useEffect(() => {
950
+ const node = footerRef.current;
951
+ if (!node) return;
952
+ const update = () => {
953
+ const rect = node.getBoundingClientRect();
954
+ setFooterOverlap(Math.max(0, window.innerHeight - rect.top));
955
+ };
956
+ update();
957
+ window.addEventListener('scroll', update, { passive: true });
958
+ window.addEventListener('resize', update);
959
+ return () => {
960
+ window.removeEventListener('scroll', update);
961
+ window.removeEventListener('resize', update);
962
+ };
963
+ }, []);
964
+
965
+ // Sticky AskBar fades out once the user scrolls near the PageFeedback
966
+ // widget so it doesn't sit on top of the page-foot widgets.
967
+ const feedbackRef = React.useRef(null);
968
+ const [askBarHidden, setAskBarHidden] = React.useState(false);
969
+ React.useEffect(() => {
970
+ const node = feedbackRef.current;
971
+ if (!node) return;
972
+ const FADE_BUFFER = 64; // matches the rootMargin below
973
+ const apply = (rect) => {
974
+ // Hide whenever the feedback's top has reached the (effective)
975
+ // viewport-bottom line — covers both "feedback is in view" AND
976
+ // "feedback is already scrolled past" without flickering back on.
977
+ // Threshold matches the IO's rootMargin so the show/hide flip is
978
+ // exactly at the same line in both scroll directions.
979
+ setAskBarHidden(rect.top < window.innerHeight - FADE_BUFFER);
980
+ };
981
+ apply(node.getBoundingClientRect());
982
+ const io = new IntersectionObserver(
983
+ ([entry]) => apply(entry.boundingClientRect),
984
+ // Trigger ~64px before the feedback enters the viewport, so the
985
+ // AskBar fades just as the widget starts to peek up from below.
986
+ { rootMargin: '0px 0px -64px 0px' },
987
+ );
988
+ io.observe(node);
989
+ return () => io.disconnect();
990
+ }, []);
991
+
992
+ const scrollTo = React.useCallback(
993
+ (id) => {
994
+ const node = document.getElementById(id);
995
+ if (!node) return;
996
+ // 1) Set + lock the active id IMMEDIATELY so the spy doesn't
997
+ // overwrite it during the smooth-scroll animation.
998
+ setActive(id);
999
+ // 2) Compute the target scroll position MANUALLY (instead of
1000
+ // scrollIntoView). The browser clamps to max-scroll
1001
+ // automatically; the target is baked in at click time and
1002
+ // doesn't drift if layout shifts mid-animation.
1003
+ const offset =
1004
+ parseFloat(
1005
+ getComputedStyle(document.documentElement).getPropertyValue(
1006
+ '--velu-scroll-offset',
1007
+ ),
1008
+ ) || 0;
1009
+ const top = node.getBoundingClientRect().top + window.scrollY - offset;
1010
+ window.scrollTo({ top, behavior: 'smooth' });
1011
+ },
1012
+ [setActive],
1013
+ );
1014
+
1015
+ const kicker = {
1016
+ fontFamily: 'var(--font-mono)',
1017
+ fontSize: 11,
1018
+ letterSpacing: '0.6px',
1019
+ textTransform: 'uppercase',
1020
+ color: 'var(--muted-color)',
1021
+ };
1022
+
1023
+ return (
1024
+ <div
1025
+ className="velu-docs-layout"
1026
+ data-chat-open={chatOpen ? 'true' : 'false'}
1027
+ data-sidebar-open={sidebarOpen ? 'true' : 'false'}
1028
+ data-drawer-open={drawerOpen ? 'true' : 'false'}
1029
+ >
1030
+ {/* Scrim — visible at mobile while the drawer OR the chatbot
1031
+ sheet is open. Sits between the article (z-0) and the
1032
+ drawer/chatbot (z-35 / z-50) and blocks pointer events to
1033
+ everything beneath; click closes whichever surface is up. */}
1034
+ <div
1035
+ className="velu-docs-layout__scrim"
1036
+ aria-hidden="true"
1037
+ onClick={() => {
1038
+ setDrawerOpen(false);
1039
+ setChatOpen(false);
1040
+ }}
1041
+ />
1042
+ {/* Site header — brand, centered search, right-side actions,
1043
+ tabs row. Configurable: pass any number of actions / tabs. */}
1044
+ <PageHeader
1045
+ linkComponent={RouterLink}
1046
+ brand={{ label: 'Velu', href: '/' }}
1047
+ brandTrailing={
1048
+ versionSwitcher && (
1049
+ <span className="velu-hide-on-mobile">{versionSwitcher}</span>
1050
+ )
1051
+ }
1052
+ tabsTrailing={languageSwitcher || undefined}
1053
+ center={
1054
+ <Cluster space="var(--s-6)" align="center">
1055
+ <Search style={{ inlineSize: '30ch' }} unavailable={IS_DEV_PREVIEW} />
1056
+ {/* Ask AI talks to the deployed site's AI backend — hidden in
1057
+ the local dev preview where there's nothing to talk to. */}
1058
+ {!IS_DEV_PREVIEW && (
1059
+ <button
1060
+ type="button"
1061
+ className="velu-header__action velu-header__action--outlined"
1062
+ onClick={() => askAI('')}
1063
+ >
1064
+ <span className="velu-header__action-icon" aria-hidden="true">
1065
+ {resolveIcon('sparkles', { size: '1.5em' })}
1066
+ </span>
1067
+ <span>Ask AI</span>
1068
+ </button>
1069
+ )}
1070
+ </Cluster>
1071
+ }
1072
+ actions={[
1073
+ {
1074
+ label: 'Book Demo',
1075
+ kind: 'primary',
1076
+ href: '#',
1077
+ },
1078
+ ]}
1079
+ trailing={<ThemeToggle />}
1080
+ onMenuClick={() => setDrawerOpen((v) => !v)}
1081
+ breadcrumb={nav?.breadcrumb ?? []}
1082
+ activeTab={nav?.activeTab}
1083
+ tabs={nav?.tabs ?? []}
1084
+ />
1085
+
1086
+ {/* Fixed left sidebar pinned to viewport-left below the header.
1087
+ Does NOT scroll with the page; the footer rises over its bottom
1088
+ edge thanks to the higher z-index on the footer below.
1089
+ `top` + `bottom` give a robust height (some browsers don't
1090
+ honour `inset-block-start` for fixed positioning the same way
1091
+ as plain `top`). */}
1092
+ <aside
1093
+ className="velu-docs-layout__aside velu-docs-layout__aside--left"
1094
+ style={{
1095
+ /* Bottom edge stays a fixed gap above the viewport bottom,
1096
+ AND lifts to keep that gap above the footer as it scrolls
1097
+ into view (footerOverlap = how far the footer intrudes).
1098
+ Set as a custom prop so the mobile drawer's
1099
+ `inset-block-end: 0` override still wins. */
1100
+ '--velu-aside-bottom': `calc(${footerOverlap}px + var(--s4))`,
1101
+ }}
1102
+ >
1103
+ {/* Drawer body — Stack with 32px gap composes the slots
1104
+ (topbar / tab-dropdown / context / nav). The aside is a flex
1105
+ column (CSS): the pinned slots keep their height and only the
1106
+ nav region scrolls (see velu-docs-nav-scroll below). At wide
1107
+ widths the topbar + docselect are `display: none`. */}
1108
+ <Stack space="var(--s0)" className="velu-docs-aside-stack">
1109
+ <div className="velu-docs-layout__drawer-head">
1110
+ <RouterLink
1111
+ href="/"
1112
+ className="velu-docs-layout__drawer-brand"
1113
+ >
1114
+ <VeluMark />
1115
+ <span className="velu-header__wordmark">Velu</span>
1116
+ </RouterLink>
1117
+ <ThemeToggle />
1118
+ <button
1119
+ type="button"
1120
+ className="velu-docs-layout__drawer-close"
1121
+ aria-label="Close navigation"
1122
+ onClick={() => setDrawerOpen(false)}
1123
+ >
1124
+ <X aria-hidden="true" focusable="false" />
1125
+ </button>
1126
+ </div>
1127
+ {/* Nav dropdown — custom button + menu, fills drawer width.
1128
+ Items mirror the desktop tabs (Home / Docs / Blog).
1129
+ Click-outside + Escape close (see navOpen useEffect
1130
+ above). Chevron rotates 180° on open. */}
1131
+ <div
1132
+ ref={navRef}
1133
+ className="velu-docs-layout__drawer-docselect"
1134
+ data-open={navOpen ? 'true' : 'false'}
1135
+ >
1136
+ <button
1137
+ type="button"
1138
+ className="velu-docs-layout__drawer-docselect-btn"
1139
+ onClick={() => setNavOpen((o) => !o)}
1140
+ aria-haspopup="menu"
1141
+ aria-expanded={navOpen}
1142
+ >
1143
+ <span className="velu-docs-layout__drawer-docselect-label">
1144
+ {activeNavLabel}
1145
+ </span>
1146
+ <ChevronDown
1147
+ className="velu-docs-layout__drawer-docselect-chev"
1148
+ aria-hidden="true"
1149
+ focusable="false"
1150
+ />
1151
+ </button>
1152
+ <ul
1153
+ className="velu-docs-layout__drawer-docselect-menu"
1154
+ role="menu"
1155
+ aria-hidden={!navOpen}
1156
+ >
1157
+ {navItems.map((it) => (
1158
+ <li key={it.href} role="none">
1159
+ <a
1160
+ role="menuitem"
1161
+ className="velu-docs-layout__drawer-docselect-item"
1162
+ href={it.href}
1163
+ tabIndex={navOpen ? 0 : -1}
1164
+ onClick={() => setNavOpen(false)}
1165
+ >
1166
+ {it.label}
1167
+ </a>
1168
+ </li>
1169
+ ))}
1170
+ </ul>
1171
+ </div>
1172
+ {/* Context zone — product switcher + anchors at the top of
1173
+ the sidebar (all breakpoints), plus version/language
1174
+ switchers that only show on mobile (desktop has them in
1175
+ the header). Rendered only when there's something to show
1176
+ so simple projects keep a bare sidebar. */}
1177
+ {(productSwitcher ||
1178
+ versionSwitcher ||
1179
+ languageSwitcher ||
1180
+ anchors.length > 0) && (
1181
+ <Stack space="var(--s-1)" className="velu-docs-context">
1182
+ {productSwitcher}
1183
+ {versionSwitcher && (
1184
+ <span className="velu-show-on-mobile">{versionSwitcher}</span>
1185
+ )}
1186
+ {languageSwitcher && (
1187
+ <span className="velu-show-on-mobile">{languageSwitcher}</span>
1188
+ )}
1189
+ {anchors.length > 0 && (
1190
+ <ul className="velu-docs-anchors">
1191
+ {anchors.map((a, i) => (
1192
+ <li key={i}>
1193
+ <a
1194
+ className="velu-docs-anchors__link"
1195
+ href={a.href}
1196
+ target="_blank"
1197
+ rel="noreferrer"
1198
+ >
1199
+ {a.icon && (
1200
+ <span
1201
+ className="velu-docs-anchors__icon"
1202
+ aria-hidden="true"
1203
+ >
1204
+ {resolveIcon(a.icon, { size: '1em' })}
1205
+ </span>
1206
+ )}
1207
+ <span>{a.label}</span>
1208
+ </a>
1209
+ </li>
1210
+ ))}
1211
+ </ul>
1212
+ )}
1213
+ </Stack>
1214
+ )}
1215
+ {/* Only this region scrolls — the context zone above stays
1216
+ pinned. The up/down arrows overlay its top/bottom edges and
1217
+ appear (via the data-fade-* attrs the scroll handler sets)
1218
+ when there's content beyond that edge; clicking jumps the
1219
+ nav fully to that end. */}
1220
+ <div className="velu-docs-nav-region">
1221
+ <div
1222
+ ref={leftAsideRef}
1223
+ className="velu-docs-nav-scroll velu-hide-scrollbar"
1224
+ style={{
1225
+ /* Just breathing room — the aside's bottom edge already
1226
+ stays above the footer (see --velu-aside-bottom). */
1227
+ paddingBlockEnd: 'var(--s1)',
1228
+ scrollPaddingBlockEnd: 'var(--s1)',
1229
+ }}
1230
+ >
1231
+ <Sidebar
1232
+ sections={nav?.sidebarSections ?? []}
1233
+ activeHref={pathname}
1234
+ linkComponent={RouterLink}
1235
+ />
1236
+ </div>
1237
+ <button
1238
+ type="button"
1239
+ className="velu-docs-nav-arrow velu-docs-nav-arrow--up"
1240
+ aria-label="Scroll navigation to top"
1241
+ onClick={() =>
1242
+ leftAsideRef.current?.scrollTo({ top: 0, behavior: 'smooth' })
1243
+ }
1244
+ >
1245
+ <ChevronUp aria-hidden="true" focusable="false" />
1246
+ </button>
1247
+ <button
1248
+ type="button"
1249
+ className="velu-docs-nav-arrow velu-docs-nav-arrow--down"
1250
+ aria-label="Scroll navigation to bottom"
1251
+ onClick={() =>
1252
+ leftAsideRef.current?.scrollTo({
1253
+ top: leftAsideRef.current.scrollHeight,
1254
+ behavior: 'smooth',
1255
+ })
1256
+ }
1257
+ >
1258
+ <ChevronDown aria-hidden="true" focusable="false" />
1259
+ </button>
1260
+ </div>
1261
+ </Stack>
1262
+ </aside>
1263
+
1264
+ {/* No separate rail element — at narrow widths the sidebar's
1265
+ aside ANIMATES its `inline-size` between 240px (open) and
1266
+ --velu-rail-width (closed), and its inner Sidebar nav fades
1267
+ out via opacity. The aside's border-inline-end therefore
1268
+ becomes the rail's right border when collapsed. This makes
1269
+ the collapse a smooth width+opacity transition instead of a
1270
+ display:none snap. See docs-layout.css. */}
1271
+
1272
+ {/* Fixed right TOC — pinned to viewport-right. Hidden while the
1273
+ Ask-AI chatbot is open (the panel takes that edge). */}
1274
+ {!chatOpen && (
1275
+ <aside
1276
+ ref={rightAsideRef}
1277
+ className="velu-docs-layout__aside velu-docs-layout__aside--right velu-hide-scrollbar"
1278
+ style={{
1279
+ /* Dynamic footer-overlap padding only static geometry
1280
+ lives in docs-layout.css. */
1281
+ paddingBlockEnd: `calc(var(--s3) + ${footerOverlap}px + 2rem)`,
1282
+ scrollPaddingBlockEnd: `calc(${footerOverlap}px + 2rem)`,
1283
+ }}
1284
+ >
1285
+ <Toc items={toc} activeId={activeId} onSelect={scrollTo} />
1286
+ </aside>
1287
+ )}
1288
+
1289
+ {/* Center column. Margin to reserve aside space lives in
1290
+ docs-layout.css (drops to 0 at narrow widths via @container,
1291
+ and the right margin collapses to 0 while the chatbot is
1292
+ open via [data-chat-open="true"]). */}
1293
+ <div className="velu-docs-layout__center">
1294
+ {/* Narrow-layout TOC bar always in DOM, only visible at
1295
+ < 1024px (toggled by @container in toc-bar.css). Shares
1296
+ its `items` + `activeId` + `onSelect` API with the
1297
+ right-rail <Toc> so both views are driven by the same
1298
+ data; whichever one is visible at a given width responds
1299
+ to the same scroll-spy state. */}
1300
+ <TocBar items={toc} activeId={activeId} onSelect={scrollTo} />
1301
+ <main
1302
+ className="velu-docs-layout__main"
1303
+ style={{
1304
+ /* No padding-block-end — the article's last child (PoweredBy)
1305
+ owns the gap to the footer via its own margin-bottom, so
1306
+ padding-bottom here would double-count it. `position:
1307
+ relative` makes <main> the offsetParent for the absolutely
1308
+ positioned sidebar-toggle below so its `top: 0` lands
1309
+ at the top of the article area, BELOW the sticky TocBar
1310
+ (which lives outside <main>). Padding-inline lives in CSS
1311
+ so the @container query can collapse the start side when
1312
+ the sidebar is closed (no "ghost column" on the left). */
1313
+ position: 'relative',
1314
+ color: 'var(--text-color)',
1315
+ }}
1316
+ >
1317
+ {/* Sidebar toggle narrow-layout only (hidden by @container
1318
+ at wide widths). Lives inside <main> so its absolute
1319
+ position is relative to the article area, not the centre
1320
+ column, and therefore sits BELOW the TocBar rather than
1321
+ overlapping it. Chevron flips direction with the
1322
+ `data-sidebar-open` data attribute on the layout root. */}
1323
+ <button
1324
+ type="button"
1325
+ className="velu-docs-layout__sidebar-toggle"
1326
+ onClick={() => setSidebarOpen((v) => !v)}
1327
+ aria-label={sidebarOpen ? 'Collapse sidebar' : 'Expand sidebar'}
1328
+ aria-expanded={sidebarOpen}
1329
+ >
1330
+ <span aria-hidden="true">
1331
+ {resolveIcon(sidebarOpen ? 'chevron-left' : 'chevron-right', {
1332
+ size: '1em',
1333
+ })}
1334
+ </span>
1335
+ </button>
1336
+ <div className="velu-docs-layout__article">
1337
+ {/* Page hero from MDX frontmatter. `.velu-hero` rules
1338
+ (in base.css) keep the title and description tightly
1339
+ grouped and create a clear break before the prose body. */}
1340
+ {(frontmatter.title || frontmatter.description) && (
1341
+ <div className="velu-hero">
1342
+ {frontmatter.title && <h1 id={pageId}>{frontmatter.title}</h1>}
1343
+ {frontmatter.description && (
1344
+ <p
1345
+ style={{
1346
+ color: 'var(--muted-color)',
1347
+ fontSize: 'var(--f-h4)',
1348
+ lineHeight: 'var(--lh-h4)',
1349
+ }}
1350
+ >
1351
+ {frontmatter.description}
1352
+ </p>
1353
+ )}
1354
+ </div>
1355
+ )}
1356
+
1357
+ {/* Article body — the current route's MDX page, rendered
1358
+ through the velu-ui MDX component registry. `velu-prose`
1359
+ gives a consistent vertical rhythm scaled by heading
1360
+ level. Falls back to a not-found / missing-file notice
1361
+ when the route has no page (or its file is absent). */}
1362
+ <MDXProvider components={defaultMdxComponents}>
1363
+ <div className="velu-prose">
1364
+ {PageComponent ? (
1365
+ <ErrorBoundary key={pathname} file={entry?.relPath}>
1366
+ <PageComponent />
1367
+ </ErrorBoundary>
1368
+ ) : (
1369
+ <p style={{ color: 'var(--muted-color)' }}>
1370
+ {entry?.missing
1371
+ ? 'This page is listed in navigation but its .mdx file was not found.'
1372
+ : 'Page not found.'}
1373
+ </p>
1374
+ )}
1375
+ </div>
1376
+ </MDXProvider>
1377
+ {/* Page-foot feedback widget — ref'd so the sticky AskBar
1378
+ above can hide as the user scrolls near it. */}
1379
+ <div ref={feedbackRef} style={{ marginTop: 'var(--s3)' }}>
1380
+ <PageFeedback />
1381
+ </div>
1382
+ {/* Previous / next page navigation derived from the
1383
+ sidebar reading order of the active section. */}
1384
+ {(nav?.prev || nav?.next) && (
1385
+ <PageNav
1386
+ style={{ marginTop: 'var(--s2)' }}
1387
+ prev={nav?.prev}
1388
+ next={nav?.next}
1389
+ linkComponent={RouterLink}
1390
+ />
1391
+ )}
1392
+ {/* "Ask a question" bar sticky to viewport-bottom while the
1393
+ article column is in view; lives inside the prose-column
1394
+ div so its width matches the article. Submitting opens
1395
+ the Ask-AI chatbot; fades out as the PageFeedback widget
1396
+ approaches (see IntersectionObserver above). */}
1397
+ {/* Ask-a-question bar opens the AI chatbot, which runs on the
1398
+ deployed site. Hidden in the local dev preview. */}
1399
+ {!IS_DEV_PREVIEW && (
1400
+ <AskBar
1401
+ onSubmit={askAI}
1402
+ style={{
1403
+ position: 'sticky',
1404
+ insetBlockEnd: 'var(--s1)',
1405
+ /* Once the user has scrolled near the feedback widget the
1406
+ AskBar fades and collapses to zero flow space — height,
1407
+ margin, padding all drop to 0 so the next element
1408
+ (PoweredBy) sits directly under PageNav at its own
1409
+ 32px margin, with no phantom gap. */
1410
+ marginTop: askBarHidden ? 0 : 'var(--s2)',
1411
+ height: askBarHidden ? 0 : 'auto',
1412
+ overflow: 'hidden',
1413
+ opacity: askBarHidden ? 0 : 1,
1414
+ transform: askBarHidden ? 'translateY(20%)' : 'translateY(0)',
1415
+ pointerEvents: askBarHidden ? 'none' : 'auto',
1416
+ transition: 'opacity 0.2s ease, transform 0.2s ease',
1417
+ }}
1418
+ />
1419
+ )}
1420
+ {/* "Powered by Velu" attribution — bottom-right of the
1421
+ article column, just under the AskBar. Muted so it reads
1422
+ as a footer-of-content note, not a brand statement. */}
1423
+ <PoweredBy />
1424
+ </div>
1425
+ </main>
1426
+ </div>
1427
+
1428
+ {/* Site footer — spans full width below the article. Its raised
1429
+ z-index ensures it visually eclipses the bottoms of the fixed
1430
+ left sidebar and right TOC as the page scrolls into it. The
1431
+ ref is watched so the asides can pad their bottom by the same
1432
+ overlap amount, keeping every item scrollable into view. */}
1433
+ <div
1434
+ ref={footerRef}
1435
+ data-velu-footer
1436
+ style={{ position: 'relative', zIndex: 20 }}
1437
+ >
1438
+ <PageFooter
1439
+ brand={{ href: '#' }}
1440
+ columns={[
1441
+ {
1442
+ title: 'Resources',
1443
+ items: [
1444
+ { label: 'Showcase', href: '#' },
1445
+ { label: 'Enterprise', href: '#' },
1446
+ { label: 'Status', href: '#' },
1447
+ ],
1448
+ },
1449
+ {
1450
+ title: 'Company',
1451
+ items: [
1452
+ { label: 'Careers', href: '#' },
1453
+ { label: 'Blog', href: '#' },
1454
+ { label: 'Community', href: '#' },
1455
+ ],
1456
+ },
1457
+ {
1458
+ title: 'Policies',
1459
+ items: [
1460
+ { label: 'Subprocessors', href: '#' },
1461
+ { label: 'Terms of Service', href: '#' },
1462
+ ],
1463
+ },
1464
+ ]}
1465
+ socials={[
1466
+ { kind: 'github', href: 'https://github.com/aravindc26/velu-cli' },
1467
+ { kind: 'x', href: 'https://x.com/' },
1468
+ { kind: 'youtube', href: 'https://youtube.com/' },
1469
+ { kind: 'linkedin', href: 'https://linkedin.com/' },
1470
+ ]}
1471
+ />
1472
+ </div>
1473
+
1474
+ {/* Ask-AI chatbot — slides in from the inline-end edge. */}
1475
+ <Chatbot
1476
+ open={chatOpen}
1477
+ seedQuestion={chatQuestion}
1478
+ onClose={() => setChatOpen(false)}
1479
+ />
1480
+ </div>
1481
+ );
1482
+ }
1483
+
1484
+ export default function App() {
1485
+ return (
1486
+ <Routes>
1487
+ <Route path="*" element={<DocsPage />} />
1488
+ </Routes>
1489
+ );
1490
+ }