@vite-hub/docs 0.6.0 → 0.7.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.
Files changed (57) hide show
  1. package/README.md +5 -4
  2. package/dist/agent-copy-DTCo8cLy.js +48 -0
  3. package/dist/{content-C_WXjV3y.js → content-Chgcvz1q.js} +2 -2
  4. package/dist/index.d.ts +5 -5
  5. package/dist/{manifest-Bti_WxDZ.js → manifest-CQMreQZ5.js} +3 -3
  6. package/dist/{manifest-DJ2DyNue.d.ts → manifest-DmITPRKL.d.ts} +1 -1
  7. package/dist/{markdown-B97RuMXs.d.ts → markdown-Ul8Z9B5A.d.ts} +1 -1
  8. package/dist/navigation.d.ts +6 -1
  9. package/dist/navigation.js +21 -4
  10. package/dist/{nuxt-CYAIBEHE.d.ts → nuxt-B0kdfz6P.d.ts} +11 -3
  11. package/dist/nuxt.d.ts +1 -1
  12. package/dist/nuxt.js +41 -69
  13. package/dist/{page-B8_70-5D.d.ts → page-Cp7sifcg.d.ts} +2 -2
  14. package/dist/primitive-rail.d.ts +1 -1
  15. package/dist/primitive-rail.js +3 -2
  16. package/dist/{raw-CQukuLuj.js → raw-Dh38kL9g.js} +1 -0
  17. package/dist/runnable.d.ts +2 -2
  18. package/dist/runtime/app/assistant/DocsAssistantPanel.vue +9 -5
  19. package/dist/runtime/app/components/AppHeader.vue +3 -9
  20. package/dist/runtime/app/components/AppSearch.vue +33 -10
  21. package/dist/runtime/app/components/DocsAsideLeftTop.vue +4 -10
  22. package/dist/runtime/app/components/DocsBuiltWith.vue +31 -0
  23. package/dist/runtime/app/components/DocsCatalogFooter.vue +4 -3
  24. package/dist/runtime/app/components/DocsLanding.vue +1 -3
  25. package/dist/runtime/app/components/DocsLearn.vue +9 -8
  26. package/dist/runtime/app/components/DocsLearnCodePre.vue +9 -20
  27. package/dist/runtime/app/components/DocsMarkdown.vue +17 -5
  28. package/dist/runtime/app/components/DocsPage.vue +26 -2
  29. package/dist/runtime/app/components/DocsPageHeaderLinks.vue +1 -3
  30. package/dist/runtime/app/components/DocsPlayground.vue +3 -3
  31. package/dist/runtime/app/components/DocsRail.vue +14 -30
  32. package/dist/runtime/app/components/DocsRailTooltip.vue +18 -0
  33. package/dist/runtime/app/components/DocsSidebarStrip.vue +3 -7
  34. package/dist/runtime/app/components/DocsSidebars.vue +2 -1
  35. package/dist/runtime/app/components/content/CopyPrompt.vue +72 -0
  36. package/dist/runtime/app/components/content/Example.vue +2 -1
  37. package/dist/runtime/app/composables/docs.ts +11 -24
  38. package/dist/runtime/app/layouts/docs.vue +7 -0
  39. package/dist/runtime/app/plugins/vitehub-ui.ts +22 -0
  40. package/dist/runtime/server/llms.js +1 -1
  41. package/dist/runtime/server/markdown.js +2 -2
  42. package/dist/runtime/server/mcp.js +1 -1
  43. package/dist/runtime/server/page.d.ts +1 -1
  44. package/dist/runtime/server/page.js +1 -1
  45. package/dist/runtime/server/raw.js +1 -1
  46. package/dist/runtime/server/search.d.ts +1 -1
  47. package/dist/runtime/server/search.js +3 -3
  48. package/dist/runtime/server/sitemap.js +1 -1
  49. package/dist/runtime/theme/design.css +15 -0
  50. package/dist/server.d.ts +3 -3
  51. package/dist/server.js +2 -2
  52. package/dist/{steps-C3tGwhNK.d.ts → steps-DzSu3r8K.d.ts} +1 -1
  53. package/dist/{theme-CxBzPBZ9.js → theme-DRktv19v.js} +1 -1
  54. package/dist/theme.js +1 -1
  55. package/dist/{types-B6YlHil4.d.ts → types-Dl6yjlwV.d.ts} +2 -0
  56. package/package.json +17 -14
  57. package/dist/agent-copy-CY9_RkHN.js +0 -32
