@veluai/velu 0.2.24 → 0.2.27

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