@vite-hub/docs 0.0.0-stage → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +453 -2
  3. package/dist/agent-copy-BJp_Yf5d.js +33 -0
  4. package/dist/assistant-shared-CdtXowot.js +97 -0
  5. package/dist/assistant-shared-Dll_F_yy.d.ts +27 -0
  6. package/dist/assistant-worker.d.ts +11 -0
  7. package/dist/assistant-worker.js +16 -0
  8. package/dist/assistant.d.ts +14 -0
  9. package/dist/assistant.js +19 -0
  10. package/dist/content-9CINWiRf.js +171 -0
  11. package/dist/draft-DUBx--r9.js +45 -0
  12. package/dist/error-diagnostics-BoOsP6Y4.js +53 -0
  13. package/dist/index.d.ts +28 -0
  14. package/dist/index.js +27 -0
  15. package/dist/link-checker-redirects.d.ts +13 -0
  16. package/dist/link-checker-redirects.js +25 -0
  17. package/dist/manifest-D66AEF8F.js +420 -0
  18. package/dist/manifest-Dzp5-_AJ.d.ts +74 -0
  19. package/dist/markdown-Cn9-4oVG.js +378 -0
  20. package/dist/navigation.d.ts +284 -0
  21. package/dist/navigation.js +520 -0
  22. package/dist/nuxt-B5LrERKc.d.ts +240 -0
  23. package/dist/nuxt.d.ts +3 -0
  24. package/dist/nuxt.js +1485 -0
  25. package/dist/page-BbmSfZO8.js +81 -0
  26. package/dist/page-Dx2JD3y1.d.ts +74 -0
  27. package/dist/primitive-rail.d.ts +110 -0
  28. package/dist/primitive-rail.js +284 -0
  29. package/dist/raw-C03EUJKw.js +851 -0
  30. package/dist/redirects-BrbWFSzW.js +62 -0
  31. package/dist/runtime/app/app.vue +11 -0
  32. package/dist/runtime/app/assistant/DocsAssistant.vue +81 -0
  33. package/dist/runtime/app/assistant/DocsAssistantOff.vue +8 -0
  34. package/dist/runtime/app/assistant/DocsAssistantPanel.vue +322 -0
  35. package/dist/runtime/app/components/AppHeader.vue +368 -0
  36. package/dist/runtime/app/components/AppSearch.vue +68 -0
  37. package/dist/runtime/app/components/DocsAppShell.vue +62 -0
  38. package/dist/runtime/app/components/DocsArticle.vue +184 -0
  39. package/dist/runtime/app/components/DocsAsideFooter.vue +94 -0
  40. package/dist/runtime/app/components/DocsAsideLeftBody.vue +584 -0
  41. package/dist/runtime/app/components/DocsAsideLeftTop.vue +132 -0
  42. package/dist/runtime/app/components/DocsBrandMark.vue +52 -0
  43. package/dist/runtime/app/components/DocsCatalogFooter.vue +129 -0
  44. package/dist/runtime/app/components/DocsCodePanel.vue +388 -0
  45. package/dist/runtime/app/components/DocsCodePre.vue +120 -0
  46. package/dist/runtime/app/components/DocsHeaderActions.vue +4 -0
  47. package/dist/runtime/app/components/DocsLanding.vue +83 -0
  48. package/dist/runtime/app/components/DocsMarkdown.vue +64 -0
  49. package/dist/runtime/app/components/DocsPage.vue +149 -0
  50. package/dist/runtime/app/components/DocsPageCredits.vue +41 -0
  51. package/dist/runtime/app/components/DocsPageHeaderLinks.vue +120 -0
  52. package/dist/runtime/app/components/DocsRail.vue +239 -0
  53. package/dist/runtime/app/components/DocsSidebarStrip.vue +81 -0
  54. package/dist/runtime/app/components/DocsSidebars.vue +63 -0
  55. package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +33 -0
  56. package/dist/runtime/app/components/content/AgentOnly.vue +9 -0
  57. package/dist/runtime/app/components/content/CodeTree.vue +203 -0
  58. package/dist/runtime/app/components/content/ComarkHtml.vue +31 -0
  59. package/dist/runtime/app/components/content/Correct.vue +17 -0
  60. package/dist/runtime/app/components/content/Example.vue +260 -0
  61. package/dist/runtime/app/components/content/ExamplePreview.vue +6 -0
  62. package/dist/runtime/app/components/content/Examples.vue +71 -0
  63. package/dist/runtime/app/components/content/Incorrect.vue +17 -0
  64. package/dist/runtime/app/components/content/PageList.vue +206 -0
  65. package/dist/runtime/app/components/content/ProductFeatureItem.vue +43 -0
  66. package/dist/runtime/app/components/content/ProductFeatures.vue +17 -0
  67. package/dist/runtime/app/components/content/TutorialStep.vue +39 -0
  68. package/dist/runtime/app/composables/docs-assistant-problem.ts +59 -0
  69. package/dist/runtime/app/composables/docs-theme.ts +15 -0
  70. package/dist/runtime/app/composables/docs.ts +83 -0
  71. package/dist/runtime/app/composables/headerActions.ts +6 -0
  72. package/dist/runtime/app/composables/icons.ts +14 -0
  73. package/dist/runtime/app/composables/seo.ts +64 -0
  74. package/dist/runtime/app/composables/tutorial.ts +40 -0
  75. package/dist/runtime/app/composables/useDocsAssistant.ts +17 -0
  76. package/dist/runtime/app/error.vue +88 -0
  77. package/dist/runtime/app/layouts/default.vue +7 -0
  78. package/dist/runtime/app/layouts/docs.vue +104 -0
  79. package/dist/runtime/app/middleware/docs-layout.ts +23 -0
  80. package/dist/runtime/app/pages/docs-page.vue +3 -0
  81. package/dist/runtime/app/plugins/comark-css.ts +14 -0
  82. package/dist/runtime/app/plugins/icon-stroke.ts +12 -0
  83. package/dist/runtime/app/plugins/theme-color.ts +18 -0
  84. package/dist/runtime/app/utils/docs-theme.ts +43 -0
  85. package/dist/runtime/app/utils/file-tree.ts +40 -0
  86. package/dist/runtime/server/llms.d.ts +6 -0
  87. package/dist/runtime/server/llms.js +7 -0
  88. package/dist/runtime/server/markdown.d.ts +10 -0
  89. package/dist/runtime/server/markdown.js +11 -0
  90. package/dist/runtime/server/mcp.d.ts +6 -0
  91. package/dist/runtime/server/mcp.js +7 -0
  92. package/dist/runtime/server/page.d.ts +7 -0
  93. package/dist/runtime/server/page.js +27 -0
  94. package/dist/runtime/server/raw.d.ts +10 -0
  95. package/dist/runtime/server/raw.js +23 -0
  96. package/dist/runtime/server/search.d.ts +6 -0
  97. package/dist/runtime/server/search.js +32 -0
  98. package/dist/runtime/server/sitemap.d.ts +6 -0
  99. package/dist/runtime/server/sitemap.js +52 -0
  100. package/dist/runtime/server/trailing-slash.d.ts +10 -0
  101. package/dist/runtime/server/trailing-slash.js +28 -0
  102. package/dist/runtime/theme/design.css +464 -0
  103. package/dist/schema-DwpXW0VZ.js +98 -0
  104. package/dist/server.d.ts +15 -0
  105. package/dist/server.js +5 -0
  106. package/dist/theme-BXyu4uFL.d.ts +32 -0
  107. package/dist/theme-DzC8LtMH.js +237 -0
  108. package/dist/theme.d.ts +2 -0
  109. package/dist/theme.js +2 -0
  110. package/dist/types-BhG6vGfG.d.ts +212 -0
  111. package/package.json +141 -3
