@vite-hub/docs 0.0.0 → 0.4.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 (115) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +456 -0
  3. package/dist/agent-copy-xPaWye_g.js +33 -0
  4. package/dist/assistant-pages-BN7hNsSZ.js +37 -0
  5. package/dist/assistant-shared-CWIKRtBv.d.ts +28 -0
  6. package/dist/assistant-shared-WzButktj.js +113 -0
  7. package/dist/assistant-worker.d.ts +11 -0
  8. package/dist/assistant-worker.js +16 -0
  9. package/dist/assistant.d.ts +14 -0
  10. package/dist/assistant.js +19 -0
  11. package/dist/content-CPZGnn3S.js +141 -0
  12. package/dist/draft-BjWmaiLn.js +45 -0
  13. package/dist/error-diagnostics-B_ZOy7kF.js +93 -0
  14. package/dist/files-UY4h1_36.js +38 -0
  15. package/dist/index.d.ts +28 -0
  16. package/dist/index.js +27 -0
  17. package/dist/link-checker-redirects.d.ts +13 -0
  18. package/dist/link-checker-redirects.js +25 -0
  19. package/dist/manifest-CMoxcwPm.d.ts +80 -0
  20. package/dist/manifest-ZdxLrcvt.js +434 -0
  21. package/dist/markdown-DUWnEMPp.js +378 -0
  22. package/dist/navigation.d.ts +283 -0
  23. package/dist/navigation.js +519 -0
  24. package/dist/nuxt-CAGpKl_-.d.ts +241 -0
  25. package/dist/nuxt.d.ts +3 -0
  26. package/dist/nuxt.js +1868 -0
  27. package/dist/page-Dx2JD3y1.d.ts +74 -0
  28. package/dist/page-GPt09oex.js +82 -0
  29. package/dist/primitive-rail.d.ts +110 -0
  30. package/dist/primitive-rail.js +289 -0
  31. package/dist/raw-BChwipz_.js +857 -0
  32. package/dist/redirects-CmR1yu5A.js +74 -0
  33. package/dist/runtime/app/app.vue +11 -0
  34. package/dist/runtime/app/assistant/DocsAssistant.vue +81 -0
  35. package/dist/runtime/app/assistant/DocsAssistantOff.vue +8 -0
  36. package/dist/runtime/app/assistant/DocsAssistantPanel.vue +322 -0
  37. package/dist/runtime/app/components/AppHeader.vue +368 -0
  38. package/dist/runtime/app/components/AppSearch.vue +68 -0
  39. package/dist/runtime/app/components/DocsAppShell.vue +62 -0
  40. package/dist/runtime/app/components/DocsArticle.vue +184 -0
  41. package/dist/runtime/app/components/DocsAsideFooter.vue +94 -0
  42. package/dist/runtime/app/components/DocsAsideLeftBody.vue +584 -0
  43. package/dist/runtime/app/components/DocsAsideLeftTop.vue +132 -0
  44. package/dist/runtime/app/components/DocsBrandMark.vue +52 -0
  45. package/dist/runtime/app/components/DocsCatalogFooter.vue +129 -0
  46. package/dist/runtime/app/components/DocsCodePanel.vue +388 -0
  47. package/dist/runtime/app/components/DocsCodePre.vue +120 -0
  48. package/dist/runtime/app/components/DocsHeaderActions.vue +4 -0
  49. package/dist/runtime/app/components/DocsLanding.vue +83 -0
  50. package/dist/runtime/app/components/DocsMarkdown.vue +64 -0
  51. package/dist/runtime/app/components/DocsPage.vue +149 -0
  52. package/dist/runtime/app/components/DocsPageCredits.vue +41 -0
  53. package/dist/runtime/app/components/DocsPageHeaderLinks.vue +120 -0
  54. package/dist/runtime/app/components/DocsRail.vue +239 -0
  55. package/dist/runtime/app/components/DocsSidebarStrip.vue +81 -0
  56. package/dist/runtime/app/components/DocsSidebars.vue +63 -0
  57. package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +33 -0
  58. package/dist/runtime/app/components/content/AgentOnly.vue +9 -0
  59. package/dist/runtime/app/components/content/CodeTree.vue +203 -0
  60. package/dist/runtime/app/components/content/ComarkHtml.vue +31 -0
  61. package/dist/runtime/app/components/content/Correct.vue +17 -0
  62. package/dist/runtime/app/components/content/Example.vue +260 -0
  63. package/dist/runtime/app/components/content/ExamplePreview.vue +6 -0
  64. package/dist/runtime/app/components/content/Examples.vue +71 -0
  65. package/dist/runtime/app/components/content/Incorrect.vue +17 -0
  66. package/dist/runtime/app/components/content/McpClient.vue +170 -0
  67. package/dist/runtime/app/components/content/McpInstall.vue +238 -0
  68. package/dist/runtime/app/components/content/PageList.vue +206 -0
  69. package/dist/runtime/app/components/content/ProductFeatureItem.vue +43 -0
  70. package/dist/runtime/app/components/content/ProductFeatures.vue +17 -0
  71. package/dist/runtime/app/components/content/TutorialStep.vue +39 -0
  72. package/dist/runtime/app/composables/docs-assistant-problem.ts +59 -0
  73. package/dist/runtime/app/composables/docs-theme.ts +15 -0
  74. package/dist/runtime/app/composables/docs.ts +83 -0
  75. package/dist/runtime/app/composables/headerActions.ts +6 -0
  76. package/dist/runtime/app/composables/icons.ts +14 -0
  77. package/dist/runtime/app/composables/seo.ts +64 -0
  78. package/dist/runtime/app/composables/tutorial.ts +40 -0
  79. package/dist/runtime/app/composables/useDocsAssistant.ts +17 -0
  80. package/dist/runtime/app/error.vue +88 -0
  81. package/dist/runtime/app/layouts/default.vue +7 -0
  82. package/dist/runtime/app/layouts/docs.vue +104 -0
  83. package/dist/runtime/app/middleware/docs-layout.ts +23 -0
  84. package/dist/runtime/app/pages/docs-page.vue +3 -0
  85. package/dist/runtime/app/plugins/comark-css.ts +14 -0
  86. package/dist/runtime/app/plugins/icon-stroke.ts +12 -0
  87. package/dist/runtime/app/plugins/theme-color.ts +18 -0
  88. package/dist/runtime/app/utils/docs-theme.ts +43 -0
  89. package/dist/runtime/app/utils/file-tree.ts +40 -0
  90. package/dist/runtime/server/llms.d.ts +6 -0
  91. package/dist/runtime/server/llms.js +7 -0
  92. package/dist/runtime/server/markdown.d.ts +10 -0
  93. package/dist/runtime/server/markdown.js +11 -0
  94. package/dist/runtime/server/mcp.d.ts +6 -0
  95. package/dist/runtime/server/mcp.js +7 -0
  96. package/dist/runtime/server/page.d.ts +7 -0
  97. package/dist/runtime/server/page.js +27 -0
  98. package/dist/runtime/server/raw.d.ts +10 -0
  99. package/dist/runtime/server/raw.js +23 -0
  100. package/dist/runtime/server/search.d.ts +6 -0
  101. package/dist/runtime/server/search.js +32 -0
  102. package/dist/runtime/server/sitemap.d.ts +6 -0
  103. package/dist/runtime/server/sitemap.js +52 -0
  104. package/dist/runtime/server/trailing-slash.d.ts +10 -0
  105. package/dist/runtime/server/trailing-slash.js +28 -0
  106. package/dist/runtime/theme/design.css +464 -0
  107. package/dist/schema-DwpXW0VZ.js +98 -0
  108. package/dist/server.d.ts +15 -0
  109. package/dist/server.js +5 -0
  110. package/dist/theme-BXyu4uFL.d.ts +32 -0
  111. package/dist/theme-DzC8LtMH.js +237 -0
  112. package/dist/theme.d.ts +2 -0
  113. package/dist/theme.js +2 -0
  114. package/dist/types-BhG6vGfG.d.ts +212 -0
  115. package/package.json +144 -1
