@vite-hub/docs 0.0.0-stage → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +453 -2
  3. package/dist/agent-copy-BJp_Yf5d.js +33 -0
  4. package/dist/assistant-shared-CdtXowot.js +97 -0
  5. package/dist/assistant-shared-Dll_F_yy.d.ts +27 -0
  6. package/dist/assistant-worker.d.ts +11 -0
  7. package/dist/assistant-worker.js +16 -0
  8. package/dist/assistant.d.ts +14 -0
  9. package/dist/assistant.js +19 -0
  10. package/dist/content-9CINWiRf.js +171 -0
  11. package/dist/draft-DUBx--r9.js +45 -0
  12. package/dist/error-diagnostics-BoOsP6Y4.js +53 -0
  13. package/dist/index.d.ts +28 -0
  14. package/dist/index.js +27 -0
  15. package/dist/link-checker-redirects.d.ts +13 -0
  16. package/dist/link-checker-redirects.js +25 -0
  17. package/dist/manifest-D66AEF8F.js +420 -0
  18. package/dist/manifest-Dzp5-_AJ.d.ts +74 -0
  19. package/dist/markdown-Cn9-4oVG.js +378 -0
  20. package/dist/navigation.d.ts +284 -0
  21. package/dist/navigation.js +520 -0
  22. package/dist/nuxt-B5LrERKc.d.ts +240 -0
  23. package/dist/nuxt.d.ts +3 -0
  24. package/dist/nuxt.js +1485 -0
  25. package/dist/page-BbmSfZO8.js +81 -0
  26. package/dist/page-Dx2JD3y1.d.ts +74 -0
  27. package/dist/primitive-rail.d.ts +110 -0
  28. package/dist/primitive-rail.js +284 -0
  29. package/dist/raw-C03EUJKw.js +851 -0
  30. package/dist/redirects-BrbWFSzW.js +62 -0
  31. package/dist/runtime/app/app.vue +11 -0
  32. package/dist/runtime/app/assistant/DocsAssistant.vue +81 -0
  33. package/dist/runtime/app/assistant/DocsAssistantOff.vue +8 -0
  34. package/dist/runtime/app/assistant/DocsAssistantPanel.vue +322 -0
  35. package/dist/runtime/app/components/AppHeader.vue +368 -0
  36. package/dist/runtime/app/components/AppSearch.vue +68 -0
  37. package/dist/runtime/app/components/DocsAppShell.vue +62 -0
  38. package/dist/runtime/app/components/DocsArticle.vue +184 -0
  39. package/dist/runtime/app/components/DocsAsideFooter.vue +94 -0
  40. package/dist/runtime/app/components/DocsAsideLeftBody.vue +584 -0
  41. package/dist/runtime/app/components/DocsAsideLeftTop.vue +132 -0
  42. package/dist/runtime/app/components/DocsBrandMark.vue +52 -0
  43. package/dist/runtime/app/components/DocsCatalogFooter.vue +129 -0
  44. package/dist/runtime/app/components/DocsCodePanel.vue +388 -0
  45. package/dist/runtime/app/components/DocsCodePre.vue +120 -0
  46. package/dist/runtime/app/components/DocsHeaderActions.vue +4 -0
  47. package/dist/runtime/app/components/DocsLanding.vue +83 -0
  48. package/dist/runtime/app/components/DocsMarkdown.vue +64 -0
  49. package/dist/runtime/app/components/DocsPage.vue +149 -0
  50. package/dist/runtime/app/components/DocsPageCredits.vue +41 -0
  51. package/dist/runtime/app/components/DocsPageHeaderLinks.vue +120 -0
  52. package/dist/runtime/app/components/DocsRail.vue +239 -0
  53. package/dist/runtime/app/components/DocsSidebarStrip.vue +81 -0
  54. package/dist/runtime/app/components/DocsSidebars.vue +63 -0
  55. package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +33 -0
  56. package/dist/runtime/app/components/content/AgentOnly.vue +9 -0
  57. package/dist/runtime/app/components/content/CodeTree.vue +203 -0
  58. package/dist/runtime/app/components/content/ComarkHtml.vue +31 -0
  59. package/dist/runtime/app/components/content/Correct.vue +17 -0
  60. package/dist/runtime/app/components/content/Example.vue +260 -0
  61. package/dist/runtime/app/components/content/ExamplePreview.vue +6 -0
  62. package/dist/runtime/app/components/content/Examples.vue +71 -0
  63. package/dist/runtime/app/components/content/Incorrect.vue +17 -0
  64. package/dist/runtime/app/components/content/PageList.vue +206 -0
  65. package/dist/runtime/app/components/content/ProductFeatureItem.vue +43 -0
  66. package/dist/runtime/app/components/content/ProductFeatures.vue +17 -0
  67. package/dist/runtime/app/components/content/TutorialStep.vue +39 -0
  68. package/dist/runtime/app/composables/docs-assistant-problem.ts +59 -0
  69. package/dist/runtime/app/composables/docs-theme.ts +15 -0
  70. package/dist/runtime/app/composables/docs.ts +83 -0
  71. package/dist/runtime/app/composables/headerActions.ts +6 -0
  72. package/dist/runtime/app/composables/icons.ts +14 -0
  73. package/dist/runtime/app/composables/seo.ts +64 -0
  74. package/dist/runtime/app/composables/tutorial.ts +40 -0
  75. package/dist/runtime/app/composables/useDocsAssistant.ts +17 -0
  76. package/dist/runtime/app/error.vue +88 -0
  77. package/dist/runtime/app/layouts/default.vue +7 -0
  78. package/dist/runtime/app/layouts/docs.vue +104 -0
  79. package/dist/runtime/app/middleware/docs-layout.ts +23 -0
  80. package/dist/runtime/app/pages/docs-page.vue +3 -0
  81. package/dist/runtime/app/plugins/comark-css.ts +14 -0
  82. package/dist/runtime/app/plugins/icon-stroke.ts +12 -0
  83. package/dist/runtime/app/plugins/theme-color.ts +18 -0
  84. package/dist/runtime/app/utils/docs-theme.ts +43 -0
  85. package/dist/runtime/app/utils/file-tree.ts +40 -0
  86. package/dist/runtime/server/llms.d.ts +6 -0
  87. package/dist/runtime/server/llms.js +7 -0
  88. package/dist/runtime/server/markdown.d.ts +10 -0
  89. package/dist/runtime/server/markdown.js +11 -0
  90. package/dist/runtime/server/mcp.d.ts +6 -0
  91. package/dist/runtime/server/mcp.js +7 -0
  92. package/dist/runtime/server/page.d.ts +7 -0
  93. package/dist/runtime/server/page.js +27 -0
  94. package/dist/runtime/server/raw.d.ts +10 -0
  95. package/dist/runtime/server/raw.js +23 -0
  96. package/dist/runtime/server/search.d.ts +6 -0
  97. package/dist/runtime/server/search.js +32 -0
  98. package/dist/runtime/server/sitemap.d.ts +6 -0
  99. package/dist/runtime/server/sitemap.js +52 -0
  100. package/dist/runtime/server/trailing-slash.d.ts +10 -0
  101. package/dist/runtime/server/trailing-slash.js +28 -0
  102. package/dist/runtime/theme/design.css +464 -0
  103. package/dist/schema-DwpXW0VZ.js +98 -0
  104. package/dist/server.d.ts +15 -0
  105. package/dist/server.js +5 -0
  106. package/dist/theme-BXyu4uFL.d.ts +32 -0
  107. package/dist/theme-DzC8LtMH.js +237 -0
  108. package/dist/theme.d.ts +2 -0
  109. package/dist/theme.js +2 -0
  110. package/dist/types-BhG6vGfG.d.ts +212 -0
  111. package/package.json +141 -3
