@verbb/vitepress-theme 1.0.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/README.md +41 -0
- package/package.json +32 -0
- package/src/Layout.vue +1077 -0
- package/src/components/DocsIcon.vue +100 -0
- package/src/components/DocsMobileMenu.vue +68 -0
- package/src/components/DocsMobileMenuNode.vue +114 -0
- package/src/components/DocsNotFound.vue +41 -0
- package/src/components/DocsOutline.vue +284 -0
- package/src/components/DocsOutlineItem.vue +65 -0
- package/src/components/DocsSearchProvider.vue +51 -0
- package/src/components/DocsSidebar.vue +41 -0
- package/src/components/DocsSidebarNode.vue +114 -0
- package/src/custom.css +547 -0
- package/src/env.d.ts +8 -0
- package/src/index.ts +22 -0
- package/src/search.ts +17 -0
- package/src/sidebar.ts +218 -0
package/src/Layout.vue
ADDED
|
@@ -0,0 +1,1077 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
3
|
+
import { Content, onContentUpdated, useData, useRoute, withBase } from 'vitepress';
|
|
4
|
+
import DocsMobileMenu from './components/DocsMobileMenu.vue';
|
|
5
|
+
import DocsNotFound from './components/DocsNotFound.vue';
|
|
6
|
+
import DocsOutline from './components/DocsOutline.vue';
|
|
7
|
+
import DocsSearchProvider from './components/DocsSearchProvider.vue';
|
|
8
|
+
import DocsSidebar from './components/DocsSidebar.vue';
|
|
9
|
+
import { openDocsSearch } from './search';
|
|
10
|
+
import { hasActiveSidebarItem, isActivePath, type SidebarGroup, type SidebarItem, useCloseSidebarOnEscape, useDocsSidebar } from './sidebar';
|
|
11
|
+
|
|
12
|
+
type DocsThemeOptions = {
|
|
13
|
+
primary?: string;
|
|
14
|
+
primaryStrong?: string;
|
|
15
|
+
primarySoft?: string;
|
|
16
|
+
primarySoftHover?: string;
|
|
17
|
+
primaryBorder?: string;
|
|
18
|
+
primaryBorderStrong?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type DocsNavItem = {
|
|
22
|
+
text?: string;
|
|
23
|
+
link?: string;
|
|
24
|
+
activeMatch?: string;
|
|
25
|
+
items?: DocsNavItem[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type DocsNavLink = {
|
|
29
|
+
text: string;
|
|
30
|
+
link: string;
|
|
31
|
+
activeMatch?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const route = useRoute();
|
|
35
|
+
const { frontmatter, page, site, theme } = useData();
|
|
36
|
+
const { close, hasSidebar, isOpen, toggle, sidebarGroups } = useDocsSidebar();
|
|
37
|
+
const docsScrollContainer = ref<HTMLDivElement | null>(null);
|
|
38
|
+
const navigationItems = ref<HTMLDivElement | null>(null);
|
|
39
|
+
const sidebarHasTopFade = ref(false);
|
|
40
|
+
const topNavRootDesktop = ref<HTMLDivElement | null>(null);
|
|
41
|
+
const topNavRootMobile = ref<HTMLDivElement | null>(null);
|
|
42
|
+
const topNavMenuDesktopOpen = ref(false);
|
|
43
|
+
const topNavMenuMobileOpen = ref(false);
|
|
44
|
+
|
|
45
|
+
useCloseSidebarOnEscape(isOpen, close);
|
|
46
|
+
|
|
47
|
+
watch(() => route.path, close);
|
|
48
|
+
watch(() => route.path, async (nextPath, previousPath) => {
|
|
49
|
+
await syncRouteScroll(nextPath, previousPath);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const logoSrc = computed(() => {
|
|
53
|
+
if (!theme.value.logo) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return typeof theme.value.logo === 'string'
|
|
58
|
+
? withBase(theme.value.logo)
|
|
59
|
+
: withBase(theme.value.logo.src);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const showOutline = computed(() => {
|
|
63
|
+
if (frontmatter.value.layout === false || frontmatter.value.layout === 'home') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (frontmatter.value.aside === false) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (frontmatter.value.outline ?? theme.value.outline) !== false;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const siteTitle = computed(() => {
|
|
75
|
+
if (typeof theme.value.siteTitle === 'string' && theme.value.siteTitle.trim()) {
|
|
76
|
+
return theme.value.siteTitle;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return site.value.title;
|
|
80
|
+
});
|
|
81
|
+
const socialLinks = computed(() => theme.value.socialLinks ?? []);
|
|
82
|
+
const currentSidebarGroup = computed<SidebarGroup | null>(() => {
|
|
83
|
+
return sidebarGroups.value.find((group) => {
|
|
84
|
+
return group.items?.some((item) => hasActiveSidebarItem(page.value.relativePath, item as SidebarItem));
|
|
85
|
+
}) ?? null;
|
|
86
|
+
});
|
|
87
|
+
const mobilePageTitle = computed(() => {
|
|
88
|
+
return frontmatter.value.title
|
|
89
|
+
?? page.value.title
|
|
90
|
+
?? siteTitle.value;
|
|
91
|
+
});
|
|
92
|
+
const mobileBreadcrumbs = computed(() => {
|
|
93
|
+
const items = [sectionLabel.value, mobilePageTitle.value]
|
|
94
|
+
.filter((value): value is string => Boolean(value?.trim()));
|
|
95
|
+
|
|
96
|
+
return items.filter((value, index) => value !== items[index - 1]);
|
|
97
|
+
});
|
|
98
|
+
const mobileBreadcrumbLead = computed(() => {
|
|
99
|
+
return mobileBreadcrumbs.value.length > 1
|
|
100
|
+
? mobileBreadcrumbs.value[0]
|
|
101
|
+
: null;
|
|
102
|
+
});
|
|
103
|
+
const mobileBreadcrumbCurrent = computed(() => {
|
|
104
|
+
return mobileBreadcrumbs.value.at(-1) ?? siteTitle.value;
|
|
105
|
+
});
|
|
106
|
+
const hasSearch = computed(() => {
|
|
107
|
+
const searchConfig = (theme.value as typeof theme.value & {
|
|
108
|
+
search?: { provider?: string; };
|
|
109
|
+
algolia?: unknown;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return Boolean(searchConfig.search?.provider || searchConfig.algolia);
|
|
113
|
+
});
|
|
114
|
+
const docsTheme = computed(() => {
|
|
115
|
+
return ((theme.value as typeof theme.value & { docsTheme?: DocsThemeOptions; }).docsTheme ?? {});
|
|
116
|
+
});
|
|
117
|
+
const editLinkConfig = computed(() => {
|
|
118
|
+
return (theme.value as typeof theme.value & {
|
|
119
|
+
editLink?: { pattern?: string; text?: string; };
|
|
120
|
+
}).editLink;
|
|
121
|
+
});
|
|
122
|
+
const lastUpdatedText = computed(() => {
|
|
123
|
+
return (theme.value as typeof theme.value & { lastUpdatedText?: string; }).lastUpdatedText ?? 'Last updated';
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
function flattenSidebarLinks(items: SidebarItem[]): SidebarItem[] {
|
|
127
|
+
const links: SidebarItem[] = [];
|
|
128
|
+
|
|
129
|
+
for (const item of items) {
|
|
130
|
+
if (item.link) {
|
|
131
|
+
links.push(item);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (item.items?.length) {
|
|
135
|
+
links.push(...flattenSidebarLinks(item.items));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return links;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function findActiveSidebarTrail(items: SidebarItem[], currentPath: string): SidebarItem[] | null {
|
|
143
|
+
for (const item of items) {
|
|
144
|
+
if (item.link && hasActiveSidebarItem(currentPath, item)) {
|
|
145
|
+
return [item];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!item.items?.length) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const childTrail = findActiveSidebarTrail(item.items, currentPath);
|
|
153
|
+
|
|
154
|
+
if (childTrail) {
|
|
155
|
+
return [item, ...childTrail];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function flattenNavItems(items: DocsNavItem[]): DocsNavLink[] {
|
|
163
|
+
const links: DocsNavLink[] = [];
|
|
164
|
+
|
|
165
|
+
for (const item of items) {
|
|
166
|
+
if (item.text && item.link) {
|
|
167
|
+
links.push({
|
|
168
|
+
text: item.text,
|
|
169
|
+
link: item.link,
|
|
170
|
+
activeMatch: item.activeMatch,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (item.items?.length) {
|
|
175
|
+
links.push(...flattenNavItems(item.items));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return links;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function normalizeRoutePath(path: string) {
|
|
183
|
+
const sanitizedPath = decodeURI(path).split(/[?#]/, 1)[0] || '/';
|
|
184
|
+
|
|
185
|
+
if (sanitizedPath === '/') {
|
|
186
|
+
return '/';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const withoutIndex = sanitizedPath.replace(/\/index(?:\.html)?$/, '/');
|
|
190
|
+
const withoutExtension = withoutIndex.replace(/\.html$/, '');
|
|
191
|
+
|
|
192
|
+
return withoutExtension === '/'
|
|
193
|
+
? '/'
|
|
194
|
+
: withoutExtension.replace(/\/+$/, '');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const currentRoutePath = computed(() => normalizeRoutePath(route.path));
|
|
198
|
+
const topNavLinks = computed(() => {
|
|
199
|
+
const nav = Array.isArray(theme.value.nav) ? theme.value.nav as DocsNavItem[] : [];
|
|
200
|
+
|
|
201
|
+
return flattenNavItems(nav);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
function isTopNavLinkActive(item: DocsNavLink) {
|
|
205
|
+
if (item.activeMatch) {
|
|
206
|
+
return new RegExp(item.activeMatch).test(currentRoutePath.value);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const targetPath = normalizeRoutePath(item.link);
|
|
210
|
+
|
|
211
|
+
if (targetPath === '/') {
|
|
212
|
+
return currentRoutePath.value === '/';
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return currentRoutePath.value === targetPath
|
|
216
|
+
|| currentRoutePath.value.startsWith(`${targetPath}/`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const activeTopNavItem = computed(() => {
|
|
220
|
+
return topNavLinks.value.find((item) => isTopNavLinkActive(item)) ?? null;
|
|
221
|
+
});
|
|
222
|
+
const activeTopNavLabel = computed(() => {
|
|
223
|
+
return activeTopNavItem.value?.text
|
|
224
|
+
?? topNavLinks.value[0]?.text
|
|
225
|
+
?? 'Documentation';
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
function closeTopNavMenus() {
|
|
229
|
+
topNavMenuDesktopOpen.value = false;
|
|
230
|
+
topNavMenuMobileOpen.value = false;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function toggleTopNavMenuDesktop() {
|
|
234
|
+
topNavMenuDesktopOpen.value = !topNavMenuDesktopOpen.value;
|
|
235
|
+
topNavMenuMobileOpen.value = false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function toggleTopNavMenuMobile() {
|
|
239
|
+
topNavMenuMobileOpen.value = !topNavMenuMobileOpen.value;
|
|
240
|
+
topNavMenuDesktopOpen.value = false;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function onDocumentPointerDown(event: MouseEvent | PointerEvent) {
|
|
244
|
+
const target = event.target as Node;
|
|
245
|
+
|
|
246
|
+
if (
|
|
247
|
+
topNavMenuDesktopOpen.value
|
|
248
|
+
&& topNavRootDesktop.value
|
|
249
|
+
&& !topNavRootDesktop.value.contains(target)
|
|
250
|
+
) {
|
|
251
|
+
topNavMenuDesktopOpen.value = false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (
|
|
255
|
+
topNavMenuMobileOpen.value
|
|
256
|
+
&& topNavRootMobile.value
|
|
257
|
+
&& !topNavRootMobile.value.contains(target)
|
|
258
|
+
) {
|
|
259
|
+
topNavMenuMobileOpen.value = false;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
watch(() => route.path, closeTopNavMenus);
|
|
264
|
+
|
|
265
|
+
const sectionLabel = computed(() => {
|
|
266
|
+
const currentGroup = currentSidebarGroup.value;
|
|
267
|
+
|
|
268
|
+
if (!currentGroup?.items?.length) {
|
|
269
|
+
return currentGroup?.text ?? null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const activeTrail = findActiveSidebarTrail(currentGroup.items as SidebarItem[], page.value.relativePath);
|
|
273
|
+
|
|
274
|
+
if (!activeTrail?.length || activeTrail.length === 1) {
|
|
275
|
+
return currentGroup.text ?? null;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return activeTrail.at(-2)?.text ?? currentGroup.text ?? null;
|
|
279
|
+
});
|
|
280
|
+
const flatSectionLinks = computed(() => {
|
|
281
|
+
return currentSidebarGroup.value?.items?.length
|
|
282
|
+
? flattenSidebarLinks(currentSidebarGroup.value.items as SidebarItem[])
|
|
283
|
+
: [];
|
|
284
|
+
});
|
|
285
|
+
const currentSectionIndex = computed(() => {
|
|
286
|
+
return flatSectionLinks.value.findIndex((item) => isActivePath(page.value.relativePath, item.link));
|
|
287
|
+
});
|
|
288
|
+
const previousPageLink = computed(() => {
|
|
289
|
+
const index = currentSectionIndex.value;
|
|
290
|
+
|
|
291
|
+
return index > 0 ? flatSectionLinks.value[index - 1] : null;
|
|
292
|
+
});
|
|
293
|
+
const nextPageLink = computed(() => {
|
|
294
|
+
const index = currentSectionIndex.value;
|
|
295
|
+
|
|
296
|
+
return index >= 0 && index < flatSectionLinks.value.length - 1
|
|
297
|
+
? flatSectionLinks.value[index + 1]
|
|
298
|
+
: null;
|
|
299
|
+
});
|
|
300
|
+
const editLink = computed(() => {
|
|
301
|
+
if (frontmatter.value.editLink === false) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const pattern = editLinkConfig.value?.pattern;
|
|
306
|
+
const filePath = page.value.filePath;
|
|
307
|
+
|
|
308
|
+
if (!pattern || !filePath) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
text: editLinkConfig.value?.text ?? 'Edit this page',
|
|
314
|
+
href: pattern.replace(':path', filePath),
|
|
315
|
+
};
|
|
316
|
+
});
|
|
317
|
+
const formattedLastUpdated = computed(() => {
|
|
318
|
+
if (frontmatter.value.lastUpdated === false) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const value = (page.value as typeof page.value & { lastUpdated?: number; }).lastUpdated;
|
|
323
|
+
|
|
324
|
+
if (!value) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return new Intl.DateTimeFormat(site.value.lang || undefined, {
|
|
329
|
+
dateStyle: 'medium',
|
|
330
|
+
timeStyle: 'short',
|
|
331
|
+
}).format(value);
|
|
332
|
+
});
|
|
333
|
+
const docsThemeStyle = computed<Record<string, string>>(() => {
|
|
334
|
+
const primary = docsTheme.value.primary?.trim() || '#0f766e';
|
|
335
|
+
|
|
336
|
+
return {
|
|
337
|
+
'--docs-primary': primary,
|
|
338
|
+
'--docs-primary-strong': docsTheme.value.primaryStrong?.trim()
|
|
339
|
+
|| `color-mix(in oklab, ${primary} 82%, black)`,
|
|
340
|
+
'--docs-primary-soft': docsTheme.value.primarySoft?.trim()
|
|
341
|
+
|| `color-mix(in oklab, ${primary} 12%, white)`,
|
|
342
|
+
'--docs-primary-soft-hover': docsTheme.value.primarySoftHover?.trim()
|
|
343
|
+
|| `color-mix(in oklab, ${primary} 16%, white)`,
|
|
344
|
+
'--docs-primary-border': docsTheme.value.primaryBorder?.trim()
|
|
345
|
+
|| `color-mix(in oklab, ${primary} 18%, white)`,
|
|
346
|
+
'--docs-primary-border-strong': docsTheme.value.primaryBorderStrong?.trim()
|
|
347
|
+
|| `color-mix(in oklab, ${primary} 28%, white)`,
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
function updateSidebarFade() {
|
|
352
|
+
const element = navigationItems.value;
|
|
353
|
+
|
|
354
|
+
if (!element) {
|
|
355
|
+
sidebarHasTopFade.value = false;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
sidebarHasTopFade.value = element.scrollTop > 4;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function getRoutePathname(path: string) {
|
|
363
|
+
return path.split('#')[0] ?? path;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function getRouteHash(path: string) {
|
|
367
|
+
const hashIndex = path.indexOf('#');
|
|
368
|
+
|
|
369
|
+
return hashIndex >= 0 ? decodeURIComponent(path.slice(hashIndex + 1)) : '';
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function getActiveHash(path: string) {
|
|
373
|
+
const routeHash = getRouteHash(path);
|
|
374
|
+
|
|
375
|
+
if (routeHash) {
|
|
376
|
+
return routeHash;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return typeof window !== 'undefined'
|
|
380
|
+
? decodeURIComponent(window.location.hash.replace(/^#/, ''))
|
|
381
|
+
: '';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function getScrollContainer() {
|
|
385
|
+
return docsScrollContainer.value
|
|
386
|
+
?? document.getElementById('docs-scroll-container')
|
|
387
|
+
?? document.getElementById('content-container');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function resetContentScroll() {
|
|
391
|
+
getScrollContainer()?.scrollTo({ top: 0, left: 0, behavior: 'auto' });
|
|
392
|
+
window.scrollTo({ top: 0, left: 0, behavior: 'auto' });
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function scrollContentToHash(hash: string) {
|
|
396
|
+
if (!hash) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const target = document.getElementById(hash);
|
|
401
|
+
const scrollContainer = getScrollContainer();
|
|
402
|
+
|
|
403
|
+
if (!(target instanceof HTMLElement)) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (!(scrollContainer instanceof HTMLElement)) {
|
|
408
|
+
target.scrollIntoView({ block: 'start' });
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const top = scrollContainer.scrollTop
|
|
413
|
+
+ target.getBoundingClientRect().top
|
|
414
|
+
- scrollContainer.getBoundingClientRect().top
|
|
415
|
+
- 24;
|
|
416
|
+
|
|
417
|
+
scrollContainer.scrollTo({
|
|
418
|
+
top: Math.max(0, top),
|
|
419
|
+
left: 0,
|
|
420
|
+
behavior: 'auto',
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
async function syncRouteScroll(nextPath: string, previousPath?: string) {
|
|
427
|
+
await nextTick();
|
|
428
|
+
updateSidebarFade();
|
|
429
|
+
|
|
430
|
+
if (getRoutePathname(nextPath) !== getRoutePathname(previousPath ?? '')) {
|
|
431
|
+
resetContentScroll();
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const hash = getActiveHash(nextPath);
|
|
435
|
+
|
|
436
|
+
if (hash) {
|
|
437
|
+
await nextTick();
|
|
438
|
+
scrollContentToHash(hash);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function createSvgIcon(
|
|
443
|
+
pathData: string,
|
|
444
|
+
className: string,
|
|
445
|
+
options?: {
|
|
446
|
+
fill?: boolean;
|
|
447
|
+
size?: number;
|
|
448
|
+
strokeWidth?: number;
|
|
449
|
+
viewBox?: string;
|
|
450
|
+
},
|
|
451
|
+
) {
|
|
452
|
+
const size = options?.size ?? 18;
|
|
453
|
+
const strokeWidth = options?.strokeWidth ?? 1.5;
|
|
454
|
+
const viewBox = options?.viewBox ?? `0 0 ${size} ${size}`;
|
|
455
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
456
|
+
svg.setAttribute('width', String(size));
|
|
457
|
+
svg.setAttribute('height', String(size));
|
|
458
|
+
svg.setAttribute('viewBox', viewBox);
|
|
459
|
+
svg.setAttribute('fill', 'none');
|
|
460
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
461
|
+
svg.setAttribute('class', className);
|
|
462
|
+
|
|
463
|
+
for (const d of pathData.split('||')) {
|
|
464
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
465
|
+
path.setAttribute('d', d);
|
|
466
|
+
if (options?.fill) {
|
|
467
|
+
path.setAttribute('fill', 'currentColor');
|
|
468
|
+
} else {
|
|
469
|
+
path.setAttribute('stroke', 'currentColor');
|
|
470
|
+
path.setAttribute('stroke-width', String(strokeWidth));
|
|
471
|
+
path.setAttribute('stroke-linecap', 'round');
|
|
472
|
+
path.setAttribute('stroke-linejoin', 'round');
|
|
473
|
+
}
|
|
474
|
+
svg.append(path);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return svg;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
async function copyTextToClipboard(text: string): Promise<boolean> {
|
|
481
|
+
try {
|
|
482
|
+
if (navigator.clipboard?.writeText) {
|
|
483
|
+
await navigator.clipboard.writeText(text);
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
} catch {
|
|
487
|
+
// Fall back to the legacy copy path below.
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const textarea = document.createElement('textarea');
|
|
491
|
+
textarea.value = text;
|
|
492
|
+
textarea.setAttribute('readonly', '');
|
|
493
|
+
textarea.style.position = 'fixed';
|
|
494
|
+
textarea.style.opacity = '0';
|
|
495
|
+
textarea.style.pointerEvents = 'none';
|
|
496
|
+
document.body.append(textarea);
|
|
497
|
+
textarea.select();
|
|
498
|
+
textarea.setSelectionRange(0, text.length);
|
|
499
|
+
|
|
500
|
+
try {
|
|
501
|
+
return document.execCommand('copy');
|
|
502
|
+
} finally {
|
|
503
|
+
textarea.remove();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function getCodeBlockText(block: HTMLElement): string {
|
|
508
|
+
const lines = Array.from(block.querySelectorAll('pre code .line'));
|
|
509
|
+
|
|
510
|
+
if (lines.length) {
|
|
511
|
+
return lines
|
|
512
|
+
.map((line) => line.textContent ?? '')
|
|
513
|
+
.join('\n')
|
|
514
|
+
.replace(/\n$/, '');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const code = block.querySelector('pre code');
|
|
518
|
+
return (code?.textContent ?? '').replace(/\n$/, '');
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function getHeadingUrl(id: string): URL {
|
|
522
|
+
const url = new URL(window.location.href);
|
|
523
|
+
url.hash = id;
|
|
524
|
+
return url;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function selectionHasText(): boolean {
|
|
528
|
+
const selection = window.getSelection();
|
|
529
|
+
return Boolean(selection && selection.type === 'Range' && selection.toString().trim());
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function hydrateHeadingAnchors() {
|
|
533
|
+
document
|
|
534
|
+
.querySelectorAll<HTMLElement>('.vp-doc h2[id], .vp-doc h3[id], .vp-doc h4[id], .vp-doc h5[id], .vp-doc h6[id]')
|
|
535
|
+
.forEach((heading) => {
|
|
536
|
+
if (heading.dataset.docsHeadingCopyBound === 'true') {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const anchor = heading.querySelector<HTMLAnchorElement>('.header-anchor');
|
|
541
|
+
|
|
542
|
+
if (!anchor) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
heading.dataset.docsHeadingCopyBound = 'true';
|
|
547
|
+
heading.classList.add('docs-copyable-heading');
|
|
548
|
+
const content = document.createElement('span');
|
|
549
|
+
content.className = 'anchor-heading__content';
|
|
550
|
+
|
|
551
|
+
while (heading.childNodes.length > 0) {
|
|
552
|
+
const child = heading.firstChild;
|
|
553
|
+
|
|
554
|
+
if (child === anchor) {
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
content.appendChild(child as Node);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const anchorWrap = document.createElement('div');
|
|
562
|
+
anchorWrap.className = 'anchor-heading__icon-wrap';
|
|
563
|
+
anchorWrap.tabIndex = -1;
|
|
564
|
+
anchorWrap.appendChild(anchor);
|
|
565
|
+
heading.prepend(anchorWrap);
|
|
566
|
+
heading.appendChild(content);
|
|
567
|
+
|
|
568
|
+
anchor.replaceChildren(
|
|
569
|
+
createSvgIcon(
|
|
570
|
+
'M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z',
|
|
571
|
+
'docs-heading-anchor__icon',
|
|
572
|
+
{ fill: true, size: 12, viewBox: '0 0 576 512' },
|
|
573
|
+
),
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
heading.addEventListener('click', (event) => {
|
|
577
|
+
if (selectionHasText()) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (event.target instanceof HTMLElement && event.target.closest('a:not(.header-anchor)')) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
586
|
+
const clickedHeadingText = target?.closest('.anchor-heading__content');
|
|
587
|
+
const clickedAnchor = target?.closest('.header-anchor');
|
|
588
|
+
|
|
589
|
+
if (!clickedHeadingText && !clickedAnchor) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
event.preventDefault();
|
|
594
|
+
|
|
595
|
+
const url = getHeadingUrl(heading.id);
|
|
596
|
+
window.history.replaceState(null, '', `${url.pathname}${url.search}${url.hash}`);
|
|
597
|
+
scrollContentToHash(heading.id);
|
|
598
|
+
void copyTextToClipboard(url.toString());
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function hydrateCodeCopyButtons() {
|
|
604
|
+
document
|
|
605
|
+
.querySelectorAll<HTMLButtonElement>('.vp-doc [class*="language-"] > button.copy')
|
|
606
|
+
.forEach((button) => {
|
|
607
|
+
if (button.querySelector('.docs-copy-button__icon')) {
|
|
608
|
+
if (button.dataset.docsCopyBound === 'true') {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
} else {
|
|
612
|
+
const copyIcon = createSvgIcon(
|
|
613
|
+
'M14.25 5.25H7.25C6.14543 5.25 5.25 6.14543 5.25 7.25V14.25C5.25 15.3546 6.14543 16.25 7.25 16.25H14.25C15.3546 16.25 16.25 15.3546 16.25 14.25V7.25C16.25 6.14543 15.3546 5.25 14.25 5.25Z||M2.80103 11.998L1.77203 5.07397C1.61003 3.98097 2.36403 2.96397 3.45603 2.80197L10.38 1.77297C11.313 1.63397 12.19 2.16297 12.528 3.00097',
|
|
614
|
+
'docs-copy-button__icon',
|
|
615
|
+
);
|
|
616
|
+
const copiedIcon = createSvgIcon(
|
|
617
|
+
'M2.75 9.25L6.75 13.25L15.25 4.75',
|
|
618
|
+
'docs-copy-button__icon docs-copy-button__icon--copied',
|
|
619
|
+
{ size: 18, strokeWidth: 2, viewBox: '0 0 18 18' },
|
|
620
|
+
);
|
|
621
|
+
const label = document.createElement('span');
|
|
622
|
+
label.className = 'sr-only';
|
|
623
|
+
label.textContent = button.title || 'Copy code';
|
|
624
|
+
|
|
625
|
+
button.replaceChildren(copyIcon, copiedIcon, label);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
button.dataset.docsCopyBound = 'true';
|
|
629
|
+
button.type = 'button';
|
|
630
|
+
|
|
631
|
+
button.addEventListener('click', async(event) => {
|
|
632
|
+
event.preventDefault();
|
|
633
|
+
event.stopPropagation();
|
|
634
|
+
|
|
635
|
+
const block = button.closest('[class*="language-"]');
|
|
636
|
+
|
|
637
|
+
if (!(block instanceof HTMLElement)) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const text = getCodeBlockText(block);
|
|
642
|
+
|
|
643
|
+
if (!text) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const copied = await copyTextToClipboard(text);
|
|
648
|
+
|
|
649
|
+
if (!copied) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
button.classList.add('copied');
|
|
654
|
+
window.setTimeout(() => {
|
|
655
|
+
button.classList.remove('copied');
|
|
656
|
+
}, 1500);
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function openSearch() {
|
|
662
|
+
openDocsSearch();
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
onMounted(async () => {
|
|
666
|
+
document.addEventListener('pointerdown', onDocumentPointerDown);
|
|
667
|
+
await syncRouteScroll(route.path);
|
|
668
|
+
hydrateCodeCopyButtons();
|
|
669
|
+
hydrateHeadingAnchors();
|
|
670
|
+
navigationItems.value?.addEventListener('scroll', updateSidebarFade, { passive: true });
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
onContentUpdated(async () => {
|
|
674
|
+
await nextTick();
|
|
675
|
+
hydrateCodeCopyButtons();
|
|
676
|
+
hydrateHeadingAnchors();
|
|
677
|
+
scrollContentToHash(getActiveHash(route.path));
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
onBeforeUnmount(() => {
|
|
681
|
+
document.removeEventListener('pointerdown', onDocumentPointerDown);
|
|
682
|
+
navigationItems.value?.removeEventListener('scroll', updateSidebarFade);
|
|
683
|
+
});
|
|
684
|
+
</script>
|
|
685
|
+
|
|
686
|
+
<template>
|
|
687
|
+
<div v-if="frontmatter.layout !== false" class="min-h-screen bg-slate-50 text-slate-900 lg:h-screen lg:overflow-hidden">
|
|
688
|
+
<DocsSearchProvider v-if="hasSearch" />
|
|
689
|
+
<div class="max-lg:contents lg:flex lg:w-full" data-docs-theme="almond" :style="docsThemeStyle">
|
|
690
|
+
<div class="max-lg:contents lg:flex-1 lg:min-w-0 lg:overflow-x-clip">
|
|
691
|
+
<header id="navbar" class="peer fixed top-0 z-30 w-full">
|
|
692
|
+
<div class="relative z-10 mx-auto max-w-[96rem] px-4">
|
|
693
|
+
<div class="relative">
|
|
694
|
+
<div
|
|
695
|
+
class="transition-opacity duration-200"
|
|
696
|
+
:class="isOpen ? 'max-lg:pointer-events-none max-lg:opacity-0' : ''"
|
|
697
|
+
>
|
|
698
|
+
<div class="lg:hidden">
|
|
699
|
+
<div class="flex h-14 items-center justify-between gap-3">
|
|
700
|
+
<a href="/" class="flex min-w-0 items-center gap-3 select-none">
|
|
701
|
+
<img v-if="logoSrc" :src="logoSrc" alt="" class="relative block h-6 w-auto max-w-[156px] shrink-0 object-contain" />
|
|
702
|
+
<div v-if="!logoSrc" class="min-w-0 truncate text-[15px] font-semibold tracking-[-0.01em] text-slate-900">
|
|
703
|
+
{{ siteTitle }}
|
|
704
|
+
</div>
|
|
705
|
+
</a>
|
|
706
|
+
|
|
707
|
+
<div class="flex items-center gap-1.5">
|
|
708
|
+
<button
|
|
709
|
+
v-if="hasSearch"
|
|
710
|
+
type="button"
|
|
711
|
+
class="inline-flex h-9 w-9 items-center justify-center rounded-xl text-slate-500 transition hover:bg-white/80 hover:text-slate-900"
|
|
712
|
+
aria-label="Open search"
|
|
713
|
+
@click="openSearch"
|
|
714
|
+
>
|
|
715
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-[18px] w-[18px]" aria-hidden="true">
|
|
716
|
+
<circle cx="11" cy="11" r="8" />
|
|
717
|
+
<path d="m21 21-4.3-4.3" />
|
|
718
|
+
</svg>
|
|
719
|
+
</button>
|
|
720
|
+
|
|
721
|
+
<a
|
|
722
|
+
v-for="link in socialLinks"
|
|
723
|
+
:key="`mobile-${link.link}`"
|
|
724
|
+
:href="link.link"
|
|
725
|
+
target="_blank"
|
|
726
|
+
rel="noreferrer"
|
|
727
|
+
class="inline-flex h-9 w-9 items-center justify-center rounded-xl text-slate-500 transition hover:bg-white/80 hover:text-slate-900"
|
|
728
|
+
:aria-label="link.icon"
|
|
729
|
+
>
|
|
730
|
+
<svg
|
|
731
|
+
v-if="link.icon === 'github'"
|
|
732
|
+
viewBox="0 0 24 24"
|
|
733
|
+
fill="currentColor"
|
|
734
|
+
class="h-[18px] w-[18px]"
|
|
735
|
+
aria-hidden="true"
|
|
736
|
+
>
|
|
737
|
+
<path d="M12 .5a12 12 0 0 0-3.79 23.39c.6.11.82-.26.82-.58l-.02-2.04c-3.34.73-4.04-1.42-4.04-1.42-.54-1.38-1.33-1.75-1.33-1.75-1.09-.74.08-.73.08-.73 1.2.09 1.84 1.24 1.84 1.24 1.07 1.83 2.8 1.3 3.49 1 .11-.78.42-1.31.76-1.61-2.66-.3-5.47-1.33-5.47-5.9 0-1.3.46-2.36 1.23-3.19-.12-.3-.53-1.52.12-3.17 0 0 1-.32 3.3 1.22a11.5 11.5 0 0 1 6 0c2.3-1.54 3.3-1.22 3.3-1.22.65 1.65.24 2.87.12 3.17.76.83 1.22 1.89 1.22 3.19 0 4.58-2.81 5.59-5.49 5.89.43.37.82 1.1.82 2.22l-.01 3.29c0 .32.22.7.83.58A12 12 0 0 0 12 .5Z" />
|
|
738
|
+
</svg>
|
|
739
|
+
</a>
|
|
740
|
+
</div>
|
|
741
|
+
</div>
|
|
742
|
+
|
|
743
|
+
<div
|
|
744
|
+
v-if="topNavLinks.length"
|
|
745
|
+
ref="topNavRootMobile"
|
|
746
|
+
class="relative border-t border-slate-100 px-1 py-2 lg:hidden"
|
|
747
|
+
>
|
|
748
|
+
<button
|
|
749
|
+
type="button"
|
|
750
|
+
class="flex w-full items-center justify-between gap-2 rounded-lg border border-slate-200/80 bg-white/80 px-3 py-2 text-left text-sm font-medium text-slate-800"
|
|
751
|
+
:aria-expanded="topNavMenuMobileOpen"
|
|
752
|
+
aria-haspopup="listbox"
|
|
753
|
+
aria-label="Documentation section"
|
|
754
|
+
@click.stop="toggleTopNavMenuMobile"
|
|
755
|
+
>
|
|
756
|
+
<span class="min-w-0 truncate">{{ activeTopNavLabel }}</span>
|
|
757
|
+
<svg
|
|
758
|
+
class="h-4 w-4 shrink-0 text-slate-500 transition-transform"
|
|
759
|
+
:class="topNavMenuMobileOpen ? 'rotate-180' : ''"
|
|
760
|
+
viewBox="0 0 20 20"
|
|
761
|
+
fill="none"
|
|
762
|
+
aria-hidden="true"
|
|
763
|
+
>
|
|
764
|
+
<path d="M5 7.5L10 12.5L15 7.5" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
|
|
765
|
+
</svg>
|
|
766
|
+
</button>
|
|
767
|
+
<div
|
|
768
|
+
v-if="topNavMenuMobileOpen"
|
|
769
|
+
class="absolute left-1 right-1 top-full z-[100] mt-1 max-h-[min(60vh,24rem)] overflow-y-auto rounded-xl border border-slate-200/80 bg-white py-1 shadow-lg"
|
|
770
|
+
role="listbox"
|
|
771
|
+
:aria-label="`${activeTopNavLabel} options`"
|
|
772
|
+
>
|
|
773
|
+
<a
|
|
774
|
+
v-for="item in topNavLinks"
|
|
775
|
+
:key="item.link"
|
|
776
|
+
:href="withBase(item.link)"
|
|
777
|
+
role="option"
|
|
778
|
+
class="block truncate px-3 py-2 text-sm transition"
|
|
779
|
+
:class="isTopNavLinkActive(item)
|
|
780
|
+
? 'bg-docs-primary-soft font-medium text-docs-primary-strong'
|
|
781
|
+
: 'text-slate-700 hover:bg-slate-50'"
|
|
782
|
+
:aria-selected="isTopNavLinkActive(item)"
|
|
783
|
+
@click="closeTopNavMenus"
|
|
784
|
+
>
|
|
785
|
+
{{ item.text }}
|
|
786
|
+
</a>
|
|
787
|
+
</div>
|
|
788
|
+
</div>
|
|
789
|
+
|
|
790
|
+
<button
|
|
791
|
+
v-if="hasSidebar"
|
|
792
|
+
type="button"
|
|
793
|
+
class="flex h-14 w-full items-center px-1 text-left cursor-pointer focus:outline-0"
|
|
794
|
+
aria-label="Open navigation menu"
|
|
795
|
+
:aria-expanded="isOpen"
|
|
796
|
+
@click="toggle"
|
|
797
|
+
>
|
|
798
|
+
<div class="text-slate-500 transition hover:text-slate-600">
|
|
799
|
+
<span class="sr-only">Navigation</span>
|
|
800
|
+
<svg class="h-4" fill="currentColor" viewBox="0 0 448 512" aria-hidden="true">
|
|
801
|
+
<path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z" />
|
|
802
|
+
</svg>
|
|
803
|
+
</div>
|
|
804
|
+
|
|
805
|
+
<div class="ml-4 flex min-w-0 items-center space-x-3 overflow-hidden text-sm leading-6 whitespace-nowrap">
|
|
806
|
+
<div v-if="mobileBreadcrumbLead" class="flex shrink-0 items-center space-x-3 text-slate-500">
|
|
807
|
+
<span>{{ mobileBreadcrumbLead }}</span>
|
|
808
|
+
<svg width="3" height="24" viewBox="0 -9 3 24" class="h-5 overflow-visible text-slate-400" aria-hidden="true">
|
|
809
|
+
<path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
|
|
810
|
+
</svg>
|
|
811
|
+
</div>
|
|
812
|
+
<div class="min-w-0 flex-1 truncate font-semibold text-slate-900">
|
|
813
|
+
{{ mobileBreadcrumbCurrent }}
|
|
814
|
+
</div>
|
|
815
|
+
</div>
|
|
816
|
+
</button>
|
|
817
|
+
</div>
|
|
818
|
+
|
|
819
|
+
<div class="relative hidden h-14 min-w-0 flex-1 items-center gap-x-4 lg:flex lg:border-none">
|
|
820
|
+
<div class="flex min-w-0 flex-1 items-center gap-x-4">
|
|
821
|
+
<a href="/" class="flex min-w-0 items-center gap-3 select-none">
|
|
822
|
+
<img v-if="logoSrc" :src="logoSrc" alt="" class="relative block h-6 w-auto max-w-[156px] shrink-0 object-contain" />
|
|
823
|
+
<div v-if="!logoSrc" class="min-w-0 truncate text-[15px] font-semibold tracking-[-0.01em] text-slate-900">
|
|
824
|
+
{{ siteTitle }}
|
|
825
|
+
</div>
|
|
826
|
+
</a>
|
|
827
|
+
|
|
828
|
+
<div
|
|
829
|
+
v-if="topNavLinks.length"
|
|
830
|
+
ref="topNavRootDesktop"
|
|
831
|
+
class="relative hidden min-w-0 shrink lg:block"
|
|
832
|
+
>
|
|
833
|
+
<button
|
|
834
|
+
type="button"
|
|
835
|
+
class="inline-flex max-w-full items-center gap-2 rounded-xl border border-slate-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-slate-800 backdrop-blur transition hover:bg-slate-100/90"
|
|
836
|
+
:aria-expanded="topNavMenuDesktopOpen"
|
|
837
|
+
aria-haspopup="listbox"
|
|
838
|
+
aria-label="Documentation section"
|
|
839
|
+
@click.stop="toggleTopNavMenuDesktop"
|
|
840
|
+
>
|
|
841
|
+
<span class="truncate">{{ activeTopNavLabel }}</span>
|
|
842
|
+
<svg
|
|
843
|
+
class="h-4 w-4 shrink-0 text-slate-500 transition-transform"
|
|
844
|
+
:class="topNavMenuDesktopOpen ? 'rotate-180' : ''"
|
|
845
|
+
viewBox="0 0 20 20"
|
|
846
|
+
fill="none"
|
|
847
|
+
aria-hidden="true"
|
|
848
|
+
>
|
|
849
|
+
<path d="M5 7.5L10 12.5L15 7.5" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
|
|
850
|
+
</svg>
|
|
851
|
+
</button>
|
|
852
|
+
<div
|
|
853
|
+
v-if="topNavMenuDesktopOpen"
|
|
854
|
+
class="absolute left-0 top-full z-[100] mt-1 min-w-[12rem] max-w-[min(100vw-2rem,22rem)] rounded-xl border border-slate-200/80 bg-white py-1 shadow-lg"
|
|
855
|
+
role="listbox"
|
|
856
|
+
:aria-label="`${activeTopNavLabel} options`"
|
|
857
|
+
>
|
|
858
|
+
<a
|
|
859
|
+
v-for="item in topNavLinks"
|
|
860
|
+
:key="item.link"
|
|
861
|
+
:href="withBase(item.link)"
|
|
862
|
+
role="option"
|
|
863
|
+
class="block truncate px-3 py-2 text-sm transition"
|
|
864
|
+
:class="isTopNavLinkActive(item)
|
|
865
|
+
? 'bg-docs-primary-soft font-medium text-docs-primary-strong'
|
|
866
|
+
: 'text-slate-700 hover:bg-slate-50'"
|
|
867
|
+
:aria-selected="isTopNavLinkActive(item)"
|
|
868
|
+
@click="closeTopNavMenus"
|
|
869
|
+
>
|
|
870
|
+
{{ item.text }}
|
|
871
|
+
</a>
|
|
872
|
+
</div>
|
|
873
|
+
</div>
|
|
874
|
+
</div>
|
|
875
|
+
|
|
876
|
+
<div class="flex items-center gap-4">
|
|
877
|
+
<div class="flex items-center gap-2">
|
|
878
|
+
<a
|
|
879
|
+
v-for="link in socialLinks"
|
|
880
|
+
:key="link.link"
|
|
881
|
+
:href="link.link"
|
|
882
|
+
target="_blank"
|
|
883
|
+
rel="noreferrer"
|
|
884
|
+
class="inline-flex h-9 w-9 items-center justify-center rounded-xl text-slate-500 transition hover:bg-white/80 hover:text-slate-900"
|
|
885
|
+
:aria-label="link.icon"
|
|
886
|
+
>
|
|
887
|
+
<svg
|
|
888
|
+
v-if="link.icon === 'github'"
|
|
889
|
+
viewBox="0 0 24 24"
|
|
890
|
+
fill="currentColor"
|
|
891
|
+
class="h-[18px] w-[18px]"
|
|
892
|
+
aria-hidden="true"
|
|
893
|
+
>
|
|
894
|
+
<path d="M12 .5a12 12 0 0 0-3.79 23.39c.6.11.82-.26.82-.58l-.02-2.04c-3.34.73-4.04-1.42-4.04-1.42-.54-1.38-1.33-1.75-1.33-1.75-1.09-.74.08-.73.08-.73 1.2.09 1.84 1.24 1.84 1.24 1.07 1.83 2.8 1.3 3.49 1 .11-.78.42-1.31.76-1.61-2.66-.3-5.47-1.33-5.47-5.9 0-1.3.46-2.36 1.23-3.19-.12-.3-.53-1.52.12-3.17 0 0 1-.32 3.3 1.22a11.5 11.5 0 0 1 6 0c2.3-1.54 3.3-1.22 3.3-1.22.65 1.65.24 2.87.12 3.17.76.83 1.22 1.89 1.22 3.19 0 4.58-2.81 5.59-5.49 5.89.43.37.82 1.1.82 2.22l-.01 3.29c0 .32.22.7.83.58A12 12 0 0 0 12 .5Z" />
|
|
895
|
+
</svg>
|
|
896
|
+
</a>
|
|
897
|
+
</div>
|
|
898
|
+
</div>
|
|
899
|
+
</div>
|
|
900
|
+
</div>
|
|
901
|
+
</div>
|
|
902
|
+
</div>
|
|
903
|
+
</header>
|
|
904
|
+
|
|
905
|
+
<div class="scroll-mt-[var(--scroll-mt)] fixed top-[7rem] w-full pb-2 pt-0 lg:top-[3.5rem]">
|
|
906
|
+
<div
|
|
907
|
+
v-if="hasSidebar"
|
|
908
|
+
class="fixed inset-0 z-40 bg-slate-950/40 backdrop-blur-md transition-opacity duration-300 lg:hidden"
|
|
909
|
+
:class="isOpen ? 'pointer-events-auto opacity-100' : 'pointer-events-none opacity-0'"
|
|
910
|
+
@click="close"
|
|
911
|
+
/>
|
|
912
|
+
|
|
913
|
+
<button
|
|
914
|
+
v-if="hasSidebar"
|
|
915
|
+
type="button"
|
|
916
|
+
class="fixed right-4 top-5 z-[60] inline-flex h-11 w-11 items-center justify-center rounded-full border border-white/70 bg-white/95 text-slate-500 shadow-[0_8px_24px_rgba(15,23,42,0.16)] backdrop-blur transition duration-300 lg:hidden"
|
|
917
|
+
:class="isOpen ? 'pointer-events-auto opacity-100 scale-100' : 'pointer-events-none opacity-0 scale-95'"
|
|
918
|
+
aria-label="Close navigation menu"
|
|
919
|
+
@click="close"
|
|
920
|
+
>
|
|
921
|
+
<svg viewBox="0 0 20 20" fill="none" class="h-5 w-5" aria-hidden="true">
|
|
922
|
+
<path d="M5 5L15 15M15 5L5 15" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
923
|
+
</svg>
|
|
924
|
+
</button>
|
|
925
|
+
|
|
926
|
+
<aside
|
|
927
|
+
v-if="hasSidebar"
|
|
928
|
+
class="fixed inset-y-0 left-0 z-50 w-[min(22rem,calc(100vw-2.5rem))] max-w-full overflow-y-auto overscroll-contain border-r border-slate-200/80 bg-white shadow-[0_28px_90px_rgba(15,23,42,0.22)] transition-transform duration-300 lg:hidden"
|
|
929
|
+
:class="isOpen ? 'translate-x-0' : '-translate-x-[105%]'"
|
|
930
|
+
>
|
|
931
|
+
<DocsMobileMenu
|
|
932
|
+
:logo-src="logoSrc"
|
|
933
|
+
:site-title="siteTitle"
|
|
934
|
+
@navigate="close"
|
|
935
|
+
/>
|
|
936
|
+
</aside>
|
|
937
|
+
|
|
938
|
+
<div
|
|
939
|
+
class="mx-auto grid h-[calc(100dvh-8rem)] min-h-0 w-full max-w-[96rem] rounded-2xl px-2 lg:h-[calc(100dvh-4rem)] lg:grid-cols-[16.5rem_minmax(0,1fr)] lg:gap-x-2 lg:px-4"
|
|
940
|
+
:class="hasSidebar ? '' : 'lg:grid-cols-[minmax(0,1fr)]'"
|
|
941
|
+
>
|
|
942
|
+
<div
|
|
943
|
+
v-if="hasSidebar"
|
|
944
|
+
id="sidebar-content"
|
|
945
|
+
class="hidden min-h-0 lg:flex lg:flex-col"
|
|
946
|
+
>
|
|
947
|
+
<div class="flex h-full min-h-0 flex-col gap-4 text-sm">
|
|
948
|
+
<div class="relative z-20 hidden items-center gap-2.5 mr-4 mt-2 mb-2 lg:flex">
|
|
949
|
+
<button
|
|
950
|
+
v-if="hasSearch"
|
|
951
|
+
type="button"
|
|
952
|
+
class="group/search flex h-9 w-full items-center justify-between gap-2 rounded-lg bg-white pl-3.5 pr-3 text-left text-sm leading-6 text-gray-500 ring-1 ring-gray-400/30 transition-[color,box-shadow] hover:text-gray-800 hover:ring-gray-600/30"
|
|
953
|
+
aria-label="Open search"
|
|
954
|
+
@click="openSearch"
|
|
955
|
+
>
|
|
956
|
+
<div class="flex min-w-0 items-center gap-2">
|
|
957
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4 min-w-4 flex-none text-gray-700" aria-hidden="true">
|
|
958
|
+
<circle cx="11" cy="11" r="8" />
|
|
959
|
+
<path d="m21 21-4.3-4.3" />
|
|
960
|
+
</svg>
|
|
961
|
+
<div class="min-w-0 truncate">Search...</div>
|
|
962
|
+
</div>
|
|
963
|
+
<span class="flex-none text-xs">⌘K</span>
|
|
964
|
+
</button>
|
|
965
|
+
</div>
|
|
966
|
+
|
|
967
|
+
<div
|
|
968
|
+
id="navigation-items"
|
|
969
|
+
ref="navigationItems"
|
|
970
|
+
class="stable-scrollbar-gutter pb-4 min-h-0 flex-1 overflow-y-auto"
|
|
971
|
+
:class="sidebarHasTopFade ? '[mask-image:linear-gradient(transparent,black_32px)] [-webkit-mask-image:linear-gradient(transparent,black_32px)]' : ''"
|
|
972
|
+
>
|
|
973
|
+
<DocsSidebar />
|
|
974
|
+
</div>
|
|
975
|
+
</div>
|
|
976
|
+
</div>
|
|
977
|
+
|
|
978
|
+
<div class="min-w-0 h-full min-h-0">
|
|
979
|
+
<div
|
|
980
|
+
id="docs-scroll-container"
|
|
981
|
+
ref="docsScrollContainer"
|
|
982
|
+
class="stable-scrollbar-gutter h-full overflow-y-auto rounded-xl border border-gray-400/30 bg-white px-8 pt-8 pb-10 lg:px-10 lg:pt-10"
|
|
983
|
+
>
|
|
984
|
+
<div
|
|
985
|
+
class="mx-auto w-full max-w-[88rem] xl:grid xl:grid-cols-[minmax(0,52rem)_16.5rem] xl:justify-center xl:gap-x-12"
|
|
986
|
+
>
|
|
987
|
+
<main id="content-area" class="w-full min-w-0 overflow-x-visible">
|
|
988
|
+
<DocsNotFound v-if="page.isNotFound" />
|
|
989
|
+
<template v-else>
|
|
990
|
+
<div
|
|
991
|
+
v-if="sectionLabel"
|
|
992
|
+
class="eyebrow mb-2.5 h-5 text-sm font-semibold text-docs-primary"
|
|
993
|
+
>
|
|
994
|
+
{{ sectionLabel }}
|
|
995
|
+
</div>
|
|
996
|
+
|
|
997
|
+
<Content class="vp-doc mdx-content relative prose prose-gray [contain:inline-size] isolate" />
|
|
998
|
+
|
|
999
|
+
<div
|
|
1000
|
+
v-if="editLink || formattedLastUpdated || previousPageLink || nextPageLink"
|
|
1001
|
+
class="mt-12 border-t border-slate-200 pt-6"
|
|
1002
|
+
>
|
|
1003
|
+
<div
|
|
1004
|
+
v-if="editLink || formattedLastUpdated"
|
|
1005
|
+
class="flex flex-col gap-3 text-sm text-slate-500 sm:flex-row sm:items-center sm:justify-between"
|
|
1006
|
+
>
|
|
1007
|
+
<a
|
|
1008
|
+
v-if="editLink"
|
|
1009
|
+
:href="editLink.href"
|
|
1010
|
+
target="_blank"
|
|
1011
|
+
rel="noreferrer"
|
|
1012
|
+
class="font-medium text-docs-primary transition hover:text-docs-primary-strong"
|
|
1013
|
+
>
|
|
1014
|
+
{{ editLink.text }}
|
|
1015
|
+
</a>
|
|
1016
|
+
|
|
1017
|
+
<div v-if="formattedLastUpdated">
|
|
1018
|
+
{{ lastUpdatedText }}: {{ formattedLastUpdated }}
|
|
1019
|
+
</div>
|
|
1020
|
+
</div>
|
|
1021
|
+
|
|
1022
|
+
<div
|
|
1023
|
+
v-if="previousPageLink || nextPageLink"
|
|
1024
|
+
class="mt-6 grid gap-3 sm:grid-cols-2"
|
|
1025
|
+
>
|
|
1026
|
+
<a
|
|
1027
|
+
v-if="previousPageLink?.link"
|
|
1028
|
+
:href="withBase(previousPageLink.link)"
|
|
1029
|
+
class="group rounded-xl border border-slate-200 px-4 py-3 text-left transition hover:border-docs-primary-border-strong hover:bg-docs-primary-soft/50"
|
|
1030
|
+
>
|
|
1031
|
+
<div class="text-[10px] font-semibold uppercase tracking-[0.08em] text-slate-400">Previous</div>
|
|
1032
|
+
<div class="mt-1 text-sm font-medium text-slate-900 group-hover:text-docs-primary-strong">
|
|
1033
|
+
{{ previousPageLink.text }}
|
|
1034
|
+
</div>
|
|
1035
|
+
</a>
|
|
1036
|
+
<div v-else class="hidden sm:block" />
|
|
1037
|
+
|
|
1038
|
+
<a
|
|
1039
|
+
v-if="nextPageLink?.link"
|
|
1040
|
+
:href="withBase(nextPageLink.link)"
|
|
1041
|
+
class="group rounded-xl border border-slate-200 px-4 py-3 text-left transition hover:border-docs-primary-border-strong hover:bg-docs-primary-soft/50 sm:text-right"
|
|
1042
|
+
>
|
|
1043
|
+
<div class="text-[10px] font-semibold uppercase tracking-[0.08em] text-slate-400">Next</div>
|
|
1044
|
+
<div class="mt-1 text-sm font-medium text-slate-900 group-hover:text-docs-primary-strong">
|
|
1045
|
+
{{ nextPageLink.text }}
|
|
1046
|
+
</div>
|
|
1047
|
+
</a>
|
|
1048
|
+
</div>
|
|
1049
|
+
</div>
|
|
1050
|
+
</template>
|
|
1051
|
+
</main>
|
|
1052
|
+
|
|
1053
|
+
<aside
|
|
1054
|
+
v-if="showOutline"
|
|
1055
|
+
id="content-side-layout"
|
|
1056
|
+
class="hidden xl:block"
|
|
1057
|
+
>
|
|
1058
|
+
<div class="sticky top-0 pt-1">
|
|
1059
|
+
<div
|
|
1060
|
+
id="table-of-contents-shell"
|
|
1061
|
+
class="max-h-[calc(100dvh-7rem)] w-[16.5rem] overflow-y-auto space-y-2 pb-4 text-sm leading-6 text-slate-600"
|
|
1062
|
+
>
|
|
1063
|
+
<DocsOutline />
|
|
1064
|
+
</div>
|
|
1065
|
+
</div>
|
|
1066
|
+
</aside>
|
|
1067
|
+
</div>
|
|
1068
|
+
</div>
|
|
1069
|
+
</div>
|
|
1070
|
+
</div>
|
|
1071
|
+
</div>
|
|
1072
|
+
</div>
|
|
1073
|
+
</div>
|
|
1074
|
+
</div>
|
|
1075
|
+
|
|
1076
|
+
<Content v-else />
|
|
1077
|
+
</template>
|