@@ -6,9 +6,7 @@ import { useDocsHeaderActionsTarget } from "../composables/headerActions"
6
6
  const route = useRoute()
7
7
  const { base, github, site, socials, start } = useDocsConfig()
8
8
  const docsHome = docsHomePath(useDocsManifest(), start)
9
- // Docs routes and the start links use the docs shell. There the brand opens the docs home, like a docs site logo,
10
- // and the menu shows the docs sidebar. Elsewhere the brand opens the home page.
11
- // The header is the same on every page: the brand, search in the middle, and the site's links and controls.
9
+ const brandLink = useDocsBrandLink()
12
10
  const shell = useDocsShell()
13
11
  const error = useError()
14
12
  const isDocsRoute = computed(() => shell.value && !error.value)
@@ -16,10 +14,8 @@ const menuOpen = ref(false)
16
14
  const wide = useMediaQuery("(min-width: 64rem)", { ssrWidth: 0 })
17
15
  const actionsTargetId = useDocsHeaderActionsTarget()
18
16
  const actionsTarget = computed(() => wide.value && actionsTargetId.value ? document.getElementById(actionsTargetId.value) : null)
19
- // Nuxt turns a `null` in runtime config into "", so only a number counts.
20
17
  const stars = github && typeof github.stars === "number" ? new Intl.NumberFormat("en", { notation: "compact" }).format(github.stars) : null
21
18
 
