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