@@ -0,0 +1,239 @@
1
+ <script setup lang="ts">
2
+ import { PrimitiveRail, PrimitiveRailGroup, PrimitiveRailItem, resolvePrimitiveIconName } from "#docs/primitive-rail"
3
+ import { NuxtLink } from "#components"
4
+ import { docsHomePath, docsPanelOf, docsRailEntries, docsRailTarget, docsStartPage, normalizeDocsPath } from "#docs/navigation"
5
+
6
+ import type { ComponentPublicInstance } from "vue"
7
+ import type { DocsAppPage, DocsRailEntry, DocsSection } from "@vite-hub/docs"
8
+
9
+ defineProps<{
10
+ /** Shows every label, with no tooltips. Touch has no hover to expand the rail. */
11
+ labeled?: boolean
12
+ /** Shows the brand at the top, for the sidebar of wide screens, which have no site header beside it. */
13
+ brand?: boolean
14
+ /**
15
+ * Shows a button under the brand that opens or collapses the sidebar, on a page with a collapsible sidebar. Collapsed,
16
+ * the rail is the whole sidebar, so it also shows search and the site links.
17
+ */
18
+ toggle?: "show" | "hide"
19
+ }>()
20
+
21
+ const { categories, railExclude, groups: docsGroups, site, start } = useDocsConfig()
22
+ const { toggle: toggleSidebar, focusMounted } = useDocsSidebarToggle()
23
+ const search = reactive(useContentSearch())
24
+ onMounted(focusMounted)
25
+ const currentSection = useDocsSection()
26
+ const icons = useDocsIcons()
27
+ // One rail group for each catalog category. Sections without a category stay reachable in a last group. The sections
28
+ // of a docs group share one item, which opens the first of them.
29
+ // A section icon from the ViteHub set (`i-vitehub-kv`, or `kv` in the `rail` option) renders inline, so it can move on
30
+ // hover. Any other Iconify icon renders through UIcon.
31
+ const groups = docsRailEntries(useDocsManifest(), { categories, railExclude, groups: docsGroups }).map(entries => entries.map((entry) => {
32
+ const icon = entry.icon ?? icons.rail(entry.sections[0]!)
33
+ return { entry, icon, railIcon: resolvePrimitiveIconName(icon) ?? null }
34
+ }))
35
+ const route = useRoute()
36
+ // Inside a panel, such as the diagnostics of one section, each rail item opens the same panel of its own section.
37
+ const currentPanel = computed(() => {
38
+ const section = currentSection.value
39
+ const page = section?.pages.find(candidate => candidate.path === normalizeDocsPath(route.path))
40
+ return section && page ? docsPanelOf(section, page) : null
41
+ })
42
+ // The item of the start section opens the start link that leads it, such as an Introduction outside every section.
43
+ const startPage = docsStartPage(useDocsManifest(), start)
44
+ function target(entry: DocsRailEntry<DocsAppPage>) {
45
+ const opensStart = startPage && !currentPanel.value && entry.sections.some(section => section.id === start?.section)
46
+ return opensStart ? startPage : docsRailTarget(entry.sections[0]!, currentPanel.value)
47
+ }
48
+ const brandLabel = site.badge ? `${site.name} ${site.badge.label}` : site.name
49
+ const docsHome = docsHomePath(useDocsManifest(), start)
50
+ const currentEntry = computed(() => groups.flat().find(({ entry }) => entry.sections.some(section => section.id === currentSection.value?.id)))
51
+
52
+ // A section that the rail leaves out, such as a shared reference topic, marks the start section.
53
+ function isCurrent(section: DocsSection<DocsAppPage>) {
54
+ const current = currentSection.value
55
+ if (!current) return false
56
+ return section.id === current.id || (!currentEntry.value && section.id === start?.section && !!current.category && railExclude.includes(current.category))
57
+ }
58
+
59
+ function isCurrentEntry(entry: DocsRailEntry<DocsAppPage>) {
60
+ return entry.sections.some(isCurrent)
61
+ }
62
+
63
+ // The sidebar link is the current page, so the rail marks its section with aria-current="true", not "page".
64
+ function ariaCurrent(entry: DocsRailEntry<DocsAppPage>) {
65
+ return isCurrentEntry(entry) ? "true" : undefined
66
+ }
67
+
68
+ // The rail hides its scrollbar. A fade at the clipped edge shows that more items are above or below.
69
+ const rail = useTemplateRef<ComponentPublicInstance>("rail")
70
+ let railBody: HTMLElement | null = null
71
+ let resize: ResizeObserver | undefined
72
+ function updateFade() {
73
+ if (!railBody) return
74
+ const { scrollTop, scrollHeight, clientHeight } = railBody
75
+ railBody.toggleAttribute("data-fade-top", scrollTop > 1)
76
+ railBody.toggleAttribute("data-fade-bottom", scrollTop + clientHeight < scrollHeight - 1)
77
+ }
78
+ onMounted(() => {
79
+ const element: unknown = rail.value?.$el
80
+ railBody = element instanceof HTMLElement ? element.querySelector<HTMLElement>(".vh-primitive-rail__body") : null
81
+ if (!railBody) return
82
+ railBody.addEventListener("scroll", updateFade, { passive: true })
83
+ resize = new ResizeObserver(updateFade)
84
+ resize.observe(railBody)
85
+ updateFade()
86
+ })
87
+ onBeforeUnmount(() => {
88
+ railBody?.removeEventListener("scroll", updateFade)
89
+ resize?.disconnect()
90
+ })
91
+ </script>
92
+
93
+ <template>
94
+ <!-- The expanded rail shows each label, so the tooltips turn off while it is open. -->
95
+ <PrimitiveRail ref="rail" :label="`${site.name} navigation`" class="vh-docs-rail" :class="{ 'vh-docs-rail-labeled': labeled }">
96
+ <!-- Like the header brand on other pages, it opens the docs home. -->
97
+ <template v-if="brand || toggle" #header="{ expanded }">
98
+ <UTooltip
99
+ v-if="brand"
100
+ :text="site.badge?.tooltip || brandLabel"
101
+ :content="{ side: 'right', sideOffset: 6 }"
102
+ :delay-duration="150"
103
+ :disabled="expanded && !site.badge?.tooltip"
104
+ ignore-non-keyboard-focus
105
+ :ui="{ content: 'h-auto max-w-64 whitespace-normal px-3 py-2 text-left leading-5' }"
106
+ >
107
+ <PrimitiveRailItem :as="NuxtLink" :to="docsHome ?? '/'" :label="brandLabel" class="vh-docs-rail-brand">
108
+ <DocsBrandMark v-if="site.logo" />
109
+ <span v-else class="vh-docs-rail-brand-initial">{{ site.name.charAt(0) }}</span>
110
+ <template #label>
111
+ <span class="vh-docs-rail-brand-name">{{ site.name }}</span>
112
+ <span v-if="site.badge" class="vh-docs-rail-brand-badge">{{ site.badge.label }}</span>
113
+ </template>
114
+ </PrimitiveRailItem>
115
+ </UTooltip>
116
+ <!-- The open and collapsed sidebars put this button in the same place, so the pointer can toggle in place. -->
117
+ <UTooltip v-if="toggle" :text="toggle === 'show' ? 'Show navigation' : 'Hide navigation'" :content="{ side: 'right', sideOffset: 6 }" :delay-duration="150" :disabled="expanded" ignore-non-keyboard-focus>
118
+ <PrimitiveRailItem
119
+ :id="docsSidebarToggleIds[toggle]"
120
+ as="button"
121
+ type="button"
122
+ :label="toggle === 'show' ? 'Show navigation' : 'Hide navigation'"
123
+ @click="toggleSidebar(toggle === 'show')"
124
+ >
125
+ <UIcon :name="toggle === 'show' ? 'i-lucide-panel-left-open' : 'i-lucide-panel-left-close'" class="size-4" />
126
+ </PrimitiveRailItem>
127
+ </UTooltip>
128
+ <UTooltip v-if="toggle === 'show'" text="Search docs" :content="{ side: 'right', sideOffset: 6 }" :delay-duration="150" :disabled="expanded">
129
+ <PrimitiveRailItem as="button" type="button" label="Search docs" @click="search.open = true">
130
+ <UIcon name="i-lucide-search" class="size-4" />
131
+ </PrimitiveRailItem>
132
+ </UTooltip>
133
+ </template>
134
+ <template #default="{ expanded }">
135
+ <PrimitiveRailGroup v-for="(items, index) in groups" :key="index">
136
+ <UTooltip
137
+ v-for="{ entry, icon, railIcon } in items"
138
+ :key="entry.sections[0]!.id"
139
+ :text="entry.title"
140
+ :content="{ side: 'right', sideOffset: 6 }"
141
+ :delay-duration="150"
142
+ :disabled="expanded || labeled"
143
+ >
144
+ <PrimitiveRailItem
145
+ v-if="railIcon"
146
+ :as="NuxtLink"
147
+ :to="target(entry)"
148
+ :current="isCurrentEntry(entry)"
149
+ :aria-current="ariaCurrent(entry)"
150
+ :icon="railIcon"
151
+ :label="entry.title"
152
+ />
153
+ <PrimitiveRailItem v-else :as="NuxtLink" :to="target(entry)" :current="isCurrentEntry(entry)" :aria-current="ariaCurrent(entry)" :label="entry.title">
154
+ <UIcon :name="icon" class="size-4" />
155
+ </PrimitiveRailItem>
156
+ </UTooltip>
157
+ </PrimitiveRailGroup>
158
+ </template>
159
+ <template v-if="toggle === 'show'" #footer>
160
+ <DocsAsideFooter stacked />
161
+ </template>
162
+ </PrimitiveRail>
163
+ </template>
164
+
165
+ <style scoped>
166
+ /* The shared rail styles the current item by aria-current="page". The docs rail uses "true", so it repeats that style:
167
+ the soft surface of the old comark-ui rail with a hairline ring. */
168
+ .vh-docs-rail :deep(.vh-primitive-rail__item[aria-current="true"]) {
169
+ background: var(--ui-bg-elevated);
170
+ box-shadow: inset 0 0 0 1px var(--ui-border);
171
+ color: var(--ui-text-highlighted);
172
+ }
173
+
174
+ @media (hover: hover) {
175
+ .vh-docs-rail :deep(.vh-primitive-rail__item[aria-current="true"]:hover) {
176
+ background: var(--ui-bg-elevated);
177
+ }
178
+ }
179
+
180
+ .vh-docs-rail :deep(.vh-primitive-rail__body[data-fade-top]),
181
+ .vh-docs-rail :deep(.vh-primitive-rail__body[data-fade-bottom]) {
182
+ --vh-docs-rail-fade-top: 0px;
183
+ --vh-docs-rail-fade-bottom: 0px;
184
+ /* A mask reads only alpha, so any opaque color works. */
185
+ mask-image: linear-gradient(to bottom, transparent, black var(--vh-docs-rail-fade-top), black calc(100% - var(--vh-docs-rail-fade-bottom)), transparent);
186
+ }
187
+
188
+ .vh-docs-rail :deep(.vh-primitive-rail__body[data-fade-top]) {
189
+ --vh-docs-rail-fade-top: 1.5rem;
190
+ }
191
+
192
+ .vh-docs-rail :deep(.vh-primitive-rail__body[data-fade-bottom]) {
193
+ --vh-docs-rail-fade-bottom: 1.5rem;
194
+ }
195
+
196
+ /* The labeled rail of the mobile menu: a fixed column with every label. Long labels wrap. */
197
+ .vh-docs-rail-labeled.vh-primitive-rail {
198
+ width: 10.5rem;
199
+ }
200
+
201
+ .vh-docs-rail-labeled.vh-primitive-rail :deep(.vh-primitive-rail__surface) {
202
+ width: 100%;
203
+ }
204
+
205
+ .vh-docs-rail-labeled :deep(.vh-primitive-rail__item) {
206
+ height: auto;
207
+ min-height: var(--vh-primitive-rail-item);
208
+ }
209
+
210
+ .vh-docs-rail-labeled :deep(.vh-primitive-rail__icon) {
211
+ height: var(--vh-primitive-rail-item);
212
+ align-self: flex-start;
213
+ }
214
+
215
+ .vh-docs-rail-labeled :deep(.vh-primitive-rail__label) {
216
+ opacity: 1;
217
+ padding-block: 0.25rem;
218
+ white-space: normal;
219
+ overflow-wrap: anywhere;
220
+ }
221
+
222
+ .vh-docs-rail-brand {
223
+ --vh-docs-mark-size: 1.125rem;
224
+ }
225
+
226
+ .vh-docs-rail-brand-initial,
227
+ .vh-docs-rail-brand-name {
228
+ color: var(--ui-text-highlighted);
229
+ font-weight: 650;
230
+ }
231
+
232
+ .vh-docs-rail-brand-badge {
233
+ margin-inline-start: 0.375rem;
234
+ border-bottom: 1px dotted currentcolor;
235
+ color: var(--ui-text-muted);
236
+ font-family: var(--font-mono);
237
+ font-size: 0.625rem;
238
+ }
239
+ </style>
@@ -0,0 +1,81 @@
1
+ <script setup lang="ts">
2
+ import { docsHomePath } from "#docs/navigation"
3
+
4
+ // A collapsed sidebar of a site without the rail: the brand, a button that opens the sidebar, search, and the site
5
+ // links, in one narrow column. The open sidebar has its collapse button in the same place.
6
+ const { site, start } = useDocsConfig()
7
+ const docsHome = docsHomePath(useDocsManifest(), start)
8
+ const brandLabel = site.badge ? `${site.name} ${site.badge.label}` : site.name
9
+ const { toggle, focusMounted } = useDocsSidebarToggle()
10
+ onMounted(focusMounted)
11
+ </script>
12
+
13
+ <template>
14
+ <nav class="vh-docs-strip" :aria-label="`${site.name} navigation`">
15
+ <UTooltip :text="brandLabel" :content="{ side: 'right', sideOffset: 6 }" :delay-duration="150">
16
+ <NuxtLink :to="docsHome ?? '/'" class="vh-docs-strip-brand" data-focus-inset :aria-label="brandLabel">
17
+ <DocsBrandMark v-if="site.logo" />
18
+ <span v-else class="vh-docs-strip-initial">{{ site.name.charAt(0) }}</span>
19
+ </NuxtLink>
20
+ </UTooltip>
21
+ <UTooltip text="Show navigation" :content="{ side: 'right', sideOffset: 6 }" :delay-duration="150" ignore-non-keyboard-focus>
22
+ <button :id="docsSidebarToggleIds.show" type="button" class="vh-docs-strip-button" data-focus-inset aria-label="Show navigation" @click="toggle(true)">
23
+ <UIcon name="i-lucide-panel-left-open" class="size-4" />
24
+ </button>
25
+ </UTooltip>
26
+ <UContentSearchButton
27
+ collapsed
28
+ label="Search docs"
29
+ :tooltip="{ content: { side: 'right', sideOffset: 6 }, delayDuration: 150 }"
30
+ class="vh-docs-strip-button"
31
+ data-focus-inset
32
+ :ui="{ base: 'h-10 w-full justify-center rounded-none border-0 border-b border-default bg-transparent text-dimmed hover:bg-elevated/50 hover:text-highlighted' }"
33
+ />
34
+ <DocsAsideFooter stacked class="mt-auto" />
35
+ </nav>
36
+ </template>
37
+
38
+ <style scoped>
39
+ .vh-docs-strip {
40
+ display: flex;
41
+ width: var(--vh-rail-width);
42
+ min-height: 0;
43
+ flex: 1 1 0;
44
+ flex-direction: column;
45
+ }
46
+
47
+ /* 56px, the height of the brand row of the open sidebar, so the brand stays put when the sidebar opens. */
48
+ .vh-docs-strip-brand {
49
+ --vh-docs-mark-size: 1.25rem;
50
+ display: flex;
51
+ flex: none;
52
+ height: 3.5rem;
53
+ align-items: center;
54
+ justify-content: center;
55
+ border-bottom: 1px solid var(--ui-border);
56
+ color: var(--ui-text-highlighted);
57
+ }
58
+
59
+ .vh-docs-strip-initial {
60
+ font-weight: 650;
61
+ }
62
+
63
+ .vh-docs-strip-button {
64
+ display: flex;
65
+ height: 2.5rem;
66
+ flex: none;
67
+ align-items: center;
68
+ justify-content: center;
69
+ border-bottom: 1px solid var(--ui-border);
70
+ color: var(--ui-text-dimmed);
71
+ transition: color 150ms ease, background-color 150ms ease;
72
+ }
73
+
74
+ @media (hover: hover) {
75
+ .vh-docs-strip-button:hover {
76
+ background: color-mix(in oklab, var(--ui-bg-elevated) 50%, transparent);
77
+ color: var(--ui-text-highlighted);
78
+ }
79
+ }
80
+
81
+ </style>
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ import { docsHasRail } from "#docs/navigation"
3
+
4
+ defineProps<{
5
+ /** Shows the page panel next to the rail. Outside a section the panel lists every product. */
6
+ panel: boolean
7
+ /** Shows the rail labels, for the mobile menu where touch has no hover to expand the rail. */
8
+ labeled?: boolean
9
+ /** Shows the brand, search, and the links row, for wide screens, which have no site header beside the sidebar. */
10
+ head?: boolean
11
+ /**
12
+ * On a page with a collapsible sidebar, shows the button that opens or collapses it. Collapsed, a site with the rail
13
+ * shows the rail alone and a site without it shows a strip. `panel` is then false.
14
+ */
15
+ collapsible?: boolean
16
+ }>()
17
+
18
+ // A small site has no rail. The panel lists every section with its pages.
19
+ const config = useDocsConfig()
20
+ const rail = docsHasRail(useDocsManifest(), config.icons, config.groups, config)
21
+ </script>
22
+
23
+ <template>
24
+ <div class="vh-docs-sidebars" :data-docs-sidebar-head="head && (panel || collapsible) ? '' : undefined">
25
+ <DocsRail v-if="rail" :labeled="labeled" :brand="head" :toggle="collapsible ? (panel ? 'hide' : 'show') : undefined" />
26
+ <DocsSidebarStrip v-else-if="collapsible && !panel" />
27
+ <div v-if="panel" class="vh-docs-panel" :class="{ 'is-single': !rail, 'has-head': head }">
28
+ <DocsAsideLeftTop :brand="head && !rail" :search="head" :title="rail" :collapsible="collapsible && !rail" />
29
+ <DocsAsideLeftBody />
30
+ <DocsAsideFooter v-if="head" />
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <style scoped>
36
+ /* The parent sets the height. The rail and the panel each scroll inside it. Nothing here clips, so the expanded rail can cover the panel. */
37
+ .vh-docs-sidebars {
38
+ display: flex;
39
+ min-height: 0;
40
+ }
41
+
42
+ .vh-docs-panel {
43
+ display: flex;
44
+ width: var(--vh-panel-width);
45
+ min-width: 0;
46
+ min-height: 0;
47
+ flex: 0 1 auto;
48
+ flex-direction: column;
49
+ overflow: hidden;
50
+ }
51
+
52
+ /* Without the rail, the panel takes the whole sidebar width. */
53
+ .vh-docs-panel.is-single {
54
+ width: auto;
55
+ flex: 1 1 auto;
56
+ padding-top: 0.75rem;
57
+ }
58
+
59
+ /* The brand and search open the panel, so the page list needs no space above it. */
60
+ .vh-docs-panel.is-single.has-head {
61
+ padding-top: 0;
62
+ }
63
+ </style>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ // The share image of every docs page, in the docs design: the site, the page title and description, and the section.
3
+ // The build renders it once per page while prerendering, so the Worker carries no renderer.
4
+ withDefaults(defineProps<{
5
+ title?: string
6
+ description?: string
7
+ site?: string
8
+ section?: string
9
+ logo?: string
10
+ host?: string
11
+ }>(), { title: "", description: "", site: "", section: "", logo: "", host: "" })
12
+ </script>
13
+
14
+ <template>
15
+ <div class="w-full h-full flex flex-col justify-between bg-white text-black p-[72px]" style="font-family: Geist">
16
+ <div class="flex items-center gap-4">
17
+ <img v-if="logo" :src="logo" alt="" class="w-12 h-12">
18
+ <span class="text-[36px] font-semibold" style="letter-spacing: -0.02em">{{ site }}</span>
19
+ <span v-if="section" class="text-[36px] text-neutral-400">/</span>
20
+ <span v-if="section" class="text-[36px] text-neutral-500">{{ section }}</span>
21
+ </div>
22
+
23
+ <div class="flex flex-col gap-6">
24
+ <span class="text-[76px] font-semibold" style="line-height: 1.05; letter-spacing: -0.045em; text-wrap: balance">{{ title }}</span>
25
+ <span v-if="description" class="text-[34px] text-neutral-500" style="line-height: 1.35; line-clamp: 2; text-overflow: ellipsis; overflow: hidden">{{ description }}</span>
26
+ </div>
27
+
28
+ <div class="flex items-center justify-between border-t border-neutral-200 pt-8">
29
+ <span class="text-[26px] text-neutral-500" style="font-family: 'Geist Mono'">{{ host }}</span>
30
+ <div class="flex w-[56px] h-[8px] bg-black" />
31
+ </div>
32
+ </div>
33
+ </template>
@@ -0,0 +1,9 @@
1
+ <script lang="ts">
2
+ import { defineComponent } from "vue"
3
+
4
+ // `::agent-only` content is for coding agents. The site renders nothing; `/raw`, llms-full.txt, and MCP keep it.
5
+ export default defineComponent({
6
+ name: "AgentOnly",
7
+ render: () => null,
8
+ })
9
+ </script>
@@ -0,0 +1,203 @@
1
+ <script setup lang="ts">
2
+ // `::code-tree` shows code blocks as a project: file tabs beside the code of the open file. Each child code block names
3
+ // its file with a path, such as ```ts [server/api/kv.ts]```. The tabs list folders first, like an editor, and
4
+ // `default-value` names the file that opens first, else the first block. A wide panel shows the tabs as a column beside
5
+ // the code. A narrow panel, such as a hero beside its copy, shows them as a row above the code, so the code keeps the width.
6
+ import type { VNode } from "vue";
7
+
8
+ const props = defineProps<{
9
+ /** The path of the file that opens first. */
10
+ defaultValue?: string;
11
+ }>();
12
+
13
+ const slots = defineSlots<{ default?: () => VNode[] }>();
14
+
15
+ function flatten(nodes: VNode[]): VNode[] {
16
+ return nodes.flatMap((node) =>
17
+ typeof node.type === "symbol" && Array.isArray(node.children) ? flatten(node.children as VNode[]) : [node],
18
+ );
19
+ }
20
+
21
+ const files = computed(() =>
22
+ flatten(slots.default?.() ?? [])
23
+ .map((node) => ({ node, path: String(node.props?.filename ?? "") }))
24
+ .filter((file) => file.path),
25
+ );
26
+ const selected = ref(files.value.find((file) => file.path === props.defaultValue)?.path ?? files.value[0]?.path ?? "");
27
+
28
+ // The tabs show file names, so two files with the same name also show their folder.
29
+ const items = computed(() => {
30
+ const names = files.value.map((file) => file.path.split("/").at(-1));
31
+ const shared = new Set(names.filter((name, index) => names.indexOf(name) !== index));
32
+ return buildFileTree(files.value.map((file) => file.path)).flatMap((row) => {
33
+ if (row.kind !== "file") return [];
34
+ const parts = row.path.split("/");
35
+ const folder = shared.has(row.name) && parts.length > 1 ? `${parts.at(-2)}/` : "";
36
+ return [{ label: row.name, value: row.path, folder }];
37
+ });
38
+ });
39
+ </script>
40
+
41
+ <template>
42
+ <div class="vh-files-frame">
43
+ <div class="vh-files">
44
+ <!-- Both tab lists render on the server. The container query shows one, so the layout never moves. -->
45
+ <UTabs v-for="orientation in (['horizontal', 'vertical'] as const)" :key="orientation" v-model="selected" :items="items" :content="false" :orientation="orientation" class="vh-files-tabs items-start font-mono" :class="orientation === 'vertical' ? 'is-column' : 'is-row'" aria-label="Files">
46
+ <template #leading="{ item }">
47
+ <!-- The file's language icon, as in Nuxt UI code block headers. The box keeps the names aligned when a
48
+ file has no icon. -->
49
+ <span class="vh-files-icon" aria-hidden="true"><ProseCodeIcon :filename="item.value" /></span>
50
+ </template>
51
+ <template #default="{ item }">
52
+ <span><span v-if="item.folder" class="text-dimmed">{{ item.folder }}</span>{{ item.label }}</span>
53
+ </template>
54
+ </UTabs>
55
+
56
+ <!-- Inactive files stay mounted but hidden, so switching files does not move the page. -->
57
+ <div v-for="file in files" v-show="selected === file.path" :key="file.path" role="tabpanel" class="vh-files-code" :aria-label="file.path">
58
+ <p class="vh-files-path">{{ file.path }}</p>
59
+ <div class="vh-files-body" data-code-header>
60
+ <component :is="file.node" hide-header tabindex="-1" />
61
+ </div>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </template>
66
+
67
+ <style scoped>
68
+ /* The panel width, not the viewport, decides where the tabs go. */
69
+ .vh-files-frame {
70
+ container-type: inline-size;
71
+ }
72
+
73
+ /* One framed panel, like a small editor: the file tabs, then the code under a header with its path. */
74
+ .vh-files {
75
+ display: grid;
76
+ grid-template-columns: minmax(0, 1fr);
77
+ grid-template-rows: auto minmax(0, 1fr);
78
+ overflow: hidden;
79
+ border: 1px solid var(--ui-border);
80
+ border-radius: calc(var(--ui-radius) * 2);
81
+ background: var(--ui-bg);
82
+ }
83
+
84
+ @media (min-width: 40rem) {
85
+ .vh-files {
86
+ height: 26rem;
87
+ }
88
+ }
89
+
90
+ .vh-files-tabs.is-column {
91
+ display: none;
92
+ }
93
+
94
+ /* A row of many files scrolls instead of cutting the names. The padding keeps the list's bottom line in view. */
95
+ .vh-files-tabs.is-row {
96
+ overflow-x: auto;
97
+ padding-bottom: 1px;
98
+ scrollbar-width: none;
99
+ }
100
+
101
+ .vh-files-tabs.is-row :deep([data-slot="list"]) {
102
+ width: max-content;
103
+ min-width: 100%;
104
+ }
105
+
106
+ .vh-files-tabs.is-row :deep([data-slot="trigger"]) {
107
+ flex: none;
108
+ }
109
+
110
+ /* Wide panels: the tab column fits its longest name, so file names never truncate. The code takes the rest. */
111
+ @container (min-width: 44rem) {
112
+ .vh-files {
113
+ grid-template-columns: max-content minmax(0, 1fr);
114
+ grid-template-rows: minmax(0, 1fr);
115
+ }
116
+
117
+ .vh-files-tabs.is-row {
118
+ display: none;
119
+ }
120
+
121
+ .vh-files-tabs.is-column {
122
+ display: flex;
123
+ min-width: 9rem;
124
+ overflow: hidden auto;
125
+ border-right: 1px solid var(--ui-border);
126
+ padding: 0.5rem;
127
+ }
128
+
129
+ .vh-files-code {
130
+ grid-area: 1 / 2;
131
+ }
132
+ }
133
+
134
+ .vh-files-icon {
135
+ display: grid;
136
+ width: 0.875rem;
137
+ height: 0.875rem;
138
+ flex: none;
139
+ place-items: center;
140
+ }
141
+
142
+ .vh-files-icon > * {
143
+ width: 100%;
144
+ height: 100%;
145
+ }
146
+
147
+ .vh-files-code {
148
+ display: flex;
149
+ min-width: 0;
150
+ min-height: 0;
151
+ flex-direction: column;
152
+ }
153
+
154
+ .vh-files-path {
155
+ display: flex;
156
+ min-height: 2.5rem;
157
+ flex: none;
158
+ align-items: center;
159
+ margin: 0;
160
+ border-bottom: 1px solid var(--ui-border);
161
+ padding-inline: 0.75rem;
162
+ color: var(--ui-text-dimmed);
163
+ font-family: var(--font-mono);
164
+ font-size: 0.75rem;
165
+ }
166
+
167
+ .vh-files-body {
168
+ min-height: 0;
169
+ flex: 1;
170
+ overflow: auto;
171
+ overscroll-behavior: contain;
172
+ padding: 0.875rem 0.75rem 1rem;
173
+ }
174
+
175
+ .vh-files-body :deep(pre) {
176
+ margin: 0;
177
+ border: 0;
178
+ border-radius: 0;
179
+ background: transparent;
180
+ padding: 0;
181
+ font-size: 0.75rem;
182
+ line-height: 1.85;
183
+ white-space: pre;
184
+ }
185
+
186
+ .vh-files-body :deep(> div) {
187
+ margin: 0;
188
+ }
189
+
190
+ /* The panel already names the file, so the code block's frame and bar give way to it. `data-code-header` tells
191
+ comark-code that the header is drawn outside the block. */
192
+ .vh-files-body :deep(.ck) {
193
+ border: 0;
194
+ border-radius: 0;
195
+ background: transparent;
196
+ box-shadow: none;
197
+ padding: 0;
198
+ }
199
+
200
+ .vh-files-body :deep(.ck-bar) {
201
+ display: none;
202
+ }
203
+ </style>
@@ -0,0 +1,31 @@
1
+ <script setup lang="ts">
2
+ // A block that has only an HTML renderer (annotate, comments, diff, quiz), drawn on the server by the docs parser.
3
+ // `block` is its tag, so a page's styles can tell a diff from a screenshot without looking inside. A block inside a
4
+ // paragraph is `inline`, and draws in a `span`, since a `div` would end the paragraph. Both tags are written out, since
5
+ // Vue's server renderer drops `v-html` on `<component :is>`.
6
+ // The parser keeps source children for search. This component renders only `html`, so they do not appear twice.
7
+ const props = defineProps<{ html: string, block?: string, blockProps?: Record<string, unknown>, inline?: boolean }>()
8
+ const root = ref<HTMLElement>()
9
+
10
+ // Scripts inserted by v-html are inert. Recreate them after mounting or replacing the HTML; the package runtimes
11
+ // guard repeated starts, including when the server's scripts already ran before hydration.
12
+ // Hydration sets `html` again, so these scripts never carry the nonce a CSP module added to the server's copies. They
13
+ // take the page's: under a CSP the browser empties every nonce attribute and keeps the value only in the property.
14
+ function runScripts() {
15
+ const nonce = document.querySelector<HTMLScriptElement>("script[nonce]")?.nonce
16
+ for (const old of root.value?.querySelectorAll("script") ?? []) {
17
+ const script = document.createElement("script")
18
+ for (const { name, value } of old.attributes) script.setAttribute(name, value)
19
+ if (nonce) script.nonce = nonce
20
+ script.textContent = old.textContent
21
+ old.replaceWith(script)
22
+ }
23
+ }
24
+ onMounted(runScripts)
25
+ watch(() => props.html, runScripts, { flush: "post" })
26
+ </script>
27
+
28
+ <template>
29
+ <span v-if="inline" ref="root" class="comark-html" :data-block="block" v-html="html" />
30
+ <div v-else ref="root" class="comark-html" :data-block="block" v-html="html" />
31
+ </template>
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ // `::correct`: an example titled Correct, such as Markdown that a lint rule accepts. `title` or the `#title` slot renames it.
3
+ import Example from "./Example.vue"
4
+
5
+ defineOptions({ inheritAttrs: false })
6
+ defineProps<{ title?: string }>()
7
+ </script>
8
+
9
+ <template>
10
+ <Example v-bind="$attrs">
11
+ <template #title>
12
+ <UIcon name="i-lucide-circle-check" class="size-4" :style="{ color: 'var(--ui-success)' }" aria-hidden="true" />
13
+ <slot name="title">{{ title ?? "Correct" }}</slot>
14
+ </template>
15
+ <slot />
16
+ </Example>
17
+ </template>