22
- // A site without docs pages has no "Docs" link. A start link that "Docs" already opens would repeat it.
23
19
  const navLinks = [
24
20
  ...docsHome ? [{ label: "Docs", to: docsHome }] : [],
25
21
  ...(start?.links ?? []).filter(link => link.to !== base && normalizeDocsPath(link.to) !== docsHome).map(link => ({ label: link.label, to: link.to })),
@@ -30,14 +26,12 @@ const mobileLinks = [
30
26
  ...navLinks,
31
27
  ]
32
28
 
33
- // The docs drawer already lists the docs pages.
34
29
  const docsMobileLinks = mobileLinks.filter(link => !isDocsPath(link.to, base))
35
30
 
36
31
  function isActiveLink(to: string) {
37
32
  return route.path === to || route.path.startsWith(`${to}/`)
38
33
  }
39
34
 
40
- // Touch screens get 44px header icon buttons. Below 360px they are 40px wide, so the brand and four buttons fit a 320px row.
41
35
  const touchIconButton = "pointer-coarse:size-11 max-[22.5rem]:pointer-coarse:w-10 pointer-coarse:justify-center"
42
36
  </script>
43
37
 
@@ -61,7 +55,7 @@ const touchIconButton = "pointer-coarse:size-11 max-[22.5rem]:pointer-coarse:w-1
61
55
  ignore-non-keyboard-focus
62
56
  :ui="{ content: 'h-auto max-w-64 whitespace-normal px-3 py-2 text-left leading-5' }"
63
57
  >
64
- <ULink :to="isDocsRoute && docsHome ? docsHome : '/'" class="vh-brand" :aria-label="site.badge ? `${site.name} ${site.badge.label}` : site.name">
58
+ <ULink v-bind="brandLink" class="vh-brand" :aria-label="site.badge ? `${site.name} ${site.badge.label}` : site.name">
65
59
  <DocsBrandMark class="vh-brand-mark" />
66
60
  <span class="vh-brand-name">
67
61
  <span>{{ site.name }}</span>
@@ -139,7 +133,7 @@ const touchIconButton = "pointer-coarse:size-11 max-[22.5rem]:pointer-coarse:w-1
139
133
  </template>
140
134
 
141
135
  <template #body>
142
- <div v-if="isDocsRoute" class="vh-docs-menu -mx-4 -my-2">
136
+ <div v-if="isDocsRoute" class="vh-docs-menu -mx-4 -my-2" data-motion-press="none">
143
137
  <nav class="flex shrink-0 flex-wrap items-center gap-1 border-b border-default px-2 py-1.5" aria-label="Site">
144
138
  <UButton
145
139
  v-for="link in docsMobileLinks"
@@ -1,9 +1,29 @@
1
- <script setup lang="ts">
1
+ <script lang="ts">
2
2
  import { createDocsSearch, docsAppPath, docsSectionHome } from "#docs/navigation"
3
3
 
4
4
  import type { DocsSearchSection } from "@vite-hub/docs"
5
5
 
6
- // A result shows the page path over its heading. One line, "Page > Section > Heading", cut off the heading on a phone.
6
+ type DocsSearch = ReturnType<typeof createDocsSearch>
7
+
8
+ let loading: Promise<DocsSearch> | undefined
9
+
10
+ function loadDocsSearch(url: string): Promise<DocsSearch> {
11
+ if (!import.meta.dev && loading) return loading
12
+ const request = $fetch<DocsSearchSection[]>(url).then(createDocsSearch)
13
+ if (import.meta.dev) return request
14
+ return loading = request.catch((error: unknown) => {
15
+ loading = undefined
16
+ throw error
17
+ })
18
+ }
19
+
20
+ function savesData(): boolean {
21
+ const connection: { saveData?: boolean } | undefined = Reflect.get(navigator, "connection")
22
+ return connection?.saveData === true
23
+ }
24
+ </script>
25
+
26
+ <script setup lang="ts">
7
27
  const { appBase } = useDocsConfig()
8
28
  const manifest = useDocsManifest()
9
29
  const icons = useDocsIcons()
@@ -15,31 +35,33 @@ const navigation = manifest.sections.map(section => ({
15
35
  }))
16
36
  const links = navigation.map((item, index) => ({ label: item.title, icon: item.icon, to: docsSectionHome(manifest.sections[index]!) }))
17
37
 
18
- // The index loads when the dialog first opens, so pages do not pay for it.
19
38
  const status = ref<"idle" | "loading" | "ready" | "error">("idle")
20
- let rank: ReturnType<typeof createDocsSearch> | undefined
39
+ let rank: DocsSearch | undefined
21
40
  const { open } = useContentSearch()
22
- watch(open, async (value) => {
23
- if (!value || status.value === "loading" || status.value === "ready") return
41
+
42
+ async function load() {
43
+ if (status.value === "loading" || status.value === "ready") return
24
44
  status.value = "loading"
25
45
  try {
26
- const records = await $fetch<DocsSearchSection[]>(docsAppPath("/api/_docs/search.json", appBase))
27
- rank = createDocsSearch(records)
46
+ rank = await loadDocsSearch(docsAppPath("/api/_docs/search.json", appBase))
28
47
  status.value = "ready"
29
48
  }
30
49
  catch {
31
50
  status.value = "error"
32
51
  }
52
+ }
53
+
54
+ watch(open, (value) => {
55
+ if (value) void load()
33
56
  })
57
+ if (!import.meta.dev && !savesData()) onNuxtReady(() => load())
34
58
 
35
59
  async function search(query: string, options?: { limit?: number }) {
36
60
  return rank?.(query, options?.limit ?? 30) ?? []
37
61
  }
38
62
 
39
- // The section list helps before the first key press. After it, the ranked results are the whole list.
40
63
  const searchTerm = ref("")
41
64
 
42
- // Nuxt UI builds the prefix as "Page > Section >".
43
65
  function searchPath(prefix: string) {
44
66
  return prefix.replace(/\s*>$/, "").split(" > ").join(" / ")
45
67
  }
@@ -52,6 +74,7 @@ function searchPath(prefix: string) {
52
74
  :navigation="navigation"
53
75
  :search="search"
54
76
  :search-status="status"
77
+ :search-delay="0"
55
78
  :fuse="{ resultLimit: 30 }"
56
79
  >
57
80
  <template #item-label="{ item }">
@@ -1,22 +1,17 @@
1
1
  <script setup lang="ts">
2
- import { docsHomePath, docsSidebarGroup } from "#docs/navigation"
2
+ import { docsSidebarGroup } from "#docs/navigation"
3
3
 
4
4
  const props = defineProps<{
5
- /** Shows the brand, for a wide-screen sidebar without the rail that carries it. */
6
5
  brand?: boolean
7
- /** Shows search, for a wide-screen sidebar, which has no site header beside it. */
8
6
  search?: boolean
9
- /** Shows the name of what the panel lists, for a panel beside the rail. */
10
7
  title?: boolean
11
- /** Shows a button before search that collapses the sidebar, on a site without the rail, which holds it otherwise. */
12
8
  collapsible?: boolean
13
9
  }>()
14
10
 
15
- const { groups, site, start } = useDocsConfig()
11
+ const { groups, site } = useDocsConfig()
12
+ const brandLink = useDocsBrandLink()
16
13
  const manifest = useDocsManifest()
17
14
  const section = useDocsSection()
18
- const docsHome = docsHomePath(manifest, start)
19
- // The group of the current section, or the section itself.
20
15
  const heading = computed(() => {
21
16
  if (!props.title || !section.value) return null
22
17
  return docsSidebarGroup(manifest, section.value, groups)?.title ?? section.value.title
@@ -26,7 +21,6 @@ onMounted(focusMounted)
26
21
  </script>
27
22
 
28
23
  <template>
29
- <!-- Like the header brand on other pages, it opens the docs home. 40px including the border, as the search row and the banner. -->
30
24
  <UTooltip
31
25
  v-if="brand"
32
26
  :text="site.badge?.tooltip ?? undefined"
@@ -35,7 +29,7 @@ onMounted(focusMounted)
35
29
  ignore-non-keyboard-focus
36
30
  :ui="{ content: 'h-auto max-w-64 whitespace-normal px-3 py-2 text-left leading-5' }"
37
31
  >
38
- <NuxtLink :to="docsHome ?? '/'" class="vh-docs-panel-brand" data-focus-inset :aria-label="site.badge ? `${site.name} ${site.badge.label}` : site.name">
32
+ <NuxtLink v-bind="brandLink" class="vh-docs-panel-brand" data-focus-inset :aria-label="site.badge ? `${site.name} ${site.badge.label}` : site.name">
39
33
  <DocsBrandMark />
40
34
  <span>{{ site.name }}</span>
41
35
  <span v-if="site.badge" class="vh-docs-panel-brand-badge">{{ site.badge.label }}</span>
@@ -0,0 +1,31 @@
1
+ <script setup lang="ts">
2
+ const { builtWith } = useDocsConfig()
3
+ </script>
4
+
5
+ <template>
6
+ <p v-if="builtWith" class="vh-docs-credit">
7
+ Built with <a href="https://vitehub.dev/docs/docs-site" target="_blank" rel="noopener">ViteHub Docs</a>
8
+ </p>
9
+ </template>
10
+
11
+ <style scoped>
12
+ .vh-docs-credit {
13
+ color: var(--ui-text-dimmed);
14
+ font-size: 0.75rem;
15
+ line-height: 1.25rem;
16
+ }
17
+
18
+ .vh-docs-credit a {
19
+ color: var(--ui-text-muted);
20
+ text-decoration: underline;
21
+ text-decoration-color: var(--ui-border-accented);
22
+ text-underline-offset: 3px;
23
+ }
24
+
25
+ @media (hover: hover) {
26
+ .vh-docs-credit a:hover {
27
+ color: var(--ui-text-highlighted);
28
+ text-decoration-color: currentcolor;
29
+ }
30
+ }
31
+ </style>
@@ -1,5 +1,4 @@
1
1
  <script setup lang="ts">
2
- // The end of every docs page: every documented area by category, with the current one marked.
3
2
  import { docsCatalog, docsSectionHome } from "#docs/navigation"
4
3
 
5
4
  import type { DocsAppPage, DocsSection } from "@vite-hub/docs"
@@ -8,7 +7,7 @@ const props = defineProps<{
8
7
  current?: DocsSection<DocsAppPage> | null
9
8
  }>()
10
9
 
11
- const { categories, footer, site } = useDocsConfig()
10
+ const { builtWith, categories, footer, site } = useDocsConfig()
12
11
  const icons = useDocsIcons()
13
12
  const groups = docsCatalog(useDocsManifest(), categories)
14
13
 
@@ -20,7 +19,7 @@ function isCurrent(section: DocsSection<DocsAppPage>) {
20
19
  <template>
21
20
  <!-- The rail and the sidebar already mark the current page, so the catalog marks the current section as the current
22
21
  item of its list. Sections join the catalog through their `category`. A site without categories has no catalog. -->
23
- <footer v-if="groups.length || footer.length" class="vh-product-footer" :aria-label="`Explore ${site.name} documentation`">
22
+ <footer v-if="groups.length || footer.length || builtWith" class="vh-product-footer" :aria-label="`Explore ${site.name} documentation`">
24
23
  <h2 v-if="groups.length" class="vh-product-footer-title">Explore {{ site.name }}</h2>
25
24
 
26
25
  <div v-if="groups.length" class="vh-product-footer-grid">
@@ -45,6 +44,8 @@ function isCurrent(section: DocsSection<DocsAppPage>) {
45
44
  <nav v-if="footer.length" class="vh-product-footer-site" :aria-label="site.name">
46
45
  <NuxtLink v-for="link in footer" :key="link.to" :to="link.to" class="vh-product-footer-link">{{ link.label }}</NuxtLink>
47
46
  </nav>
47
+
48
+ <DocsBuiltWith class="mt-8" />
48
49
  </footer>
49
50
  </template>
50
51
 
@@ -1,9 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { DocsPageResponse } from "@vite-hub/docs"
3
3
 
4
- // A landing is a wide Overview. A section Overview opens with its own hero in the Markdown, so it shows only the page
5
- // actions above the body and ends with the catalog footer. The docs base page is the catalog itself: it keeps the
6
- // page header and has no footer.
7
4
  const props = defineProps<{
8
5
  response: DocsPageResponse
9
6
  header?: boolean
@@ -24,6 +21,7 @@ const page = computed(() => props.response.page)
24
21
  <UPageBody prose class="docs-content docs-catalog-content pb-16">
25
22
  <DocsMarkdown :document="response.document" />
26
23
  <DocsPageCredits v-if="response.credits" :credits="response.credits" class="not-prose mt-10" />
24
+ <DocsBuiltWith class="not-prose mt-8" />
27
25
  </UPageBody>
28
26
  </UPage>
29
27
 
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { Button } from "@ui-sdk/vue/button"
2
3
  import { webContainer, Workspace, type WorkspaceExample, type WorkspaceSlotProps, type WorkspaceStep } from "@vite-hub/ui/workspace"
3
4
  import { fetchSnapshot } from "@vite-hub/web-container"
4
5
  import { docsAppPath } from "#docs/navigation"
@@ -133,7 +134,7 @@ const guideComponents = { pre: DocsLearnCodePre, DocsLearnFile }
133
134
  </script>
134
135
 
135
136
  <template>
136
- <div class="vh-docs-workspace" :data-path="response.page.path">
137
+ <div class="vh-docs-workspace ui-sdk" :data-path="response.page.path">
137
138
  <Workspace
138
139
  v-model:open="open"
139
140
  v-model:selected="selected"
@@ -151,20 +152,20 @@ const guideComponents = { pre: DocsLearnCodePre, DocsLearnFile }
151
152
  <p v-if="tutorial.page !== response.page.path" class="mb-4 text-sm text-muted">
152
153
  <NuxtLink :to="tutorial.page" class="hover:text-highlighted">Read in the docs</NuxtLink>
153
154
  </p>
154
- <UPageBody prose class="docs-content docs-tutorial-content !my-0 !px-0 !pb-0">
155
+ <div class="docs-content docs-tutorial-content">
155
156
  <DocsMarkdown :key="step" :document="{ nodes: guideNodes, toc: [] }" :components="guideComponents" />
156
- </UPageBody>
157
+ </div>
157
158
  </template>
158
159
 
159
160
  <template #bar-actions="{ guard }">
160
- <UButton color="neutral" variant="outline" label="Solve" icon="i-lucide-wand-sparkles" @click="solve(guard)" />
161
+ <Button data-variant="outline" data-size="sm" @click="solve(guard)"><Icon name="i-lucide-wand-sparkles" data-slot="leadingIcon" /><span data-slot="label">Solve</span></Button>
161
162
  </template>
162
163
 
163
164
  <template v-if="pendingStep !== undefined" #banner>
164
165
  <div class="vh-docs-learn-bar" role="status">
165
166
  <span class="min-w-0 flex-1">You changed {{ edited.length === 1 ? "1 file" : `${edited.length} files` }}. Step {{ pendingStep + 1 }} has its own version.</span>
166
- <UButton size="xs" color="neutral" variant="outline" :label="`Load step ${pendingStep + 1}`" @click="loadPending" />
167
- <UButton size="xs" color="neutral" variant="ghost" label="Keep mine" @click="keepMine" />
167
+ <Button data-variant="outline" data-size="xs" @click="loadPending"><span data-slot="label">Load step {{ pendingStep + 1 }}</span></Button>
168
+ <Button data-variant="ghost" data-size="xs" @click="keepMine"><span data-slot="label">Keep mine</span></Button>
168
169
  </div>
169
170
  </template>
170
171
 
@@ -175,9 +176,9 @@ const guideComponents = { pre: DocsLearnCodePre, DocsLearnFile }
175
176
 
176
177
  <!-- Without the workspace, such as on a phone, the page is the whole lesson. -->
177
178
  <template #fallback>
178
- <UPageBody prose class="docs-content docs-tutorial-content !px-0 !pb-0">
179
+ <div class="docs-content docs-tutorial-content mt-8">
179
180
  <DocsMarkdown :document="lessonDocument" />
180
- </UPageBody>
181
+ </div>
181
182
  </template>
182
183
  </Workspace>
183
184
  </div>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { Button } from "@ui-sdk/vue/button"
2
3
  import { parseCurl } from "#docs/runnable"
3
4
  import { docsLearnActionsKey } from "../utils/docs-learn"
4
5
 
@@ -38,27 +39,15 @@ async function run() {
38
39
  <template>
39
40
  <div ref="root" class="vh-docs-learn-code">
40
41
  <DocsCodePre v-bind="props"><slot /></DocsCodePre>
41
- <UButton
42
- v-if="isFile"
43
- class="vh-docs-learn-code-action"
44
- size="xs"
45
- variant="ghost"
46
- color="neutral"
47
- icon="i-lucide-file-code"
48
- label="Show in editor"
49
- @click="actions?.show(filename!)"
50
- />
42
+ <Button v-if="isFile" class="vh-docs-learn-code-action" data-variant="ghost" data-size="xs" @click="actions?.show(filename!)">
43
+ <Icon name="i-lucide-file-code" data-slot="leadingIcon" />
44
+ <span data-slot="label">Show in editor</span>
45
+ </Button>
51
46
  <div v-if="isRequest" class="vh-docs-learn-run">
52
- <UButton
53
- size="xs"
54
- variant="outline"
55
- color="neutral"
56
- icon="i-lucide-play"
57
- :label="pending ? 'Running' : 'Run in workspace'"
58
- :loading="pending"
59
- :disabled="!actions?.running || pending"
60
- @click="run"
61
- />
47
+ <Button data-variant="outline" data-size="xs" :disabled="!actions?.running || pending" :aria-busy="pending || undefined" @click="run">
48
+ <Icon :name="pending ? 'i-lucide-loader-circle' : 'i-lucide-play'" :data-slot="pending ? 'spinner' : 'leadingIcon'" />
49
+ <span data-slot="label">{{ pending ? "Running" : "Run in workspace" }}</span>
50
+ </Button>
62
51
  <span v-if="!actions?.running" class="text-xs text-muted">Available when the dev server runs.</span>
63
52
  </div>
64
53
  <pre v-if="output !== undefined" class="vh-docs-learn-output" aria-live="polite"><code>{{ output }}</code></pre>
@@ -1,7 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { MarkdownDocument } from "@comark/vue/components/MarkdownDocument"
3
+ import { useViteHubUIMotionEnabled } from "@vite-hub/ui"
4
+ import { components as lazyBlocks } from "comark-ui/vue/lazy"
3
5
  import { camelize, capitalize, defineAsyncComponent } from "vue"
4
- import blocks from "#docs/blocks"
5
6
  import customComponents from "#docs/custom-components"
6
7
  import contentComponents from "#docs/components"
7
8
 
@@ -19,6 +20,9 @@ const props = defineProps<{
19
20
  components?: Record<string, Component>
20
21
  }>()
21
22
 
23
+ const blocks: Record<string, Component> = lazyBlocks
24
+ const motionEnabled = useViteHubUIMotionEnabled()
25
+
22
26
  // `::note`, `::tip`, and the other callout components draw comark-ui's GitHub callout, the same as a `> [!NOTE]` quote.
23
27
  const callout = (type: string, title?: string): Component => defineComponent({
24
28
  name: `${type[0]!.toUpperCase()}${type.slice(1)}Callout`,
@@ -38,19 +42,27 @@ const componentKey = (tag: string) => capitalize(camelize(tag))
38
42
  // Comark looks up PascalCase before the raw tag, so all maps must use the same keys for precedence to hold.
39
43
  const byKey = (maps: Record<string, Component>[]) => Object.fromEntries(maps.flatMap(map => Object.entries(map).map(([tag, component]) => [componentKey(tag), component])))
40
44
  const overrides = computed(() => byKey([contentBlocks, customComponents, props.components ?? {}]))
41
- const resolved = computed(() => ({ ...byKey([blocks, callouts]), ...overrides.value }))
45
+ const resolved = computed(() => ({
46
+ ...byKey([blocks, callouts]),
47
+ ...overrides.value,
48
+ ...(motionEnabled ? {} : { ProseMotionRuntime: () => null }),
49
+ }))
42
50
 
43
51
  // HTML is the fallback. An app component still receives the original tag, props, and source children. comark-ui's own
44
52
  // component doesn't: the parser drew the block as HTML because that component can't, as with a chart's marks.
45
- function renderNodes(nodes: ComarkNode[]): ComarkNode[] {
53
+ const unbrokenCodeLength = 24
54
+ const isShortText = (children: ComarkNode[]) => children.length === 1 && typeof children[0] === "string" && children[0].length <= unbrokenCodeLength
55
+
56
+ function renderNodes(nodes: ComarkNode[], inPre = false): ComarkNode[] {
46
57
  return nodes.map((node): ComarkNode => {
47
58
  if (typeof node === "string" || node[0] === null) return node
48
59
  const [tag, attributes, ...children] = node
49
60
  const { block, blockProps } = attributes
50
61
  if (tag === "comark-html" && typeof block === "string" && overrides.value[componentKey(block)]) {
51
- return [block, (blockProps ?? {}) as ElementNode[1], ...renderNodes(children)]
62
+ return [block, (blockProps ?? {}) as ElementNode[1], ...renderNodes(children, inPre)]
52
63
  }
53
- return [tag, attributes, ...renderNodes(children)]
64
+ if (tag === "code" && !inPre && isShortText(children)) return [tag, { ...attributes, "data-nowrap": "" }, ...children]
65
+ return [tag, attributes, ...renderNodes(children, inPre || tag === "pre")]
54
66
  })
55
67
  }
56
68
  const nodes = computed(() => renderNodes(props.document.nodes))
@@ -75,8 +75,11 @@ useDocsSeo({
75
75
 
76
76
  <template>
77
77
  <!-- The layout's UMain is the page's only main landmark. -->
78
- <LazyDocsLearn v-if="workspace?.layout === 'learn'" :key="page.path" :response="response" :data="workspace" />
79
- <LazyDocsPlayground v-else-if="workspace" :key="page.path" :response="response" :data="workspace" />
78
+ <div v-if="workspace" :key="page.path" class="vh-docs-workspace-page">
79
+ <LazyDocsLearn v-if="workspace.layout === 'learn'" :response="response" :data="workspace" />
80
+ <LazyDocsPlayground v-else :response="response" :data="workspace" />
81
+ <DocsBuiltWith class="shrink-0 px-4 py-2" />
82
+ </div>
80
83
 
81
84
  <div v-else-if="isStandalone" class="mx-auto w-full max-w-3xl px-4 pb-24 pt-14 sm:px-6 sm:pt-20 lg:px-8 lg:pt-24" :data-path="page.path">
82
85
  <UPageHeader
@@ -94,11 +97,13 @@ useDocsSeo({
94
97
  <DocsMarkdown :document="response.document" />
95
98
  <DocsPageCredits v-if="response.credits" :credits="response.credits" class="not-prose mt-10" />
96
99
  </UPageBody>
100
+ <DocsBuiltWith class="mt-8" />
97
101
  </div>
98
102
 
99
103
  <div v-else-if="home" :data-path="page.path">
100
104
  <DocsMarkdown :document="home" />
101
105
  <DocsPageCredits v-if="response.credits" :credits="response.credits" class="mx-auto w-full max-w-(--vh-content-width) px-4 sm:px-6" />
106
+ <DocsBuiltWith class="mx-auto w-full max-w-(--vh-content-width) px-4 pb-8 pt-8 sm:px-6" />
102
107
  </div>
103
108
 
104
109
  <div v-else-if="page.layout === 'landing'" class="vh-docs-landing">
@@ -112,6 +117,25 @@ useDocsSeo({
112
117
  </template>
113
118
 
114
119
  <style scoped>
120
+ .vh-docs-workspace-page {
121
+ display: contents;
122
+ }
123
+
124
+ .vh-docs-workspace-page:has(> .vh-docs-credit) {
125
+ display: flex;
126
+ flex-direction: column;
127
+ min-height: 0;
128
+ }
129
+
130
+ .vh-docs-workspace-page > :deep(.vh-docs-workspace) {
131
+ flex: 1 1 0;
132
+ }
133
+
134
+ .vh-docs-workspace-page:has(> .vh-docs-credit) > :deep(.vh-docs-workspace:has(.vh-workspace-gate)) {
135
+ flex: 1 0 auto;
136
+ height: auto;
137
+ }
138
+
115
139
  /* Below 40rem the article and the product landing set the only gutter, so the text keeps the width. */
116
140
  .vh-docs-main,
117
141
  .vh-docs-landing,
@@ -1,5 +1,4 @@
1
1
  <script setup lang="ts">
2
- // Page actions: the Markdown twin of the page, chat tools that read it, and the docs MCP server.
3
2
  import { CopyButton, useCopy } from "@vite-hub/ui"
4
3
  import { docsMarkdownLinks, docsMcpInstallLinks, findDocsPage } from "#docs/navigation"
5
4
 
@@ -19,7 +18,6 @@ function openPendingMenu(event: MouseEvent | KeyboardEvent) {
19
18
  }
20
19
  else if (event.button !== 0 || event.ctrlKey) return
21
20
 
22
- // Keep the first activation while the async menu loads. Updating its open prop also starts hydration before idle.
23
21
  event.preventDefault()
24
22
  event.stopPropagation()
25
23
  menuOpen.value = true
@@ -68,7 +66,7 @@ const items = computed(() => {
68
66
  <template>
69
67
  <!-- `contents` keeps the group a direct flex item of the page header. -->
70
68
  <div v-if="links" class="contents">
71
- <UFieldGroup size="sm" @click.capture="openPendingMenu" @keydown.capture="openPendingMenu">
69
+ <UFieldGroup data-field-group size="sm" @click.capture="openPendingMenu" @keydown.capture="openPendingMenu">
72
70
  <CopyButton
73
71
  :value="pageMarkdown"
74
72
  label="Copy page"
@@ -48,7 +48,7 @@ function exampleHref(id: string) {
48
48
  </script>
49
49
 
50
50
  <template>
51
- <div class="vh-docs-workspace" :data-path="page.path">
51
+ <div class="vh-docs-workspace ui-sdk" :data-path="page.path">
52
52
  <Workspace
53
53
  v-model:open="open"
54
54
  :examples="examples"
@@ -71,9 +71,9 @@ function exampleHref(id: string) {
71
71
 
72
72
  <!-- Without the workspace, such as on a phone, the page shows its own text and the examples. -->
73
73
  <template #fallback>
74
- <UPageBody prose class="docs-content !px-0 !pb-0">
74
+ <div class="docs-content mt-8">
75
75
  <DocsMarkdown :document="response.document" />
76
- </UPageBody>
76
+ </div>
77
77
  <h2 class="mt-10 text-lg font-semibold text-highlighted">Examples</h2>
78
78
  <ul class="vh-docs-playground-list">
79
79
  <li v-for="item in examples" :key="item.id">