@@ -0,0 +1,238 @@
1
+ <script setup lang="ts">
2
+ // `::mcp-install` connects a reader's agent to the docs MCP server. The Client tab lists one `:::mcp-client` per
3
+ // client as a row of logos, and shows the steps of the client the reader picks. The Prompt, MCP URL, and Command tabs
4
+ // come from the site's `mcp` config, so they always name the real server. Raw Markdown keeps every client's steps.
5
+ import { CopyButton } from "@vite-hub/ui"
6
+ import type { VNode } from "vue"
7
+
8
+ const slots = defineSlots<{ default?: () => VNode[] }>()
9
+ const { mcp, site } = useDocsConfig()
10
+
11
+ const tabs = [
12
+ { value: "client", label: "Client", slot: "client" },
13
+ { value: "prompt", label: "Prompt", slot: "prompt" },
14
+ { value: "url", label: "MCP URL", slot: "url" },
15
+ { value: "command", label: "Command", slot: "command" },
16
+ ]
17
+ const tab = ref("client")
18
+
19
+ // Comark wraps children in fragments. A client is any node with a `label` prop.
20
+ function clientNodes(nodes: VNode[]): VNode[] {
21
+ return nodes.flatMap(node => typeof node.type === "symbol" && Array.isArray(node.children)
22
+ ? clientNodes(node.children as VNode[])
23
+ : typeof node.props?.label === "string" ? [node] : [])
24
+ }
25
+ const clients = computed(() => clientNodes(slots.default?.() ?? []).map(node => ({
26
+ node,
27
+ label: String(node.props!.label),
28
+ icon: typeof node.props?.icon === "string" ? node.props.icon : "i-lucide-plug",
29
+ })))
30
+
31
+ const storageKey = "vh-mcp-client"
32
+ const selected = ref("")
33
+ const current = computed(() => clients.value.find(client => client.label === selected.value)?.label ?? clients.value[0]?.label)
34
+ function choose(label: string) {
35
+ selected.value = label
36
+ try { localStorage.setItem(storageKey, label) }
37
+ catch { /* Private mode: the choice lasts for this page. */ }
38
+ }
39
+ onMounted(() => {
40
+ try { selected.value = localStorage.getItem(storageKey) ?? "" }
41
+ catch { /* Storage is off: keep the first client. */ }
42
+ })
43
+
44
+ const prompt = computed(() => mcp
45
+ ? `Add the ${site.name} MCP server to this agent. Name it ${mcp.name} and use Streamable HTTP at ${mcp.url}. Then list its tools to confirm it works.`
46
+ : "")
47
+ const command = computed(() => mcp ? `npx add-mcp ${mcp.url} --name ${mcp.name}` : "")
48
+ </script>
49
+
50
+ <template>
51
+ <div v-if="mcp" class="vh-mcp not-prose">
52
+ <UTabs v-model="tab" :items="tabs" class="vh-mcp-tabs" aria-label="Setup method">
53
+ <template #client>
54
+ <div class="vh-mcp-clients" role="group" aria-label="Choose your client">
55
+ <button
56
+ v-for="client in clients"
57
+ :key="client.label"
58
+ type="button"
59
+ class="vh-mcp-client"
60
+ :aria-pressed="current === client.label"
61
+ @click="choose(client.label)"
62
+ >
63
+ <span class="vh-mcp-client-logo"><UIcon :name="client.icon" aria-hidden="true" /></span>
64
+ <span class="vh-mcp-client-name">{{ client.label }}</span>
65
+ </button>
66
+ </div>
67
+ <div v-for="client in clients" v-show="current === client.label" :key="client.label">
68
+ <component :is="client.node" />
69
+ </div>
70
+ </template>
71
+
72
+ <template #prompt>
73
+ <p class="vh-mcp-hint">Send this to your agent. It adds the server for you.</p>
74
+ <p class="vh-mcp-prompt">{{ prompt }}</p>
75
+ <CopyButton :value="prompt" label="Copy prompt" variant="solid" size="sm" />
76
+ </template>
77
+
78
+ <template #url>
79
+ <p class="vh-mcp-hint">Add a Streamable HTTP MCP server named <code>{{ mcp.name }}</code> with this URL.</p>
80
+ <div class="vh-mcp-field">
81
+ <code>{{ mcp.url }}</code>
82
+ <CopyButton :value="mcp.url" label="Copy" size="sm" variant="outline" />
83
+ </div>
84
+ </template>
85
+
86
+ <template #command>
87
+ <p class="vh-mcp-hint">Run this in your project, then pick the agents to add the server to. Add <code>-g</code> to add it for every project.</p>
88
+ <DocsCodePre :code="command" language="bash" filename="Terminal">{{ command }}</DocsCodePre>
89
+ </template>
90
+ </UTabs>
91
+ </div>
92
+ </template>
93
+
94
+ <style scoped>
95
+ .vh-mcp {
96
+ margin-block: 1.25rem 1.75rem;
97
+ container-type: inline-size;
98
+ }
99
+
100
+ .vh-mcp-tabs {
101
+ margin-bottom: 1rem;
102
+ }
103
+
104
+ .vh-mcp-clients {
105
+ display: flex;
106
+ flex-wrap: wrap;
107
+ gap: 0.375rem;
108
+ margin-bottom: 0.875rem;
109
+ }
110
+
111
+ /* Narrow: a row of chips. Wide: a grid of logo tiles, like a launcher. */
112
+ .vh-mcp-client {
113
+ display: flex;
114
+ align-items: center;
115
+ gap: 0.5rem;
116
+ min-height: 2.75rem;
117
+ padding: 0.25rem 0.75rem 0.25rem 0.25rem;
118
+ border: 1px solid var(--ui-border);
119
+ border-radius: calc(var(--ui-radius) * 2);
120
+ font-size: 0.8125rem;
121
+ line-height: 1rem;
122
+ color: var(--ui-text-muted);
123
+ cursor: pointer;
124
+ transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
125
+ }
126
+
127
+ .vh-mcp-client-logo {
128
+ display: flex;
129
+ flex-shrink: 0;
130
+ align-items: center;
131
+ justify-content: center;
132
+ width: 1.75rem;
133
+ height: 1.75rem;
134
+ border: 1px solid var(--ui-border);
135
+ border-radius: calc(var(--ui-radius) * 1.5);
136
+ background: var(--ui-bg);
137
+ font-size: 1rem;
138
+ }
139
+
140
+ .vh-mcp-client-name {
141
+ overflow: hidden;
142
+ text-overflow: ellipsis;
143
+ white-space: nowrap;
144
+ }
145
+
146
+ @media (hover: hover) {
147
+ .vh-mcp-client:hover {
148
+ background: var(--ui-bg-elevated);
149
+ color: var(--ui-text-highlighted);
150
+ }
151
+ }
152
+
153
+ .vh-mcp-client[aria-pressed="true"] {
154
+ border-color: var(--ui-border-accented);
155
+ background: var(--ui-bg-elevated);
156
+ color: var(--ui-text-highlighted);
157
+ }
158
+
159
+ @container (min-width: 34rem) {
160
+ .vh-mcp-clients {
161
+ display: grid;
162
+ grid-template-columns: repeat(auto-fit, minmax(4.75rem, 1fr));
163
+ }
164
+
165
+ .vh-mcp-client {
166
+ flex-direction: column;
167
+ gap: 0.375rem;
168
+ padding: 0.625rem 0.25rem 0.5rem;
169
+ font-size: 0.75rem;
170
+ }
171
+
172
+ .vh-mcp-client:not([aria-pressed="true"]) {
173
+ border-color: transparent;
174
+ }
175
+
176
+ .vh-mcp-client-logo {
177
+ width: 2rem;
178
+ height: 2rem;
179
+ font-size: 1.125rem;
180
+ }
181
+
182
+ .vh-mcp-client-name {
183
+ width: 100%;
184
+ text-align: center;
185
+ }
186
+ }
187
+
188
+ .vh-mcp-hint {
189
+ margin-bottom: 0.75rem;
190
+ font-size: 0.8125rem;
191
+ line-height: 1.25rem;
192
+ color: var(--ui-text-muted);
193
+ }
194
+
195
+ .vh-mcp-hint code,
196
+ .vh-mcp-field code {
197
+ font-family: var(--font-mono, ui-monospace, monospace);
198
+ font-size: 0.8125rem;
199
+ color: var(--ui-text-highlighted);
200
+ }
201
+
202
+ .vh-mcp-prompt {
203
+ margin-bottom: 0.75rem;
204
+ padding: 1rem;
205
+ border: 1px solid var(--ui-border);
206
+ border-radius: calc(var(--ui-radius) * 2);
207
+ background: var(--ui-bg-elevated);
208
+ font-size: 0.875rem;
209
+ line-height: 1.5rem;
210
+ overflow-wrap: anywhere;
211
+ user-select: text;
212
+ }
213
+
214
+ .vh-mcp-field {
215
+ display: flex;
216
+ align-items: center;
217
+ gap: 0.5rem;
218
+ min-width: 0;
219
+ padding: 0.375rem 0.375rem 0.375rem 1rem;
220
+ border: 1px solid var(--ui-border);
221
+ border-radius: calc(var(--ui-radius) * 2);
222
+ }
223
+
224
+ .vh-mcp-field code {
225
+ flex: 1;
226
+ min-width: 0;
227
+ overflow: hidden;
228
+ text-overflow: ellipsis;
229
+ white-space: nowrap;
230
+ }
231
+
232
+ @media (prefers-reduced-motion: reduce) {
233
+ .vh-mcp-tab,
234
+ .vh-mcp-client {
235
+ transition: none;
236
+ }
237
+ }
238
+ </style>
@@ -0,0 +1,206 @@
1
+ <script setup lang="ts">
2
+ import { docsPanelOf, docsPanelPages } from "#docs/navigation"
3
+
4
+ // `::page-list` lists the pages of a section under their sidebar groups, each with its icon and description, so an
5
+ // Overview can link every page without keeping a list by hand. On a panel Overview it lists the pages of the panel.
6
+ // Its own content is the list agents read in the Markdown copy; the site leaves it out.
7
+ const props = defineProps<{
8
+ /** The section to list, by id. Defaults to the section of the page. */
9
+ section?: string
10
+ /** One sidebar group to list, such as `Runtime errors`. */
11
+ group?: string
12
+ /** Sidebar groups to leave out, comma-separated, such as `Start`. */
13
+ exclude?: string
14
+ /**
15
+ * One line per page without icons, for long lists such as one page per error code. It renders a tenth of the markup
16
+ * of a Markdown table, so a list of a thousand pages stays far below the 2 MB that crawlers read.
17
+ */
18
+ compact?: boolean
19
+ }>()
20
+
21
+ const manifest = useDocsManifest()
22
+ const current = useDocsSection()
23
+ const page = useDocsPage()
24
+ const icons = useDocsIcons()
25
+ const groups = computed(() => {
26
+ const section = props.section ? manifest.sections.find(candidate => candidate.id === props.section) : current.value
27
+ const exclude = new Set((props.exclude ?? "").split(",").map(name => name.trim()).filter(Boolean))
28
+ // Pages in the panel of the current page, or outside every panel: the section sidebar links each panel once.
29
+ const panel = section && !props.section && page.value ? docsPanelOf(section, page.value.page) : null
30
+ const grouped = new Map<string, NonNullable<typeof section>["pages"]>()
31
+ const pages = !section ? [] : panel ? docsPanelPages(section, panel) : section.pages.filter(candidate => candidate.panel || !docsPanelOf(section, candidate))
32
+ for (const candidate of pages) {
33
+ const label = candidate.group?.trim() ?? ""
34
+ if (candidate.navigation === false || candidate.path === page.value?.page.path || exclude.has(label)) continue
35
+ if (props.group !== undefined && label !== props.group) continue
36
+ grouped.set(label, [...(grouped.get(label) ?? []), candidate])
37
+ }
38
+ return [...grouped].map(([label, pages]) => ({ label, pages }))
39
+ })
40
+ </script>
41
+
42
+ <template>
43
+ <div v-if="compact" class="vh-page-list">
44
+ <section v-for="group in groups" :key="group.label">
45
+ <h3 v-if="group.label && group.label !== props.group" class="vh-page-list-group">{{ group.label }}</h3>
46
+ <ul class="vh-page-list-compact">
47
+ <li v-for="item in group.pages" :key="item.path">
48
+ <NuxtLink :to="item.path">{{ item.title }}</NuxtLink>
49
+ <span v-if="item.description">{{ item.description }}</span>
50
+ </li>
51
+ </ul>
52
+ </section>
53
+ </div>
54
+ <div v-else class="vh-page-list">
55
+ <section v-for="group in groups" :key="group.label">
56
+ <h3 v-if="group.label" class="vh-page-list-group">{{ group.label }}</h3>
57
+ <ul>
58
+ <li v-for="item in group.pages" :key="item.path">
59
+ <NuxtLink :to="item.path" class="vh-page-list-link">
60
+ <span class="vh-page-list-icon">
61
+ <UIcon :name="icons.page(item)" class="size-4" aria-hidden="true" />
62
+ </span>
63
+ <span class="vh-page-list-text">
64
+ <span class="vh-page-list-title">{{ item.title }}</span>
65
+ <span v-if="item.description" class="vh-page-list-description">{{ item.description }}</span>
66
+ </span>
67
+ <UIcon name="i-lucide-arrow-right" class="vh-page-list-arrow size-4" aria-hidden="true" />
68
+ </NuxtLink>
69
+ </li>
70
+ </ul>
71
+ </section>
72
+ </div>
73
+ </template>
74
+
75
+ <style scoped>
76
+ /* One track no wider than the page, so a long description truncates instead of widening the list. */
77
+ .vh-page-list {
78
+ display: grid;
79
+ grid-template-columns: minmax(0, 1fr);
80
+ gap: 2rem;
81
+ margin-block: 2rem;
82
+ }
83
+
84
+ .vh-page-list-group {
85
+ margin: 0 0 0.5rem;
86
+ color: var(--ui-text-muted);
87
+ font-size: 0.75rem;
88
+ font-weight: 600;
89
+ letter-spacing: 0.08em;
90
+ text-transform: uppercase;
91
+ }
92
+
93
+ .vh-page-list ul {
94
+ margin: 0;
95
+ padding: 0;
96
+ list-style: none;
97
+ border-block: 1px solid var(--ui-border);
98
+ }
99
+
100
+ .vh-page-list li + li {
101
+ border-top: 1px solid var(--ui-border);
102
+ }
103
+
104
+ /* Plain elements under one class: a list of a thousand rows must not repeat a class on each element. */
105
+ .vh-page-list-compact li {
106
+ display: grid;
107
+ grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
108
+ gap: 0.25rem 1rem;
109
+ padding-block: 0.5rem;
110
+ font-size: 0.875rem;
111
+ line-height: 1.5rem;
112
+ }
113
+
114
+ .vh-page-list-compact a {
115
+ overflow-wrap: anywhere;
116
+ color: var(--ui-text-highlighted);
117
+ font-family: var(--font-mono);
118
+ font-size: 0.8125rem;
119
+ text-decoration: underline;
120
+ text-decoration-color: var(--ui-border);
121
+ text-underline-offset: 0.2em;
122
+ }
123
+
124
+ .vh-page-list-compact span {
125
+ color: var(--ui-text-muted);
126
+ }
127
+
128
+ @media (hover: hover) {
129
+ .vh-page-list-compact a:hover {
130
+ text-decoration-color: currentColor;
131
+ }
132
+ }
133
+
134
+ @media (max-width: 40rem) {
135
+ .vh-page-list-compact li {
136
+ grid-template-columns: minmax(0, 1fr);
137
+ }
138
+ }
139
+
140
+ .vh-page-list-link {
141
+ display: flex;
142
+ align-items: center;
143
+ gap: 0.75rem;
144
+ padding-block: 0.75rem;
145
+ color: inherit;
146
+ text-decoration: none;
147
+ transition: background-color 150ms ease;
148
+ }
149
+
150
+
151
+ .vh-page-list-icon {
152
+ display: grid;
153
+ flex: none;
154
+ place-items: center;
155
+ width: 2rem;
156
+ height: 2rem;
157
+ border: 1px solid var(--ui-border);
158
+ border-radius: var(--ui-radius);
159
+ background: var(--ui-bg-elevated);
160
+ color: var(--ui-text-muted);
161
+ }
162
+
163
+ .vh-page-list-text {
164
+ min-width: 0;
165
+ flex: 1;
166
+ }
167
+
168
+ .vh-page-list-title {
169
+ display: block;
170
+ color: var(--ui-text-highlighted);
171
+ font-size: 0.875rem;
172
+ font-weight: 500;
173
+ }
174
+
175
+ .vh-page-list-description {
176
+ display: block;
177
+ margin-top: 0.125rem;
178
+ overflow: hidden;
179
+ color: var(--ui-text-muted);
180
+ font-size: 0.75rem;
181
+ line-height: 1.25rem;
182
+ text-overflow: ellipsis;
183
+ white-space: nowrap;
184
+ }
185
+
186
+ .vh-page-list-arrow {
187
+ flex: none;
188
+ color: var(--ui-text-dimmed);
189
+ transition: transform 150ms ease, color 150ms ease;
190
+ }
191
+
192
+ @media (hover: hover) {
193
+ .vh-page-list-link:hover {
194
+ background: color-mix(in srgb, var(--ui-bg-elevated) 45%, transparent);
195
+ }
196
+
197
+ .vh-page-list-link:hover .vh-page-list-icon,
198
+ .vh-page-list-link:hover .vh-page-list-arrow {
199
+ color: var(--ui-text-highlighted);
200
+ }
201
+
202
+ .vh-page-list-link:hover .vh-page-list-arrow {
203
+ transform: translateX(2px);
204
+ }
205
+ }
206
+ </style>
@@ -0,0 +1,43 @@
1
+ <script setup lang="ts">
2
+ // A linked feature in the product landing list.
3
+ defineProps<{
4
+ title: string
5
+ /** Icon shown above the title. */
6
+ icon?: string
7
+ /** Docs page that explains the feature in full. */
8
+ to: string
9
+ }>()
10
+ </script>
11
+
12
+ <template>
13
+ <UPageCard :to="to" :icon="icon">
14
+ <!-- Each feature is a heading of the landing page, so readers can jump between them. -->
15
+ <template #title>
16
+ <h2>{{ title }}</h2>
17
+ </template>
18
+ <template #description>
19
+ <div class="vh-feature-description">
20
+ <slot />
21
+ </div>
22
+ </template>
23
+ </UPageCard>
24
+ </template>
25
+
26
+ <style scoped>
27
+ /* The sentence is Markdown, so its paragraph and inline code take the size of the card description. */
28
+ .vh-feature-description :deep(p) {
29
+ margin: 0;
30
+ font-size: inherit;
31
+ line-height: inherit;
32
+ }
33
+
34
+ .vh-feature-description :deep(code) {
35
+ display: inline;
36
+ border: 0;
37
+ border-radius: 0;
38
+ background: none;
39
+ padding: 0;
40
+ color: var(--ui-text-toned);
41
+ font-size: inherit;
42
+ }
43
+ </style>
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ // `::product-features` is the feature list of a product landing page. Its default slot holds
3
+ // `:::product-feature-item` entries: one claim, one sentence, one link. No code: the hero carries the code.
4
+ defineProps<{
5
+ /** Optional heading above the list. */
6
+ title?: string
7
+ }>()
8
+ </script>
9
+
10
+ <template>
11
+ <section class="not-prose py-10">
12
+ <h2 v-if="title" class="mb-6 text-xl font-semibold text-highlighted">{{ title }}</h2>
13
+ <UPageGrid>
14
+ <slot />
15
+ </UPageGrid>
16
+ </section>
17
+ </template>
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ id?: string
4
+ title?: string
5
+ }>()
6
+ </script>
7
+
8
+ <template>
9
+ <section :id="id" class="vh-tutorial-step">
10
+ <slot />
11
+ </section>
12
+ </template>
13
+
14
+ <style scoped>
15
+ .vh-tutorial-step {
16
+ counter-increment: tutorial-step;
17
+ margin-block: 2.5rem;
18
+ scroll-margin-top: calc(var(--ui-header-height) + 2rem);
19
+ }
20
+
21
+ .vh-tutorial-step :deep(h2:first-child) {
22
+ display: flex;
23
+ align-items: baseline;
24
+ gap: 0.75rem;
25
+ }
26
+
27
+ .vh-tutorial-step :deep(h2:first-child)::before {
28
+ content: counter(tutorial-step) ".";
29
+ flex: none;
30
+ color: var(--ui-text-dimmed);
31
+ font-variant-numeric: tabular-nums;
32
+ font-size: 1rem;
33
+ }
34
+
35
+ .vh-tutorial-step :deep(pre) {
36
+ white-space: pre;
37
+ overflow-x: auto;
38
+ }
39
+ </style>
@@ -0,0 +1,59 @@
1
+ /** A failed answer, described for the reader, with the command that fixes it when there is one. */
2
+ export interface DocsAssistantProblem {
3
+ /** Stable code from the server, such as `AGENT_R1016`, or `unknown`. */
4
+ code: string
5
+ title: string
6
+ detail: string
7
+ /** A shell command for the site owner, run from the app folder. */
8
+ command?: string
9
+ }
10
+
11
+ const codePattern = /\b(AGENT_R\d{4}|AGENT_BUDGET_EXCEEDED|RATE_LIMIT_(?:REJECTED|UNAVAILABLE))\b/
12
+
13
+ /**
14
+ * Maps a chat error to what the panel shows. The ChatGPT plan errors name their fix, so the panel shows the exact
15
+ * command instead of a generic failure. `origin` is the site origin that the CLI connects to.
16
+ */
17
+ export function docsAssistantProblem(error: Error | string, origin: string): DocsAssistantProblem {
18
+ const message = errorText(typeof error === "string" ? error : error.message)
19
+ const code = codePattern.exec(message)?.[1] ?? "unknown"
20
+ switch (code) {
21
+ case "AGENT_R1016": {
22
+ const connection = /vitehub connections connect ([\w-]+)/.exec(message)?.[1] ?? "chatgpt"
23
+ return {
24
+ code,
25
+ title: "Connect ChatGPT",
26
+ detail: "The assistant runs on the site owner's ChatGPT plan, and no plan is connected. Sign in once from the app folder, then ask again.",
27
+ command: `pnpm vitehub connections connect ${connection} --url ${origin}`,
28
+ }
29
+ }
30
+ case "AGENT_R1026":
31
+ return {
32
+ code,
33
+ title: "Install Codex",
34
+ detail: "The assistant runs Codex, and the app cannot find it. Install it in the app folder, restart the app, then ask again.",
35
+ command: "pnpm add @openai/codex",
36
+ }
37
+ case "AGENT_R1017":
38
+ return { code, title: "ChatGPT plan limit reached", detail: "The site owner's ChatGPT plan reached its usage limit. Try again after it resets." }
39
+ case "AGENT_R1018":
40
+ return { code, title: "ChatGPT plan not eligible", detail: "The connected ChatGPT account cannot use its plan in apps. The site owner can check the plan at chatgpt.com." }
41
+ case "RATE_LIMIT_REJECTED":
42
+ return { code, title: "Too many questions", detail: "The assistant reached its limit of questions for now. Try again later." }
43
+ default:
44
+ return { code, title: "The assistant could not answer", detail: message || "Try again." }
45
+ }
46
+ }
47
+
48
+ /** A failed chat request carries the response body, such as `{"code":"PROVIDER_UNAVAILABLE","error":"AGENT_R1016: ..."}`. */
49
+ function errorText(message: string): string {
50
+ if (!message.startsWith("{")) return message
51
+ try {
52
+ const body: unknown = JSON.parse(message)
53
+ const text: unknown = body && typeof body === "object" ? Reflect.get(body, "error") : undefined
54
+ return typeof text === "string" ? text : message
55
+ }
56
+ catch {
57
+ return message
58
+ }
59
+ }
@@ -0,0 +1,15 @@
1
+ import theme from "#docs/theme"
2
+
3
+ import { resolveDocsTheme } from "../utils/docs-theme"
4
+
5
+ /**
6
+ * The `ui` prop of a Nuxt UI component in the shell, with the design's classes for the same slots in front. In an app
7
+ * with its own `app.vue`, `<UTheme>` gives the docs components the design, but a component's own `ui` prop replaces a
8
+ * `<UTheme>` slot instead of adding to it. In a docs site the design is in the app config, and this returns `ui` as is.
9
+ * Remove when ViteHub moves to Nuxt UI v5, where `<UTheme>` merges `ui` (https://github.com/nuxt/ui/pull/7050).
10
+ */
11
+ export function withDocsTheme<T extends Record<string, string | undefined>>(component: string, ui: T): T {
12
+ if (!theme.ui[component]) return ui
13
+ const design = resolveDocsTheme(theme, useAppConfig().ui).ui[component] as Record<string, string | undefined>
14
+ return Object.fromEntries(Object.entries(ui).map(([slot, classes]) => [slot, [design[slot], classes].filter(Boolean).join(" ") || undefined])) as T
15
+ }