@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,83 @@
1
+ import { computed, type ComputedRef } from "vue"
2
+ import { useError, useRoute, useRuntimeConfig } from "#imports"
3
+ import { useDocsSidebarExpanded } from "./tutorial"
4
+ import manifest from "#docs/manifest"
5
+ import { docsSectionForPath, docsSidebarCollapses, findDocsPage, normalizeDocsPath } from "#docs/navigation"
6
+
7
+ import type { DocsAppPage, DocsManifest, DocsPublicConfig, DocsSection } from "@vite-hub/docs"
8
+
9
+ /**
10
+ * Sections and pages of the site, computed from the content folder at build time. Each page has its `DocsAppPage`
11
+ * fields: navigation, title, description, and layout. The page route returns the rest, such as `seo` and `credits`.
12
+ */
13
+ export function useDocsManifest(): DocsManifest<DocsAppPage> {
14
+ return manifest
15
+ }
16
+
17
+ /** The `docs` options of `nuxt.config`, as the app reads them. */
18
+ export function useDocsConfig(): DocsPublicConfig {
19
+ return useRuntimeConfig().public.docs
20
+ }
21
+
22
+ /** Whether a path is one of the site pages that `start.links` lists. They open inside the start section. */
23
+ export function isDocsStartLink(config: DocsPublicConfig, path: string): boolean {
24
+ const normalized = normalizeDocsPath(path)
25
+ return (config.start?.links ?? []).some(link => link.to !== config.base && normalizeDocsPath(link.to) === normalized)
26
+ }
27
+
28
+ /** The docs page of the current route, or `null` on other pages. */
29
+ export function useDocsPage(): ComputedRef<{ page: DocsAppPage, section: DocsSection<DocsAppPage> | null } | null> {
30
+ const route = useRoute()
31
+ return computed(() => findDocsPage(manifest, route.path))
32
+ }
33
+
34
+ /** The section of the current route. A start link page resolves to the start section. */
35
+ export function useDocsSection(): ComputedRef<DocsSection<DocsAppPage> | null> {
36
+ const route = useRoute()
37
+ const config = useDocsConfig()
38
+ return computed(() => {
39
+ const section = docsSectionForPath(manifest, route.path)
40
+ if (section || !config.start || !isDocsStartLink(config, route.path)) return section
41
+ return manifest.sections.find(candidate => candidate.id === config.start?.section) ?? null
42
+ })
43
+ }
44
+
45
+ /**
46
+ * Whether the current route renders in the docs shell, whose sidebar carries the site navigation on wide screens. That
47
+ * is the `docs` layout: docs pages get it from the module's middleware, and an app page sets it itself. Any other
48
+ * page, such as a `home` page or an app page under a base of `/`, keeps the site header.
49
+ */
50
+ export function useDocsShell(): ComputedRef<boolean> {
51
+ const route = useRoute()
52
+ return computed(() => route.meta.layout === "docs")
53
+ }
54
+
55
+ /**
56
+ * How the current route shows the sidebar on wide screens: `open`, `collapsed` to a strip whose button opens it, or
57
+ * `hidden`. A docs page sets it in its frontmatter and an app page in `definePageMeta({ layout: "docs", sidebar })`.
58
+ * Code panel tutorials start collapsed. Once the reader opens a collapsed sidebar, it stays open on every such page.
59
+ */
60
+ export function useDocsSidebar(): ComputedRef<{ state: "open" | "collapsed" | "hidden", collapsible: boolean }> {
61
+ const shell = useDocsShell()
62
+ const found = useDocsPage()
63
+ const route = useRoute()
64
+ const expanded = useDocsSidebarExpanded()
65
+ return computed(() => {
66
+ if (!shell.value || useError().value) return { state: "hidden", collapsible: false }
67
+ const meta = route.meta.sidebar
68
+ const page = found.value?.page
69
+ const setting = meta === false || meta === "collapsed" ? meta : page ? (docsSidebarCollapses(page) ? "collapsed" : page.sidebar) : true
70
+ if (setting === false) return { state: "hidden", collapsible: false }
71
+ if (setting !== "collapsed") return { state: "open", collapsible: false }
72
+ return { state: expanded.value ? "open" : "collapsed", collapsible: true }
73
+ })
74
+ }
75
+
76
+ /**
77
+ * Whether the route shows the sidebar column, open or collapsed. On wide screens that column then carries the brand,
78
+ * search, and the site links, and the site header hides. A page with `sidebar: false` keeps the header.
79
+ */
80
+ export function useDocsSidebarShown(): ComputedRef<boolean> {
81
+ const sidebar = useDocsSidebar()
82
+ return computed(() => sidebar.value.state !== "hidden")
83
+ }
@@ -0,0 +1,6 @@
1
+ import { useState } from "#imports"
2
+
3
+ /** The mounted sidebar footer that can receive the header's single custom action instance. */
4
+ export function useDocsHeaderActionsTarget() {
5
+ return useState<string | null>("docs-header-actions-target", () => null)
6
+ }
@@ -0,0 +1,14 @@
1
+ import { docsPageIcon, docsRailIcon, docsSectionIcon } from "#docs/navigation"
2
+ import { useDocsConfig } from "./docs"
3
+
4
+ import type { DocsAppPage, DocsSection } from "@vite-hub/docs"
5
+
6
+ /** Icons of pages and sections in the rail, the sidebar, and the catalog, after the `icons` options apply. */
7
+ export function useDocsIcons() {
8
+ const { icons } = useDocsConfig()
9
+ return {
10
+ page: (page: Pick<DocsAppPage, "path" | "icon">) => docsPageIcon(icons, page),
11
+ section: (section: Pick<DocsSection<DocsAppPage>, "id" | "icon">) => docsSectionIcon(icons, section),
12
+ rail: (section: Pick<DocsSection<DocsAppPage>, "id" | "icon">) => docsRailIcon(icons, section),
13
+ }
14
+ }
@@ -0,0 +1,64 @@
1
+ import { defineArticle, defineBreadcrumb, defineOgImage, defineWebPage, defineWebSite, useRoute, useSchemaOrg, useSeoMeta } from "#imports"
2
+ import { docsAppPath, normalizeDocsPath } from "#docs/navigation"
3
+
4
+ import { useDocsConfig } from "./docs"
5
+
6
+ export interface DocsSeoInput {
7
+ title: string
8
+ description?: string | null
9
+ /** Section label in the share image and the breadcrumb, such as `KV`. */
10
+ section?: { title: string, path: string } | null
11
+ /** A path in `public/` or a URL for the share image, or `false` for none. Without it the build renders one. */
12
+ image?: string | false
13
+ /** `article` marks the page a TechArticle in Schema.org. */
14
+ type?: "article" | "page"
15
+ }
16
+
17
+ /**
18
+ * Title, description, share image, and Schema.org of a page. Docs pages call it with their frontmatter; an app page,
19
+ * such as a playground, calls it to look the same when shared.
20
+ */
21
+ export function useDocsSeo(input: DocsSeoInput): void {
22
+ const { site, appBase, ogImage } = useDocsConfig()
23
+ const route = useRoute()
24
+ const path = docsAppPath(normalizeDocsPath(route.path), appBase)
25
+ // A section's own Overview names the section already.
26
+ const section = input.section && input.section.path !== path ? input.section : null
27
+ const description = input.description ?? site.description ?? undefined
28
+ useSeoMeta({ title: input.title, ogTitle: input.title, description, ogDescription: description, ogType: input.type === "article" ? "article" : "website" })
29
+
30
+ if (input.image === false) {
31
+ // Null overrides inherited head tags before Unhead removes them from the rendered page.
32
+ // A `summary` card tells share previews and the search check that the page has no image on purpose.
33
+ useSeoMeta({ twitterCard: "summary", ogImage: null, ogImageUrl: null, ogImageSecureUrl: null, ogImageType: null, ogImageWidth: null, ogImageHeight: null, ogImageAlt: null, twitterImage: null, twitterImageAlt: null })
34
+ }
35
+ else if (input.image) {
36
+ const imagePath = input.image.startsWith("/") ? input.image : `/${input.image}`
37
+ const image = /^https?:\/\//.test(input.image) ? input.image : `${site.url}${docsAppPath(imagePath, appBase)}`
38
+ useSeoMeta({ ogImage: image, ogImageUrl: null, ogImageSecureUrl: null, ogImageType: null, ogImageWidth: null, ogImageHeight: null, ogImageAlt: null, twitterImage: image, twitterImageAlt: null })
39
+ }
40
+ else if (ogImage) {
41
+ // SAFETY: `ogImage.component` is an OgImage component; the default ships with this package, and an app names its own.
42
+ defineOgImage(ogImage.component as "DocsPage", {
43
+ title: input.title,
44
+ description: description ?? "",
45
+ site: site.name,
46
+ section: section?.title ?? "",
47
+ // A path, so the prerender reads the file from the build instead of fetching the site before it is deployed.
48
+ logo: site.logo ? site.logo.src : "",
49
+ host: site.url.replace(/^https?:\/\//, ""),
50
+ })
51
+ }
52
+ else {
53
+ useSeoMeta({ twitterCard: "summary" })
54
+ }
55
+
56
+ useSchemaOrg([
57
+ defineWebSite({ name: site.name, description: site.description ?? undefined }),
58
+ defineWebPage({ name: input.title, description }),
59
+ ...input.type === "article" ? [defineArticle({ "@type": "TechArticle", "headline": input.title, description })] : [],
60
+ ...section
61
+ ? [defineBreadcrumb({ itemListElement: [{ name: site.name, item: docsAppPath("/", appBase) }, { name: section.title, item: section.path }, { name: input.title }] })]
62
+ : [],
63
+ ])
64
+ }
@@ -0,0 +1,40 @@
1
+ import { useCookie, useState } from "#imports"
2
+ import { docsTutorialNavigationCookie } from "#docs/navigation"
3
+ import { nextTick } from "vue"
4
+
5
+ // A page with a collapsed sidebar, such as a code panel tutorial, starts with a narrow strip so the content gets the
6
+ // page. Its button opens the sidebar. A cookie keeps the choice, so the server renders the same layout on the next
7
+ // visit and nothing jumps.
8
+ export function useDocsSidebarExpanded() {
9
+ return useCookie<boolean>(docsTutorialNavigationCookie, {
10
+ default: () => false,
11
+ maxAge: 60 * 60 * 24 * 365,
12
+ sameSite: "lax",
13
+ })
14
+ }
15
+
16
+ /** Ids of the buttons that open and collapse the sidebar. Only one of them is on the page at a time. */
17
+ export const docsSidebarToggleIds = { show: "vh-docs-sidebar-show", hide: "vh-docs-sidebar-hide" } as const
18
+
19
+ /**
20
+ * Opens or collapses the sidebar and focuses the opposite control after the DOM updates, whether the component mounts
21
+ * or only its toggle prop changes.
22
+ */
23
+ export function useDocsSidebarToggle() {
24
+ const expanded = useDocsSidebarExpanded()
25
+ const focus = useState<string | null>("vh-docs-sidebar-focus", () => null)
26
+ function focusMounted() {
27
+ const id = focus.value
28
+ focus.value = null
29
+ if (id) document.getElementById(id)?.focus()
30
+ }
31
+ return {
32
+ expanded,
33
+ toggle(open: boolean) {
34
+ focus.value = open ? docsSidebarToggleIds.hide : docsSidebarToggleIds.show
35
+ expanded.value = open
36
+ void nextTick(focusMounted)
37
+ },
38
+ focusMounted,
39
+ }
40
+ }
@@ -0,0 +1,17 @@
1
+ import { computed } from "vue"
2
+
3
+ import { useState } from "#imports"
4
+
5
+ import { useDocsConfig } from "./docs"
6
+
7
+ /** The docs assistant panel state. Any component can open it, for example an "Ask" link in the page header. */
8
+ export function useDocsAssistant() {
9
+ const config = useDocsConfig()
10
+ const open = useState("docs-assistant-open", () => false)
11
+ return {
12
+ /** The Agent name, or `undefined` when `docs.assistant` is off. */
13
+ agent: computed(() => config.assistant ? config.assistant.agent : undefined),
14
+ open,
15
+ toggle: (value = !open.value) => { open.value = value },
16
+ }
17
+ }
@@ -0,0 +1,88 @@
1
+ <script setup lang="ts">
2
+ import { docsAppPath, docsHomePath, docsSectionHome } from "#docs/navigation"
3
+
4
+ import type { NuxtError } from "#app"
5
+
6
+ const props = defineProps<{
7
+ error: NuxtError
8
+ }>()
9
+
10
+ const config = useDocsConfig()
11
+ const manifest = useDocsManifest()
12
+ // Nuxt 5 names the code `status`. An error that the server rendered reaches the client as a plain object, which has no
13
+ // `statusCode` getter.
14
+ const status = computed(() => props.error.status ?? props.error.statusCode)
15
+ const isNotFound = computed(() => status.value === 404)
16
+ const title = computed(() => isNotFound.value ? "Page not found" : "This page failed to load")
17
+ const description = computed(() => isNotFound.value
18
+ ? "The page may have moved or been renamed. Search the docs, or open one of these sections."
19
+ : "Reload the page to try again. If it still fails, search the docs or open one of these sections.")
20
+
21
+ const start = manifest.sections.find(section => section.id === config.start?.section)
22
+ // Each link opens a real page. Without `content/docs/index.md` the docs base itself is a 404, so "Docs" opens the first section.
23
+ const docsHome = docsHomePath(manifest, config.start)
24
+ const sections = [
25
+ ...docsHome ? [{ label: "Docs", to: docsHome }] : [],
26
+ ...start ? [{ label: start.title, to: docsSectionHome(start) }] : [],
27
+ ...(config.start?.links ?? []).filter(link => link.to !== config.base),
28
+ ].filter((link, index, links) => links.findIndex(other => other.to === link.to) === index)
29
+
30
+ // The error page replaces the app shell, so it mounts the search dialog that the header button and Ctrl K open.
31
+ const { open: openSearch } = useContentSearch()
32
+
33
+ useSeoMeta({
34
+ title,
35
+ description,
36
+ robots: "noindex, nofollow",
37
+ })
38
+ </script>
39
+
40
+ <template>
41
+ <UApp>
42
+ <AppHeader />
43
+
44
+ <main class="mx-auto flex min-h-[calc(100svh-var(--ui-header-height))] w-full max-w-3xl items-center px-4 py-16 sm:px-6 lg:px-8">
45
+ <section class="w-full border-y border-default py-12 sm:py-16">
46
+ <p class="font-mono text-sm text-muted">
47
+ HTTP {{ status }}
48
+ </p>
49
+ <h1 class="mt-4 max-w-2xl text-balance text-4xl font-semibold tracking-[-0.04em] text-highlighted sm:text-5xl">
50
+ {{ title }}
51
+ </h1>
52
+ <p class="mt-6 max-w-2xl text-pretty text-lg/8 text-muted">
53
+ {{ description }}
54
+ </p>
55
+
56
+ <UButton
57
+ class="mt-8"
58
+ icon="i-lucide-search"
59
+ label="Search the docs"
60
+ variant="outline"
61
+ @click="openSearch = true"
62
+ />
63
+
64
+ <nav class="mt-8 flex flex-wrap gap-x-6 gap-y-3" aria-label="Sections">
65
+ <NuxtLink
66
+ v-for="section in sections"
67
+ :key="section.to"
68
+ class="font-medium text-highlighted underline underline-offset-4"
69
+ :to="section.to"
70
+ >
71
+ {{ section.label }}
72
+ </NuxtLink>
73
+ </nav>
74
+
75
+ <p class="mt-10 text-sm text-muted">
76
+ For coding agents:
77
+ <NuxtLink class="underline underline-offset-4 hover:text-highlighted" :to="docsAppPath('/llms.txt', config.appBase)" external>llms.txt</NuxtLink>
78
+ and the
79
+ <NuxtLink class="underline underline-offset-4 hover:text-highlighted" :to="docsAppPath('/sitemap.xml', config.appBase)" external>Sitemap</NuxtLink>.
80
+ </p>
81
+ </section>
82
+ </main>
83
+
84
+ <ClientOnly>
85
+ <AppSearch />
86
+ </ClientOnly>
87
+ </UApp>
88
+ </template>
@@ -0,0 +1,7 @@
1
+ <template>
2
+ <DocsAppShell layout>
3
+ <UMain>
4
+ <slot />
5
+ </UMain>
6
+ </DocsAppShell>
7
+ </template>
@@ -0,0 +1,104 @@
1
+ <script setup lang="ts">
2
+ const { banner } = useDocsConfig()
3
+ const found = useDocsPage()
4
+ // A tutorial with a code panel uses the whole page column, half for prose and half for files.
5
+ const hasCodePanel = computed(() => found.value?.page.codePanel === true)
6
+ // Pages show the sidebar unless they set `sidebar: false`. A page with `sidebar: "collapsed"`, and a code panel tutorial,
7
+ // shows a narrow strip until the reader opens the sidebar.
8
+ const sidebar = useDocsSidebar()
9
+
10
+ // The sidebar sits on the left edge of the viewport on every docs page. The page content centers in the remaining space.
11
+ const docsShellUi = {
12
+ root: "lg:!flex lg:!flex-row lg:!items-start lg:!gap-0",
13
+ left: "lg:!w-(--vh-sidebar-width) lg:shrink-0",
14
+ center: "lg:!flex-1 lg:!min-w-0",
15
+ }
16
+ </script>
17
+
18
+ <template>
19
+ <DocsAppShell layout>
20
+ <!-- On wide screens the sidebar carries the brand, search, and the site links, so the site header hides beside it. -->
21
+ <UMain class="vh-docs-shell" :class="{ 'is-tutorial': hasCodePanel, 'has-sidebar': sidebar.state !== 'hidden', 'is-collapsed': sidebar.state === 'collapsed' }">
22
+ <!-- The sidebar holds about 30 links, so keyboard users can jump past it. The link shows only when it has focus. -->
23
+ <a href="#docs-content" class="vh-skip-link">Skip to content</a>
24
+ <UPage :ui="withDocsTheme('page', docsShellUi)">
25
+ <template v-if="sidebar.state !== 'hidden'" #left>
26
+ <UPageAside class="vh-docs-aside hidden lg:flex">
27
+ <!-- Phones hide this column and open the sidebar from the header menu, so it hydrates only once it shows. -->
28
+ <LazyDocsSidebars hydrate-on-visible class="vh-docs-aside-sidebars" :panel="sidebar.state === 'open'" head :collapsible="sidebar.collapsible" />
29
+ </UPageAside>
30
+ </template>
31
+
32
+ <!-- The banner spans the page column, so its border meets the sidebar and the right edge. -->
33
+ <div id="docs-content" tabindex="-1" class="relative">
34
+ <!-- 40px including the border, the same height as the sidebar search, so both bottom rules line up. It grows when the text wraps. -->
35
+ <!-- A page with a collapsible sidebar, such as a playground, fills the viewport, so it has no banner. -->
36
+ <div v-if="banner && !sidebar.collapsible" class="flex min-h-10 items-center justify-center border-b border-default bg-default px-4 py-2 text-center text-sm/5">
37
+ <span class="text-muted">{{ banner }}</span>
38
+ </div>
39
+ </div>
40
+ <slot />
41
+ </UPage>
42
+ </UMain>
43
+ </DocsAppShell>
44
+ </template>
45
+
46
+ <style scoped>
47
+ .vh-skip-link {
48
+ position: fixed;
49
+ top: 0.5rem;
50
+ left: 0.5rem;
51
+ z-index: 60;
52
+ padding: 0.5rem 0.75rem;
53
+ border: 1px solid var(--ui-border);
54
+ border-radius: calc(var(--ui-radius) * 1.5);
55
+ background: var(--ui-bg);
56
+ color: var(--ui-text-highlighted);
57
+ font-size: 0.875rem;
58
+ font-weight: 500;
59
+ transform: translateY(calc(-100% - 1rem));
60
+ }
61
+
62
+ .vh-skip-link:focus {
63
+ transform: none;
64
+ }
65
+
66
+ @media (min-width: 64rem) {
67
+ /* Beside a tutorial the navigation is a short page list, so its panel is narrower and the prose and code keep the width. */
68
+ /* The sum is set again here, because a custom property resolves its calc() where it is declared. */
69
+ .vh-docs-shell.is-tutorial {
70
+ --vh-panel-width: 12rem;
71
+ --vh-sidebar-width: calc(var(--vh-rail-width) + var(--vh-panel-width));
72
+ }
73
+
74
+ /* A collapsed sidebar is a strip as wide as the rail. */
75
+ .vh-docs-shell.is-collapsed {
76
+ --vh-sidebar-width: var(--vh-rail-width);
77
+ }
78
+
79
+ /* AppHeader hides beside the sidebar. Sticky offsets and full-height columns read this variable. */
80
+ .vh-docs-shell.has-sidebar:has([data-docs-sidebar-head]) {
81
+ --ui-header-height: 0px;
82
+ }
83
+
84
+ .vh-docs-aside {
85
+ position: sticky;
86
+ top: var(--ui-header-height);
87
+ display: flex;
88
+ height: calc(100dvh - var(--ui-header-height));
89
+ max-height: calc(100dvh - var(--ui-header-height));
90
+ min-height: calc(100dvh - var(--ui-header-height));
91
+ flex-direction: column;
92
+ overflow: hidden;
93
+ border-right: 1px solid var(--ui-border);
94
+ }
95
+
96
+ /* The aside container is a flex column. Without a flex basis the sidebars shrink to the rail header and the panel loses its page list. */
97
+ .vh-docs-aside-sidebars {
98
+ min-height: 0;
99
+ flex: 1 1 0;
100
+ }
101
+
102
+ }
103
+
104
+ </style>
@@ -0,0 +1,23 @@
1
+ import { defineNuxtRouteMiddleware, isDocsStartLink, navigateTo, useDocsConfig, useRuntimeConfig } from "#imports"
2
+ import manifest from "#docs/manifest"
3
+ import panels from "#docs/panels"
4
+ import { docsAppPath, docsSectionForPath, findDocsPage, loadDocsPanels } from "#docs/navigation"
5
+ import { articleLayout } from "#docs/shell"
6
+
7
+ // A docs page renders in the docs shell whichever app page serves its path. A page outside the docs base, such as
8
+ // `/about`, is a plain article under the site header, and a `home` page is its own blocks under it. A page that
9
+ // `start.links` lists opens inside the start section, so it gets the shell too. With an app-owned `app.vue`, plain
10
+ // articles use `docs-article`, so the app keeps its `default` layout.
11
+ export default defineNuxtRouteMiddleware(async (to, from) => {
12
+ // The pages inside a panel load when the reader opens it, before anything reads the manifest for this route.
13
+ await loadDocsPanels(manifest, to.path, panels)
14
+ const found = findDocsPage(manifest, to.path)
15
+ if (found) to.meta.layout = found.page.layout !== "home" && (found.section || found.page.path === manifest.root?.path || isDocsStartLink(useDocsConfig(), to.path)) ? "docs" : articleLayout
16
+ // A new page that exists only as a Content draft renders in the shell of its section.
17
+ else if (docsSectionForPath(manifest, to.path)) to.meta.layout = "docs"
18
+ // No docs page and no app page answers the path, but the host may: a static app copied into the output, such as a
19
+ // playground at `/play/`, or a file in `public/`. A client navigation would draw the docs 404 for it, so the browser
20
+ // loads it. The first load and a reload come from the server already, so they never reach this.
21
+ else if (import.meta.client && from.matched.length > 0 && to.name === "docs-page" && to.path !== from.path)
22
+ return navigateTo(docsAppPath(to.fullPath, useRuntimeConfig().app.baseURL), { external: true })
23
+ })
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <DocsPage />
3
+ </template>
@@ -0,0 +1,14 @@
1
+ import file, { names } from "#docs/comark-css"
2
+ import { defineNuxtPlugin, useHead, useRuntimeConfig } from "#imports"
3
+
4
+ // The comark-ui stylesheet that every page needs, the error page too. It is a public asset, so its URL follows Nuxt's
5
+ // rule for those: below `app.cdnURL` when set, else below `app.baseURL`. Both are read at runtime, since
6
+ // `NUXT_APP_BASE_URL` and `NUXT_APP_CDN_URL` can change them after the build.
7
+ // The link goes after the app's CSS, where the components add their styles, since some of their unlayered rules tie
8
+ // with the app's and must still win. Its `data-comark-<name>` attributes tell each component its styles are on the page.
9
+ export default defineNuxtPlugin(() => {
10
+ const { baseURL, cdnURL } = useRuntimeConfig().app
11
+ const base = (cdnURL || baseURL).replace(/\/*$/, "/")
12
+ const marks = Object.fromEntries(names.map(name => [`data-comark-${name}`, ""]))
13
+ useHead({ link: [{ rel: "stylesheet", href: `${base}_docs/${file}`, tagPriority: "low", ...marks }] })
14
+ })
@@ -0,0 +1,12 @@
1
+ import { docsIconStroke } from "#docs/navigation"
2
+ import { defineNuxtPlugin, useAppConfig, useDocsConfig } from "#imports"
3
+
4
+ // Lucide draws its lines 2px wide. The docs draw them at `docs.icons.stroke`, 1.5px by default, the stroke of the
5
+ // ViteHub set, so a section icon and the page icons under it look like one set. A site that sets `icon.customize` in
6
+ // its app config keeps its own.
7
+ export default defineNuxtPlugin(() => {
8
+ const icon = useAppConfig().icon
9
+ const { stroke } = useDocsConfig().icons
10
+ if (!icon || icon.customize || stroke === false) return
11
+ icon.customize = (content: string) => docsIconStroke(content, stroke)
12
+ })
@@ -0,0 +1,18 @@
1
+ import { defineNuxtPlugin, nextTick, ref, useHead, watch } from "#imports"
2
+ import { ownsApp } from "#docs/shell"
3
+
4
+ // The browser bar matches the page canvas: the `--ui-bg` of the design system, read from the page, so the theme stays
5
+ // the only place that names the color. It follows the mode that the reader picks. A plugin, and not `app.vue`, so the
6
+ // error page has it too. An app with its own `app.vue` keeps its browser bar color. Prerendered HTML has no value, and
7
+ // browsers use their own bar color until the app starts.
8
+ export default defineNuxtPlugin((nuxtApp) => {
9
+ if (!ownsApp || import.meta.server) return
10
+ const color = ref<string>()
11
+ const read = () => {
12
+ color.value = getComputedStyle(document.documentElement).backgroundColor || undefined
13
+ }
14
+ nuxtApp.hook("app:mounted", read)
15
+ // The color mode module sets the class on `<html>` after the value changes, so read after that render.
16
+ watch(() => nuxtApp.$colorMode?.value, () => nextTick(() => requestAnimationFrame(read)))
17
+ useHead({ meta: [{ name: "theme-color", content: color }] })
18
+ })
@@ -0,0 +1,43 @@
1
+ // A Nuxt app maps `defu` to its package folder, where its types are `export =`. Only a default import reads them.
2
+ import defu from "defu"
3
+
4
+ type DocsThemeUi = Record<string, unknown>
5
+
6
+ /** What Nuxt UI's `<UTheme>` takes: slot classes per component in `ui`, and default props per component in `props`. */
7
+ export interface DocsThemeScope {
8
+ ui: Record<string, unknown>
9
+ props: Record<string, unknown>
10
+ }
11
+
12
+ /**
13
+ * The theme as `<UTheme>` props, for the docs pages of an app with its own `app.vue`. The app's `app.config.ts` then
14
+ * stays as written on the app's own pages. `<UTheme>` sets slot classes and default props only, so the docs pages keep
15
+ * the app's colors, icons, and variant classes, such as the color of a callout.
16
+ */
17
+ export function docsThemeScope(theme: DocsThemeUi): DocsThemeScope {
18
+ const scope: DocsThemeScope = { ui: {}, props: {} }
19
+ for (const [name, entry] of Object.entries(theme)) {
20
+ if (name === "colors" || name === "icons" || !isRecord(entry)) continue
21
+ if (name === "prose") {
22
+ const prose = docsThemeScope(entry)
23
+ scope.ui.prose = prose.ui
24
+ if (Object.keys(prose.props).length) scope.props.prose = prose.props
25
+ continue
26
+ }
27
+ // A component with one element has a `base` class instead of slots, and reads it from `ui.base`.
28
+ const slots = isRecord(entry.slots) ? entry.slots : typeof entry.base === "string" ? { base: entry.base } : null
29
+ if (slots) scope.ui[name] = slots
30
+ if (isRecord(entry.defaultVariants)) scope.props[name] = entry.defaultVariants
31
+ }
32
+ return scope
33
+ }
34
+
35
+ /** Resolve the live app config above the docs defaults, without adding a scope to standalone docs sites. */
36
+ export function resolveDocsTheme(scope: DocsThemeScope, ui: DocsThemeUi = {}): DocsThemeScope {
37
+ if (!Object.keys(scope.ui).length && !Object.keys(scope.props).length) return scope
38
+ return defu(docsThemeScope(ui), scope)
39
+ }
40
+
41
+ function isRecord(value: unknown): value is Record<string, unknown> {
42
+ return typeof value === "object" && value !== null && !Array.isArray(value)
43
+ }
@@ -0,0 +1,40 @@
1
+ export type FileTreeFolderRow = { kind: "folder"; name: string; path: string; depth: number }
2
+ export type FileTreeFileRow = { kind: "file"; name: string; path: string; depth: number; index: number }
3
+ export type FileTreeRow = FileTreeFolderRow | FileTreeFileRow
4
+
5
+ type Folder = { folders: Map<string, Folder>; files: { name: string; path: string; index: number }[] }
6
+
7
+ /**
8
+ * Lays out file paths as an editor file tree: folders first, then files, each sorted by name.
9
+ * `index` keeps the position of the path in the input, so callers can map a row back to its file.
10
+ */
11
+ export function buildFileTree(paths: readonly string[]): FileTreeRow[] {
12
+ const root: Folder = { folders: new Map(), files: [] }
13
+ paths.forEach((path, index) => {
14
+ const parts = path.split("/")
15
+ const name = parts.pop() ?? path
16
+ let folder = root
17
+ for (const part of parts) {
18
+ let child = folder.folders.get(part)
19
+ if (!child) {
20
+ child = { folders: new Map(), files: [] }
21
+ folder.folders.set(part, child)
22
+ }
23
+ folder = child
24
+ }
25
+ folder.files.push({ name, path, index })
26
+ })
27
+
28
+ const rows: FileTreeRow[] = []
29
+ const visit = (folder: Folder, depth: number, prefix: string) => {
30
+ for (const [name, child] of [...folder.folders].sort(([left], [right]) => left.localeCompare(right))) {
31
+ rows.push({ kind: "folder", name, path: `${prefix}${name}/`, depth })
32
+ visit(child, depth + 1, `${prefix}${name}/`)
33
+ }
34
+ for (const file of [...folder.files].sort((left, right) => left.name.localeCompare(right.name))) {
35
+ rows.push({ kind: "file", ...file, depth })
36
+ }
37
+ }
38
+ visit(root, 0, "")
39
+ return rows
40
+ }
@@ -0,0 +1,6 @@
1
+ import { ContentHandler } from "@vite-hub/content";
2
+ //#region src/runtime/server/llms.d.ts
3
+ /** `/llms.txt`, `/llms-full.txt`, and `/sitemap.md`, from Content. The build prerenders them. */
4
+ declare const handler: ContentHandler;
5
+ //#endregion
6
+ export { handler as default };
@@ -0,0 +1,7 @@
1
+ import { n as docsContent } from "../../content-CPZGnn3S.js";
2
+ import { defineContentLlmsHandler } from "@vite-hub/content";
3
+ //#region src/runtime/server/llms.ts
4
+ /** `/llms.txt`, `/llms-full.txt`, and `/sitemap.md`, from Content. The build prerenders them. */
5
+ const handler = { fetch: (request) => defineContentLlmsHandler(docsContent()).fetch(request) };
6
+ //#endregion
7
+ export { handler as default };
@@ -0,0 +1,10 @@
1
+ import { ContentMiddleware } from "@vite-hub/content/markdown";
2
+ //#region src/runtime/server/markdown.d.ts
3
+ /**
4
+ * The Markdown copy of each app page that is not a docs page, at its URL plus `.md` and for `Accept: text/markdown`.
5
+ * Content converts the HTML that Nitro renders for the same request. nuxt-agent-discovery answers the docs pages first.
6
+ * Content loads on the first request that asks for Markdown or gets an HTML page.
7
+ */
8
+ declare const handler: ContentMiddleware;
9
+ //#endregion
10
+ export { handler as default };
@@ -0,0 +1,11 @@
1
+ import { defineContentMarkdownHandler } from "@vite-hub/content/markdown";
2
+ import { serverFetch } from "nitro";
3
+ //#region src/runtime/server/markdown.ts
4
+ /**
5
+ * The Markdown copy of each app page that is not a docs page, at its URL plus `.md` and for `Accept: text/markdown`.
6
+ * Content converts the HTML that Nitro renders for the same request. nuxt-agent-discovery answers the docs pages first.
7
+ * Content loads on the first request that asks for Markdown or gets an HTML page.
8
+ */
9
+ const handler = defineContentMarkdownHandler(() => import("../../content-CPZGnn3S.js").then((n) => n.t).then((module) => module.docsContent()), { render: (request) => serverFetch(request) });
10
+ //#endregion
11
+ export { handler as default };
@@ -0,0 +1,6 @@
1
+ import { ContentHandler } from "@vite-hub/content";
2
+ //#region src/runtime/server/mcp.d.ts
3
+ /** The docs MCP server at `/mcp`, with the `list-pages` and `get-page` tools of Content. */
4
+ declare const handler: ContentHandler;
5
+ //#endregion
6
+ export { handler as default };
@@ -0,0 +1,7 @@
1
+ import { n as docsContent } from "../../content-CPZGnn3S.js";
2
+ import { defineContentMcpHandler } from "@vite-hub/content";
3
+ //#region src/runtime/server/mcp.ts
4
+ /** The docs MCP server at `/mcp`, with the `list-pages` and `get-page` tools of Content. */
5
+ const handler = { fetch: (request) => defineContentMcpHandler(docsContent()).fetch(request) };
6
+ //#endregion
7
+ export { handler as default };