@@ -0,0 +1,120 @@
1
+ <script setup lang="ts">
2
+ import { CopyButton } from "@vite-hub/ui"
3
+
4
+ const props = defineProps<{
5
+ code?: string
6
+ language?: string | null
7
+ filename?: string | null
8
+ highlights?: number[]
9
+ meta?: string | null
10
+ class?: string | null
11
+ }>()
12
+
13
+ const pre = useTemplateRef<HTMLPreElement>("pre")
14
+ const code = () => props.code ?? pre.value?.textContent ?? ""
15
+ </script>
16
+
17
+ <template>
18
+ <div class="code-block-wrapper" :class="{ 'has-filename': filename }">
19
+ <div v-if="filename" class="vh-code-filename">
20
+ <span>{{ filename }}</span>
21
+ </div>
22
+ <pre
23
+ ref="pre"
24
+ :class="[language && `language-${language}`, $props.class]"
25
+ :data-filename="filename || undefined"
26
+ :data-code-filename="filename || undefined"
27
+ ><slot /></pre>
28
+ <!-- After the filename bar, so the tutorial code panel still finds the bar as the first child. -->
29
+ <CopyButton :value="code" size="xs" aria-label="Copy code" class="vh-code-copy" />
30
+ </div>
31
+ </template>
32
+
33
+ <style scoped>
34
+ .code-block-wrapper {
35
+ position: relative;
36
+ min-width: 0;
37
+ margin-block: 1rem;
38
+ border: 1px solid var(--ui-border);
39
+ border-radius: calc(var(--ui-radius) * 2);
40
+ }
41
+
42
+ .vh-code-filename {
43
+ display: flex;
44
+ min-height: 2.5rem;
45
+ align-items: center;
46
+ gap: 0.5rem;
47
+ border-bottom: 1px solid var(--ui-border);
48
+ /* The bar fills the top of the frame, so it follows the frame's corners. */
49
+ border-start-start-radius: inherit;
50
+ border-start-end-radius: inherit;
51
+ background: var(--ui-bg-muted);
52
+ /* The copy button sits over the end of the bar, so a long name wraps before it. */
53
+ padding: 0.375rem 2.75rem 0.375rem 0.75rem;
54
+ color: var(--ui-text-muted);
55
+ font-family: var(--font-mono);
56
+ font-size: 0.75rem;
57
+ line-height: 1.25rem;
58
+ }
59
+
60
+ .vh-code-filename > span {
61
+ min-width: 0;
62
+ overflow-wrap: anywhere;
63
+ }
64
+
65
+ .code-block-wrapper > pre {
66
+ margin-block: 0;
67
+ }
68
+
69
+ .vh-code-filename + pre {
70
+ border-start-start-radius: 0;
71
+ border-start-end-radius: 0;
72
+ }
73
+
74
+ /* Centered in the 40px filename bar, or in the first line of code when there is no bar. */
75
+ .vh-code-copy {
76
+ position: absolute;
77
+ top: 0.4375rem;
78
+ right: 0.4375rem;
79
+ color: var(--ui-text-muted);
80
+ }
81
+
82
+ .code-block-wrapper:not(.has-filename) > .vh-code-copy {
83
+ top: 0.5625rem;
84
+ background: var(--ui-bg);
85
+ }
86
+
87
+ /* With a mouse the button shows on hover or focus. Touch screens cannot hover, so it stays visible there. */
88
+ @media (hover: hover) and (pointer: fine) {
89
+ .vh-code-copy {
90
+ opacity: 0;
91
+ }
92
+
93
+ .code-block-wrapper:hover > .vh-code-copy,
94
+ .vh-code-copy:focus-visible {
95
+ opacity: 1;
96
+ }
97
+ }
98
+
99
+ @media (pointer: coarse) {
100
+ .vh-code-copy {
101
+ top: 0.125rem;
102
+ right: 0.125rem;
103
+ width: 2.25rem;
104
+ height: 2.25rem;
105
+ justify-content: center;
106
+ }
107
+
108
+ /* A 44px tap area around the 36px button. */
109
+ .vh-code-copy::before {
110
+ position: absolute;
111
+ inset: -4px;
112
+ content: "";
113
+ }
114
+
115
+ .code-block-wrapper:not(.has-filename) > .vh-code-copy {
116
+ top: 0.25rem;
117
+ right: 0.25rem;
118
+ }
119
+ }
120
+ </style>
@@ -0,0 +1,4 @@
1
+ <!-- Items in the site header or the desktop sidebar footer. An app's own `DocsHeaderActions` component replaces this one. -->
2
+ <template>
3
+ <span class="contents" />
4
+ </template>
@@ -0,0 +1,83 @@
1
+ <script setup lang="ts">
2
+ import type { DocsPageResponse } from "@vite-hub/docs"
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
+ const props = defineProps<{
8
+ response: DocsPageResponse
9
+ header?: boolean
10
+ }>()
11
+
12
+ const section = useDocsSection()
13
+ const page = computed(() => props.response.page)
14
+ </script>
15
+
16
+ <template>
17
+ <UPage v-if="header" :ui="withDocsTheme('page', { root: 'lg:!grid-cols-1 lg:!gap-0', center: 'lg:!col-span-1', right: 'hidden' })" :data-path="page.path">
18
+ <UPageHeader :headline="page.eyebrow ?? undefined" :title="page.sourceTitle" :description="page.tagline ?? undefined">
19
+ <template #links>
20
+ <DocsPageHeaderLinks />
21
+ </template>
22
+ </UPageHeader>
23
+
24
+ <UPageBody prose class="docs-content docs-catalog-content pb-16">
25
+ <DocsMarkdown :document="response.document" />
26
+ <DocsPageCredits v-if="response.credits" :credits="response.credits" class="not-prose mt-10" />
27
+ </UPageBody>
28
+ </UPage>
29
+
30
+ <article v-else class="vh-product-landing" :data-path="page.path">
31
+ <div class="vh-product-actions">
32
+ <DocsPageHeaderLinks />
33
+ </div>
34
+
35
+ <UPageBody prose class="docs-content vh-product-body !px-0">
36
+ <DocsMarkdown :document="response.document" />
37
+ <DocsPageCredits v-if="response.credits" :credits="response.credits" class="not-prose mt-10" />
38
+ </UPageBody>
39
+
40
+ <!-- Below the content: its links work before it hydrates. -->
41
+ <LazyDocsCatalogFooter hydrate-on-visible :current="section" />
42
+ </article>
43
+ </template>
44
+
45
+ <style scoped>
46
+ /* The page header shows the title, so the catalog hides the h1 of its Markdown. A section hero keeps its own h1. */
47
+ .docs-catalog-content :deep(h1:first-of-type) {
48
+ display: none;
49
+ }
50
+
51
+ /* The catalog spans the full page width. Its intro children keep the measure; a `.vh-docs-wide` block uses the width. */
52
+ .docs-catalog-content :deep(> .comark-content > :not(.vh-docs-wide)) {
53
+ max-width: var(--vh-content-width);
54
+ }
55
+
56
+ /* The landing has no page header or page body padding, so it sets the same insets itself. Below 40rem the page gutter is the only one. */
57
+ .vh-product-landing {
58
+ padding: 0 0 4rem;
59
+ }
60
+
61
+ @media (min-width: 40rem) {
62
+ .vh-product-landing {
63
+ padding-inline: 2rem;
64
+ }
65
+ }
66
+
67
+ @media (min-width: 80rem) {
68
+ .vh-product-landing {
69
+ padding-inline: 3rem;
70
+ }
71
+ }
72
+
73
+ .vh-product-actions {
74
+ display: flex;
75
+ justify-content: flex-end;
76
+ padding-top: 1rem;
77
+ }
78
+
79
+ /* The landing body spans the full landing width. Its sections manage their own measure. */
80
+ .vh-product-body {
81
+ padding-bottom: 0;
82
+ }
83
+ </style>
@@ -0,0 +1,64 @@
1
+ <script setup lang="ts">
2
+ import { MarkdownDocument } from "@comark/vue/components/MarkdownDocument"
3
+ import { camelize, capitalize, defineAsyncComponent } from "vue"
4
+ import blocks from "#docs/blocks"
5
+ import customComponents from "#docs/custom-components"
6
+ import contentComponents from "#docs/components"
7
+
8
+ import type { Component } from "vue"
9
+ import type { ElementNode, Node as ComarkNode } from "comark"
10
+ import type { DocsDocument } from "@vite-hub/docs"
11
+
12
+ // The server parsed the page, so the client only renders nodes. Explicit maps and app content components override
13
+ // comark-ui's blocks. Blocks and content components load on first use, so a page downloads only the blocks it renders.
14
+ // The map has every comark-ui block, not only those of the plugins this package parses with: a site that adds chips or
15
+ // another comark-ui plugin to its parser gets its nodes drawn.
16
+ const props = defineProps<{
17
+ document: DocsDocument
18
+ /** Components by tag, such as `{ pre: DocsCodePre }`. */
19
+ components?: Record<string, Component>
20
+ }>()
21
+
22
+ // `::note`, `::tip`, and the other callout components draw comark-ui's GitHub callout, the same as a `> [!NOTE]` quote.
23
+ const callout = (type: string, title?: string): Component => defineComponent({
24
+ name: `${type[0]!.toUpperCase()}${type.slice(1)}Callout`,
25
+ setup: (_, { slots }) => () => h(blocks.GithubCallout!, { type, title }, slots),
26
+ })
27
+ const callouts: Record<string, Component> = {
28
+ Note: callout("note", "Note"),
29
+ Tip: callout("tip", "Tip"),
30
+ Important: callout("important", "Important"),
31
+ Warning: callout("warning", "Warning"),
32
+ Caution: callout("caution", "Caution"),
33
+ Callout: callout("note"),
34
+ }
35
+
36
+ const contentBlocks = Object.fromEntries(Object.entries(contentComponents).flatMap(([tag, load]) => load ? [[tag, defineAsyncComponent(async () => (await load()).default)]] : []))
37
+ const componentKey = (tag: string) => capitalize(camelize(tag))
38
+ // Comark looks up PascalCase before the raw tag, so all maps must use the same keys for precedence to hold.
39
+ const byKey = (maps: Record<string, Component>[]) => Object.fromEntries(maps.flatMap(map => Object.entries(map).map(([tag, component]) => [componentKey(tag), component])))
40
+ const overrides = computed(() => byKey([contentBlocks, customComponents, props.components ?? {}]))
41
+ const resolved = computed(() => ({ ...byKey([blocks, callouts]), ...overrides.value }))
42
+
43
+ // HTML is the fallback. An app component still receives the original tag, props, and source children. comark-ui's own
44
+ // 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[] {
46
+ return nodes.map((node): ComarkNode => {
47
+ if (typeof node === "string" || node[0] === null) return node
48
+ const [tag, attributes, ...children] = node
49
+ const { block, blockProps } = attributes
50
+ if (tag === "comark-html" && typeof block === "string" && overrides.value[componentKey(block)]) {
51
+ return [block, (blockProps ?? {}) as ElementNode[1], ...renderNodes(children)]
52
+ }
53
+ return [tag, attributes, ...renderNodes(children)]
54
+ })
55
+ }
56
+ const nodes = computed(() => renderNodes(props.document.nodes))
57
+ </script>
58
+
59
+ <template>
60
+ <MarkdownDocument
61
+ :value="{ nodes, frontmatter: {}, meta: {} }"
62
+ :components="resolved"
63
+ />
64
+ </template>
@@ -0,0 +1,149 @@
1
+ <script setup lang="ts">
2
+ import { camelize, capitalize } from "vue"
3
+ import { pageBlocks } from "#docs/components"
4
+ import { docsAppPath, docsRawPath, normalizeDocsPath } from "#docs/navigation"
5
+ import { articleLayout } from "#docs/shell"
6
+
7
+ import type { Node as ComarkNode } from "comark"
8
+ import type { DocsDocument, DocsPageResponse } from "@vite-hub/docs"
9
+
10
+ const route = useRoute()
11
+ const manifest = useDocsManifest()
12
+ const { site, appBase } = useDocsConfig()
13
+ const path = normalizeDocsPath(route.path)
14
+ // A Content preview can show a new draft outside the build-time manifest. Let the page request decide whether it exists.
15
+ const { data } = await useFetch<DocsPageResponse>(docsAppPath(`/api/_docs/page${path === "/" ? "/index" : path}.json`, appBase), { key: `docs:${path}` })
16
+ if (!data.value) throw createError({ statusCode: 404, statusMessage: "Page not found", fatal: true })
17
+ const response = data.value
18
+ const { page } = response
19
+
20
+ const isRoot = page.path === manifest.root?.path
21
+ // A page that `start.links` lists opens inside the start section, like the pages of a section.
22
+ const isStartLink = isDocsStartLink(useDocsConfig(), page.path)
23
+ // Content previews can change a page's layout or add a home page after the manifest was built.
24
+ const layout = page.layout !== "home" && (response.section || isRoot || isStartLink) ? "docs" : articleLayout
25
+ if (import.meta.client && route.meta.layout !== layout) {
26
+ // The server has already rendered the manifest's layout. Finish hydrating it before switching shells.
27
+ if (useNuxtApp().isHydrating) onNuxtReady(() => setPageLayout(layout))
28
+ else setPageLayout(layout)
29
+ }
30
+ // A page outside the docs base has no section. It reads as a plain article under the site header.
31
+ const isStandalone = !response.section && !isRoot && !isStartLink && page.layout !== "home"
32
+
33
+ // A home page draws the app's `components/content/` blocks at full width. The Markdown between two of them, such as a
34
+ // heading and a list, goes in one column with the prose styles of a docs page.
35
+ const componentKey = (tag: string) => capitalize(camelize(tag))
36
+ function homeDocument(document: DocsDocument): DocsDocument {
37
+ const blocks = new Set(pageBlocks.map(componentKey))
38
+ const nodes: ComarkNode[] = []
39
+ let prose: ComarkNode[] = []
40
+ const flush = () => {
41
+ if (prose.length) nodes.push(["div", { class: "docs-content vh-docs-home-prose" }, ...prose])
42
+ prose = []
43
+ }
44
+ for (const node of document.nodes) {
45
+ // The parser draws some blocks as HTML. An app component with the block's name still draws it.
46
+ const tag = typeof node === "string" || node[0] === null ? undefined : node[0] === "comark-html" && typeof node[1].block === "string" ? node[1].block : node[0]
47
+ if (tag && blocks.has(componentKey(tag))) {
48
+ flush()
49
+ nodes.push(node)
50
+ }
51
+ else prose.push(node)
52
+ }
53
+ flush()
54
+ return { ...document, nodes }
55
+ }
56
+ const home = page.layout === "home" ? homeDocument(response.document) : undefined
57
+
58
+ // Agents can fetch the Markdown twin of the page instead of the HTML.
59
+ useHead({ link: [{ rel: "alternate", type: "text/markdown", href: `${site.url}${docsAppPath(docsRawPath(page.path), appBase)}` }] })
60
+ const section = manifest.sections.find(candidate => candidate.id === response.section)
61
+ // A page that search engines must not index gets no share image either: the build does not prerender it.
62
+ const indexed = page.seo?.index !== false
63
+ if (!indexed) useSeoMeta({ robots: "noindex, follow" })
64
+ useDocsSeo({
65
+ title: page.seo?.title ?? page.sourceTitle,
66
+ description: page.seo?.description ?? page.description,
67
+ section: section && { title: section.title, path: docsAppPath(section.path, appBase) },
68
+ image: indexed ? page.seo?.image : false,
69
+ type: isRoot || page.layout === "landing" || page.layout === "home" ? "page" : "article",
70
+ })
71
+ </script>
72
+
73
+ <template>
74
+ <!-- The layout's UMain is the page's only main landmark. -->
75
+ <div v-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">
76
+ <UPageHeader
77
+ :headline="page.eyebrow ?? undefined"
78
+ :title="page.sourceTitle"
79
+ :description="page.tagline ?? undefined"
80
+ :ui="withDocsTheme('pageHeader', {
81
+ root: 'border-b border-default px-0 pb-10 pt-0',
82
+ title: 'text-balance text-[38px] leading-[46px] sm:text-[46px] sm:leading-[54px]',
83
+ description: 'max-w-2xl text-pretty text-lg leading-8',
84
+ })"
85
+ />
86
+
87
+ <UPageBody prose class="!max-w-none !px-0 !pb-0 pt-10">
88
+ <DocsMarkdown :document="response.document" />
89
+ <DocsPageCredits v-if="response.credits" :credits="response.credits" class="not-prose mt-10" />
90
+ </UPageBody>
91
+ </div>
92
+
93
+ <div v-else-if="home" :data-path="page.path">
94
+ <DocsMarkdown :document="home" />
95
+ <DocsPageCredits v-if="response.credits" :credits="response.credits" class="mx-auto w-full max-w-(--vh-content-width) px-4 sm:px-6" />
96
+ </div>
97
+
98
+ <div v-else-if="page.layout === 'landing'" class="vh-docs-landing">
99
+ <DocsLanding :response="response" :header="isRoot" />
100
+ </div>
101
+
102
+ <!-- Remount numbered steps when navigating between tutorials. -->
103
+ <div v-else :key="page.layout === 'tutorial' ? page.path : undefined" :class="page.codePanel ? 'vh-docs-split' : 'vh-docs-main'">
104
+ <DocsArticle :response="response" />
105
+ </div>
106
+ </template>
107
+
108
+ <style scoped>
109
+ /* Below 40rem the article and the product landing set the only gutter, so the text keeps the width. */
110
+ .vh-docs-main,
111
+ .vh-docs-landing,
112
+ .vh-docs-split {
113
+ margin: 0 auto;
114
+ }
115
+
116
+ .vh-docs-landing {
117
+ padding: 0 1rem;
118
+ }
119
+
120
+ .vh-docs-main {
121
+ max-width: calc(var(--vh-content-width) + var(--vh-toc-width) + 4rem);
122
+ }
123
+
124
+ .vh-docs-landing {
125
+ max-width: 84rem;
126
+ }
127
+
128
+ @media (min-width: 40rem) {
129
+ .vh-docs-main,
130
+ .vh-docs-landing,
131
+ .vh-docs-split {
132
+ padding: 0 2rem;
133
+ }
134
+ }
135
+
136
+ /* With the article padding, the prose starts just clear of the pinned navigation button. */
137
+ @media (min-width: 64rem) {
138
+ .vh-docs-split {
139
+ padding-left: 1.25rem;
140
+ }
141
+ }
142
+
143
+ /* The code panel reaches the right edge of the page. */
144
+ @media (min-width: 80rem) {
145
+ .vh-docs-split {
146
+ padding-right: 0;
147
+ }
148
+ }
149
+ </style>
@@ -0,0 +1,41 @@
1
+ <script setup lang="ts">
2
+ import type { DocsDocument } from "@vite-hub/docs"
3
+
4
+ // The page's `credits` frontmatter, parsed on the server like the body.
5
+ defineProps<{
6
+ credits: DocsDocument
7
+ }>()
8
+ </script>
9
+
10
+ <template>
11
+ <footer class="vh-docs-credits">
12
+ <DocsMarkdown :document="credits" />
13
+ </footer>
14
+ </template>
15
+
16
+ <style scoped>
17
+ .vh-docs-credits {
18
+ border-top: 1px solid var(--ui-border);
19
+ padding-block: 1rem;
20
+ color: var(--ui-text-muted);
21
+ font-size: 0.875rem;
22
+ line-height: 1.5rem;
23
+ }
24
+
25
+ .vh-docs-credits :deep(p) {
26
+ margin: 0;
27
+ }
28
+
29
+ .vh-docs-credits :deep(a) {
30
+ color: var(--ui-text);
31
+ text-decoration: underline;
32
+ text-decoration-color: var(--ui-border-accented);
33
+ text-underline-offset: 3px;
34
+ }
35
+
36
+ @media (hover: hover) {
37
+ .vh-docs-credits :deep(a:hover) {
38
+ text-decoration-color: currentcolor;
39
+ }
40
+ }
41
+ </style>
@@ -0,0 +1,120 @@
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
+ import { CopyButton, useCopy } from "@vite-hub/ui"
4
+ import { docsMarkdownLinks, docsMcpInstallLinks, findDocsPage } from "#docs/navigation"
5
+
6
+ const route = useRoute()
7
+ const toast = useToast()
8
+ const { copy } = useCopy()
9
+ const manifest = useDocsManifest()
10
+ const { mcp, site, appBase } = useDocsConfig()
11
+ const links = computed(() => findDocsPage(manifest, route.path) ? docsMarkdownLinks(site, route.path, appBase) : null)
12
+ const menuOpen = ref(false)
13
+ const menuHydrated = ref(false)
14
+
15
+ function openPendingMenu(event: MouseEvent | KeyboardEvent) {
16
+ if (menuHydrated.value || !(event.target instanceof Element) || !event.target.closest(".vh-page-action-more")) return
17
+ if (event instanceof KeyboardEvent) {
18
+ if (!["Enter", " ", "ArrowDown"].includes(event.key)) return
19
+ }
20
+ else if (event.button !== 0 || event.ctrlKey) return
21
+
22
+ // Keep the first activation while the async menu loads. Updating its open prop also starts hydration before idle.
23
+ event.preventDefault()
24
+ event.stopPropagation()
25
+ menuOpen.value = true
26
+ }
27
+
28
+ async function copyText(text: string, title: string) {
29
+ if (await copy(text)) toast.add({ title, icon: "i-lucide-check" })
30
+ }
31
+
32
+ const pageMarkdown = () => $fetch<string>(links.value?.markdownPath ?? "", { responseType: "text" })
33
+
34
+ function copyPageFailed() {
35
+ toast.add({ title: "Could not copy the page", description: "Open the Markdown view instead.", icon: "i-lucide-x" })
36
+ }
37
+
38
+ function mcpItems(server: { name: string, url: string, guide: string | null }) {
39
+ const install = docsMcpInstallLinks(server)
40
+ return [
41
+ { label: "Copy MCP server URL", icon: "i-lucide-plug", onSelect: () => copyText(server.url, "MCP server URL copied") },
42
+ { label: "Add MCP server to Cursor", icon: "i-simple-icons-cursor", to: install.cursor, external: true },
43
+ { label: "Add MCP server to VS Code", icon: "i-simple-icons-visualstudiocode", to: install.vscode, external: true },
44
+ ...server.guide ? [{ label: "Set up other AI tools", icon: "i-lucide-book-open", to: server.guide }] : [],
45
+ ]
46
+ }
47
+
48
+ const items = computed(() => {
49
+ const page = links.value
50
+ if (!page) return []
51
+
52
+ return [
53
+ [
54
+ { label: "View as Markdown", icon: "i-simple-icons-markdown", to: page.markdownPath, target: "_blank", external: true },
55
+ {
56
+ label: "Copy Markdown URL",
57
+ icon: "i-lucide-link",
58
+ onSelect: () => copyText(page.markdownUrl, "Markdown URL copied"),
59
+ },
60
+ { label: "Open in ChatGPT", icon: "i-simple-icons-openai", to: page.chatGptUrl, target: "_blank" },
61
+ { label: "Open in Claude", icon: "i-simple-icons-anthropic", to: page.claudeUrl, target: "_blank" },
62
+ ],
63
+ ...mcp ? [mcpItems(mcp)] : [],
64
+ ]
65
+ })
66
+ </script>
67
+
68
+ <template>
69
+ <!-- `contents` keeps the group a direct flex item of the page header. -->
70
+ <div v-if="links" class="contents">
71
+ <UFieldGroup size="sm" @click.capture="openPendingMenu" @keydown.capture="openPendingMenu">
72
+ <CopyButton
73
+ :value="pageMarkdown"
74
+ label="Copy page"
75
+ variant="outline"
76
+ aria-label="Copy page as Markdown"
77
+ class="vh-page-action"
78
+ @error="copyPageFailed"
79
+ />
80
+
81
+ <!-- The menu and its Reka parts load once the page is idle, so they stay out of the JS that every page waits for. -->
82
+ <LazyUDropdownMenu
83
+ v-model:open="menuOpen"
84
+ hydrate-on-idle
85
+ size="sm"
86
+ :items="items"
87
+ :content="{ align: 'end', side: 'bottom', sideOffset: 8 }"
88
+ :ui="withDocsTheme('dropdownMenu', { item: 'pointer-coarse:min-h-11 pointer-coarse:items-center' })"
89
+ @hydrated="menuHydrated = true"
90
+ >
91
+ <UButton
92
+ icon="i-lucide-chevron-down"
93
+ variant="outline"
94
+ aria-label="More page actions"
95
+ class="vh-page-action vh-page-action-more"
96
+ />
97
+ </LazyUDropdownMenu>
98
+ </UFieldGroup>
99
+ </div>
100
+ </template>
101
+
102
+ <style scoped>
103
+ /* On touch screens the 28px buttons take taps from a 44px area. The visible buttons keep their size. */
104
+ @media (pointer: coarse) {
105
+ .vh-page-action {
106
+ position: relative;
107
+ }
108
+
109
+ .vh-page-action::before {
110
+ position: absolute;
111
+ inset: -8px 0;
112
+ content: "";
113
+ }
114
+
115
+ /* The menu button is 29px wide, and nothing sits to its right. */
116
+ .vh-page-action-more::before {
117
+ inset: -8px -15px -8px 0;
118
+ }
119
+ }
120
+ </style>