@vite-hub/docs 0.4.1 → 0.5.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.
- package/README.md +164 -6
- package/dist/{assistant-pages-BN7hNsSZ.js → assistant-pages-CqNlHsx-.js} +1 -1
- package/dist/{assistant-shared-WzButktj.js → assistant-shared-DhiLHKSl.js} +2 -2
- package/dist/assistant-worker.js +1 -1
- package/dist/assistant.js +1 -1
- package/dist/{content-CPZGnn3S.js → content-BQVlMshL.js} +55 -15
- package/dist/{draft-BjWmaiLn.js → draft-CSsTYSeb.js} +2 -2
- package/dist/{error-diagnostics-B_ZOy7kF.js → error-diagnostics-CmgtG9xa.js} +64 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +4 -4
- package/dist/link-checker-redirects.js +1 -1
- package/dist/{manifest-CMoxcwPm.d.ts → manifest-Drbdw1us.d.ts} +1 -1
- package/dist/{manifest-ZdxLrcvt.js → manifest-DvECmwX-.js} +62 -26
- package/dist/{markdown-DUWnEMPp.js → markdown-1M1FbjCw.js} +1 -1
- package/dist/{page-Dx2JD3y1.d.ts → markdown-BiKrT08O.d.ts} +2 -25
- package/dist/navigation.d.ts +9 -3
- package/dist/navigation.js +22 -8
- package/dist/{nuxt-CAGpKl_-.d.ts → nuxt-8O2OB_hI.d.ts} +80 -4
- package/dist/nuxt.d.ts +2 -2
- package/dist/nuxt.js +1269 -58
- package/dist/{page-GPt09oex.js → page-Bb0TfRKi.js} +19 -3
- package/dist/page-BryUCmYf.d.ts +26 -0
- package/dist/primitive-rail.d.ts +1 -4
- package/dist/primitive-rail.js +1 -4
- package/dist/{redirects-CmR1yu5A.js → redirects-BJj58IsY.js} +34 -21
- package/dist/runnable.d.ts +37 -0
- package/dist/runnable.js +105 -0
- package/dist/runtime/app/components/DocsAsideLeftBody.vue +2 -8
- package/dist/runtime/app/components/DocsLearn.vue +215 -0
- package/dist/runtime/app/components/DocsLearnCodePre.vue +98 -0
- package/dist/runtime/app/components/DocsLearnFile.vue +21 -0
- package/dist/runtime/app/components/DocsPage.vue +11 -5
- package/dist/runtime/app/components/DocsPlayground.vue +117 -0
- package/dist/runtime/app/components/content/Example.vue +18 -49
- package/dist/runtime/app/components/content/PageList.vue +1 -5
- package/dist/runtime/app/layouts/docs.vue +36 -8
- package/dist/runtime/app/middleware/docs-layout.ts +2 -2
- package/dist/runtime/app/utils/docs-learn.ts +31 -0
- package/dist/runtime/app/utils/docs-playground.ts +3 -0
- package/dist/runtime/server/llms.js +1 -1
- package/dist/runtime/server/markdown.d.ts +0 -5
- package/dist/runtime/server/markdown.js +10 -1
- package/dist/runtime/server/mcp.js +1 -1
- package/dist/runtime/server/page.d.ts +1 -1
- package/dist/runtime/server/page.js +3 -3
- package/dist/runtime/server/raw.js +2 -9
- package/dist/runtime/server/search.d.ts +1 -1
- package/dist/runtime/server/search.js +3 -2
- package/dist/runtime/server/sitemap.js +1 -1
- package/dist/{schema-DwpXW0VZ.js → schema-DcWZ3Q3M.js} +97 -5
- package/dist/server.d.ts +3 -2
- package/dist/server.js +3 -3
- package/dist/snapshot-worker.mjs +40 -0
- package/dist/steps-DBlkJwtD.d.ts +105 -0
- package/dist/steps-DF-11dJn.js +32 -0
- package/dist/{types-BhG6vGfG.d.ts → types-CHU_fy9l.d.ts} +69 -4
- package/package.json +17 -10
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { WorkspaceFileLink } from "@vite-hub/ui/workspace"
|
|
3
|
+
|
|
4
|
+
defineProps<{ path: string }>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<WorkspaceFileLink :path="path" class="vh-docs-learn-file"><slot /></WorkspaceFileLink>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<style scoped>
|
|
12
|
+
.vh-docs-learn-file {
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
text-decoration: underline dotted var(--ui-border-accented);
|
|
15
|
+
text-underline-offset: 0.25em;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.vh-docs-learn-file:hover {
|
|
19
|
+
text-decoration-color: var(--ui-text-muted);
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { camelize, capitalize } from "vue"
|
|
3
3
|
import { pageBlocks } from "#docs/components"
|
|
4
|
-
import { docsAppPath, docsRawPath, normalizeDocsPath } from "#docs/navigation"
|
|
4
|
+
import { docsAppPath, docsRawPath, isDocsWorkspaceLayout, normalizeDocsPath } from "#docs/navigation"
|
|
5
5
|
import { articleLayout } from "#docs/shell"
|
|
6
|
+
import workspaces from "#docs/workspaces"
|
|
6
7
|
|
|
7
8
|
import type { Node as ComarkNode } from "comark"
|
|
8
9
|
import type { DocsDocument, DocsPageResponse } from "@vite-hub/docs"
|
|
@@ -20,15 +21,17 @@ const { page } = response
|
|
|
20
21
|
const isRoot = page.path === manifest.root?.path
|
|
21
22
|
// A page that `start.links` lists opens inside the start section, like the pages of a section.
|
|
22
23
|
const isStartLink = isDocsStartLink(useDocsConfig(), page.path)
|
|
24
|
+
const loadWorkspace = isDocsWorkspaceLayout(page.layout) ? workspaces[page.path] : undefined
|
|
25
|
+
const workspace = loadWorkspace && (await loadWorkspace()).default
|
|
23
26
|
// 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
|
|
27
|
+
const layout = isDocsWorkspaceLayout(page.layout) || (page.layout !== "home" && (response.section || isRoot || isStartLink)) ? "docs" : articleLayout
|
|
25
28
|
if (import.meta.client && route.meta.layout !== layout) {
|
|
26
29
|
// The server has already rendered the manifest's layout. Finish hydrating it before switching shells.
|
|
27
30
|
if (useNuxtApp().isHydrating) onNuxtReady(() => setPageLayout(layout))
|
|
28
31
|
else setPageLayout(layout)
|
|
29
32
|
}
|
|
30
33
|
// 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"
|
|
34
|
+
const isStandalone = !response.section && !isRoot && !isStartLink && page.layout !== "home" && !isDocsWorkspaceLayout(page.layout)
|
|
32
35
|
|
|
33
36
|
// A home page draws the app's `components/content/` blocks at full width. The Markdown between two of them, such as a
|
|
34
37
|
// heading and a list, goes in one column with the prose styles of a docs page.
|
|
@@ -66,13 +69,16 @@ useDocsSeo({
|
|
|
66
69
|
description: page.seo?.description ?? page.description,
|
|
67
70
|
section: section && { title: section.title, path: docsAppPath(section.path, appBase) },
|
|
68
71
|
image: indexed ? page.seo?.image : false,
|
|
69
|
-
type: isRoot || page.layout === "landing" || page.layout === "home" ? "page" : "article",
|
|
72
|
+
type: isRoot || page.layout === "landing" || page.layout === "home" || page.layout === "playground" ? "page" : "article",
|
|
70
73
|
})
|
|
71
74
|
</script>
|
|
72
75
|
|
|
73
76
|
<template>
|
|
74
77
|
<!-- The layout's UMain is the page's only main landmark. -->
|
|
75
|
-
<
|
|
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" />
|
|
80
|
+
|
|
81
|
+
<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">
|
|
76
82
|
<UPageHeader
|
|
77
83
|
:headline="page.eyebrow ?? undefined"
|
|
78
84
|
:title="page.sourceTitle"
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { defineAsyncComponent } from "vue"
|
|
3
|
+
import { render, webContainer, Workspace, type WorkspaceExample, type WorkspaceRunner, type WorkspaceSnapshot } from "@vite-hub/ui/workspace"
|
|
4
|
+
import { fetchSnapshot } from "@vite-hub/web-container"
|
|
5
|
+
import { defineConnect, type ConnectConfig } from "@vite-hub/web-container/connect"
|
|
6
|
+
import { docsAppPath } from "#docs/navigation"
|
|
7
|
+
import { docsPlaygroundExampleQuery } from "../utils/docs-playground"
|
|
8
|
+
|
|
9
|
+
import type { DocsWorkspaceData } from "#docs/runnable"
|
|
10
|
+
import type { DocsPageResponse } from "@vite-hub/docs"
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{ response: DocsPageResponse, data: Exclude<DocsWorkspaceData, { layout: "learn" }> }>()
|
|
13
|
+
const route = useRoute()
|
|
14
|
+
const router = useRouter()
|
|
15
|
+
const { page } = props.response
|
|
16
|
+
const { appBase, site } = useDocsConfig()
|
|
17
|
+
|
|
18
|
+
const snapshots = new Map<string, WorkspaceSnapshot>()
|
|
19
|
+
const snapshotOf = new Map<string, string>()
|
|
20
|
+
const examples: WorkspaceExample[] = props.data.examples.map(({ snapshot: prebuilt, snapshotOf: key, ...example }) => {
|
|
21
|
+
if (key && prebuilt && !snapshots.has(key)) {
|
|
22
|
+
snapshots.set(key, () => fetchSnapshot(prebuilt.parts, { cache: `vitehub-tutorial-${key}`, sha256: prebuilt.sha256 }))
|
|
23
|
+
}
|
|
24
|
+
if (key) snapshotOf.set(example.id, key)
|
|
25
|
+
return example
|
|
26
|
+
})
|
|
27
|
+
const connectConfig: ConnectConfig = {}
|
|
28
|
+
for (const name of props.data.connect ?? []) connectConfig[name] = true
|
|
29
|
+
const connect = props.data.connect?.length ? defineConnect(connectConfig) : undefined
|
|
30
|
+
const load = props.data.render
|
|
31
|
+
const runner: WorkspaceRunner = load
|
|
32
|
+
? render(async (files, context) => (await load()).default(files, context))
|
|
33
|
+
: webContainer({ connect, port: props.data.port, snapshot: example => snapshots.get(snapshotOf.get(example.id) ?? "") })
|
|
34
|
+
const zipPrefix = site.name.toLowerCase().replace(/[^a-z\d]+/g, "-").replace(/^-|-$/g, "")
|
|
35
|
+
const tabs = (props.data.tabs ?? []).map(tab => ({ value: tab.value, label: tab.label, component: defineAsyncComponent(async () => (await tab.component()).default) }))
|
|
36
|
+
const tabItems = tabs.map(({ value, label }) => ({ value, label }))
|
|
37
|
+
|
|
38
|
+
const example = computed(() => [route.query.example, route.query.template].find((value): value is string => typeof value === "string" && examples.some(example => example.id === value)))
|
|
39
|
+
const open = ref(false)
|
|
40
|
+
|
|
41
|
+
function keep(id: string) {
|
|
42
|
+
void router.replace({ query: { ...route.query, example: docsPlaygroundExampleQuery(examples, id), template: undefined }, hash: "" })
|
|
43
|
+
}
|
|
44
|
+
function exampleHref(id: string) {
|
|
45
|
+
const query = docsPlaygroundExampleQuery(examples, id)
|
|
46
|
+
return docsAppPath(query ? `${page.path}?example=${encodeURIComponent(query)}` : page.path, appBase)
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<div class="vh-docs-workspace" :data-path="page.path">
|
|
52
|
+
<Workspace
|
|
53
|
+
v-model:open="open"
|
|
54
|
+
:examples="examples"
|
|
55
|
+
:example="example"
|
|
56
|
+
:runner="runner"
|
|
57
|
+
:tabs="tabItems"
|
|
58
|
+
:start="examples.length > 1 && !example"
|
|
59
|
+
label="playground"
|
|
60
|
+
:name="zipPrefix"
|
|
61
|
+
@update:example="keep"
|
|
62
|
+
>
|
|
63
|
+
<template v-for="tab in tabs" :key="tab.value" #[tab.value]>
|
|
64
|
+
<component :is="tab.component" />
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<template #intro>
|
|
68
|
+
<h1 class="text-balance text-3xl font-semibold text-highlighted">{{ page.sourceTitle }}</h1>
|
|
69
|
+
<p v-if="page.description" class="mt-3 text-muted">{{ page.description }}</p>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<!-- Without the workspace, such as on a phone, the page shows its own text and the examples. -->
|
|
73
|
+
<template #fallback>
|
|
74
|
+
<UPageBody prose class="docs-content !px-0 !pb-0">
|
|
75
|
+
<DocsMarkdown :document="response.document" />
|
|
76
|
+
</UPageBody>
|
|
77
|
+
<h2 class="mt-10 text-lg font-semibold text-highlighted">Examples</h2>
|
|
78
|
+
<ul class="vh-docs-playground-list">
|
|
79
|
+
<li v-for="item in examples" :key="item.id">
|
|
80
|
+
<!-- A new document boots the example, as a link from another page does. -->
|
|
81
|
+
<a :href="exampleHref(item.id)" class="font-medium text-highlighted">{{ item.label }}</a>
|
|
82
|
+
<span v-if="item.description" class="text-muted">: {{ item.description }}</span>
|
|
83
|
+
</li>
|
|
84
|
+
</ul>
|
|
85
|
+
</template>
|
|
86
|
+
</Workspace>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<style scoped>
|
|
91
|
+
.vh-docs-workspace {
|
|
92
|
+
display: flex;
|
|
93
|
+
height: 100%;
|
|
94
|
+
min-height: 0;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.vh-docs-workspace :deep(.vh-workspace) {
|
|
99
|
+
flex: 1 1 0;
|
|
100
|
+
min-height: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.vh-docs-workspace :deep(.vh-workspace-gate-content) {
|
|
104
|
+
width: 100%;
|
|
105
|
+
max-width: calc(65ch + 2rem);
|
|
106
|
+
margin-inline: auto;
|
|
107
|
+
padding: 2.5rem 1rem 4rem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.vh-docs-playground-list {
|
|
111
|
+
margin-top: 0.75rem;
|
|
112
|
+
display: grid;
|
|
113
|
+
gap: 0.5rem;
|
|
114
|
+
padding-inline-start: 1.25rem;
|
|
115
|
+
list-style: disc;
|
|
116
|
+
}
|
|
117
|
+
</style>
|
|
@@ -23,24 +23,21 @@ const view = defineModel<"preview" | "code">("view", { default: "preview" })
|
|
|
23
23
|
const loader = props.name ? examples[props.name] : undefined
|
|
24
24
|
const live = loader ? defineAsyncComponent(loader) : undefined
|
|
25
25
|
const mounts = ref(0)
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// The
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
26
|
+
const views = ["preview", "code"] as const
|
|
27
|
+
|
|
28
|
+
// A segmented switch is a radio group: arrow keys move the choice and the focus, and only the checked radio is a tab
|
|
29
|
+
// stop. The motion layer moves the raised look from one radio to the other.
|
|
30
|
+
function onKeydown(event: KeyboardEvent) {
|
|
31
|
+
const step = { ArrowLeft: -1, ArrowUp: -1, ArrowRight: 1, ArrowDown: 1 }[event.key]
|
|
32
|
+
if (!step) return
|
|
33
|
+
event.preventDefault()
|
|
34
|
+
const group = event.currentTarget
|
|
35
|
+
const next = views[(views.indexOf(view.value) + step + views.length) % views.length]!
|
|
36
|
+
view.value = next
|
|
37
|
+
nextTick(() => {
|
|
38
|
+
if (group instanceof HTMLElement) group.querySelector<HTMLElement>(`[data-view="${next}"]`)?.focus()
|
|
39
|
+
})
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
// A switch in a hidden tab measures zero, so it's placed again, without sliding, whenever its size changes: when its
|
|
36
|
-
// tab opens or the font loads.
|
|
37
|
-
let resizes: ResizeObserver | undefined
|
|
38
|
-
watch(view, () => nextTick(() => place(true)))
|
|
39
|
-
onMounted(() => {
|
|
40
|
-
resizes = new ResizeObserver(() => place())
|
|
41
|
-
if (seg.value) resizes.observe(seg.value)
|
|
42
|
-
})
|
|
43
|
-
onBeforeUnmount(() => resizes?.disconnect())
|
|
44
41
|
</script>
|
|
45
42
|
|
|
46
43
|
<template>
|
|
@@ -55,10 +52,8 @@ onBeforeUnmount(() => resizes?.disconnect())
|
|
|
55
52
|
<UIcon name="i-lucide-rotate-ccw" class="size-3.5" />
|
|
56
53
|
Reset
|
|
57
54
|
</button>
|
|
58
|
-
<div
|
|
59
|
-
<
|
|
60
|
-
<button type="button" data-focus-inset data-view="preview" :aria-pressed="view === 'preview'" :class="{ 'is-unmeasured': !thumb }" @click="view = 'preview'">Preview</button>
|
|
61
|
-
<button type="button" data-focus-inset data-view="code" :aria-pressed="view === 'code'" :class="{ 'is-unmeasured': !thumb }" @click="view = 'code'">Code</button>
|
|
55
|
+
<div class="vh-seg" role="radiogroup" aria-label="View" @keydown="onKeydown">
|
|
56
|
+
<button v-for="name in views" :key="name" type="button" role="radio" data-focus-inset :data-view="name" :aria-checked="view === name" :tabindex="view === name ? 0 : -1" @click="view = name">{{ name === "preview" ? "Preview" : "Code" }}</button>
|
|
62
57
|
</div>
|
|
63
58
|
</div>
|
|
64
59
|
<div class="vh-example-body">
|
|
@@ -121,7 +116,7 @@ onBeforeUnmount(() => resizes?.disconnect())
|
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
|
|
124
|
-
/* A segmented switch: a muted track and a raised
|
|
119
|
+
/* A segmented switch: a muted track, and a raised look on the checked radio, which the motion layer moves. */
|
|
125
120
|
.vh-seg {
|
|
126
121
|
position: relative;
|
|
127
122
|
display: inline-flex;
|
|
@@ -130,17 +125,6 @@ onBeforeUnmount(() => resizes?.disconnect())
|
|
|
130
125
|
padding: 3px;
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
.vh-seg-thumb {
|
|
134
|
-
position: absolute;
|
|
135
|
-
top: 3px;
|
|
136
|
-
bottom: 3px;
|
|
137
|
-
left: 3px;
|
|
138
|
-
border-radius: 6px;
|
|
139
|
-
background: var(--vh-raised);
|
|
140
|
-
box-shadow: 0 0 0 1px var(--ui-border);
|
|
141
|
-
transition: transform 200ms var(--vh-ease-out), width 200ms var(--vh-ease-out);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
128
|
.vh-seg button {
|
|
145
129
|
position: relative;
|
|
146
130
|
border-radius: 6px;
|
|
@@ -152,13 +136,9 @@ onBeforeUnmount(() => resizes?.disconnect())
|
|
|
152
136
|
transition: color 150ms ease;
|
|
153
137
|
}
|
|
154
138
|
|
|
155
|
-
|
|
156
|
-
.vh-seg button.is-unmeasured[aria-pressed="true"] {
|
|
139
|
+
.vh-seg button[aria-checked="true"] {
|
|
157
140
|
background: var(--vh-raised);
|
|
158
141
|
box-shadow: 0 0 0 1px var(--ui-border);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.vh-seg button[aria-pressed="true"] {
|
|
162
142
|
color: var(--ui-text-highlighted);
|
|
163
143
|
}
|
|
164
144
|
|
|
@@ -168,7 +148,6 @@ onBeforeUnmount(() => resizes?.disconnect())
|
|
|
168
148
|
}
|
|
169
149
|
}
|
|
170
150
|
|
|
171
|
-
|
|
172
151
|
/* Touch screens get 44px targets. */
|
|
173
152
|
@media (pointer: coarse) {
|
|
174
153
|
.vh-seg button {
|
|
@@ -181,16 +160,6 @@ onBeforeUnmount(() => resizes?.disconnect())
|
|
|
181
160
|
}
|
|
182
161
|
}
|
|
183
162
|
|
|
184
|
-
.vh-seg-thumb.is-still {
|
|
185
|
-
transition: none;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
@media (prefers-reduced-motion: reduce) {
|
|
189
|
-
.vh-seg-thumb {
|
|
190
|
-
transition: none;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
163
|
/* The preview sits in a hairline frame. The source shows in its own code block. */
|
|
195
164
|
.vh-example[data-view="preview"] > .vh-example-body:has(> .docs-example-preview) > :deep(:not(.docs-example-preview)),
|
|
196
165
|
.vh-example[data-view="code"] > .vh-example-body > :deep(.docs-example-preview) {
|
|
@@ -186,7 +186,7 @@ const groups = computed(() => {
|
|
|
186
186
|
.vh-page-list-arrow {
|
|
187
187
|
flex: none;
|
|
188
188
|
color: var(--ui-text-dimmed);
|
|
189
|
-
transition:
|
|
189
|
+
transition: color 150ms ease;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
@media (hover: hover) {
|
|
@@ -198,9 +198,5 @@ const groups = computed(() => {
|
|
|
198
198
|
.vh-page-list-link:hover .vh-page-list-arrow {
|
|
199
199
|
color: var(--ui-text-highlighted);
|
|
200
200
|
}
|
|
201
|
-
|
|
202
|
-
.vh-page-list-link:hover .vh-page-list-arrow {
|
|
203
|
-
transform: translateX(2px);
|
|
204
|
-
}
|
|
205
201
|
}
|
|
206
202
|
</style>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { isDocsWorkspaceLayout } from "#docs/navigation"
|
|
3
|
+
|
|
2
4
|
const { banner } = useDocsConfig()
|
|
3
5
|
const found = useDocsPage()
|
|
4
6
|
// A tutorial with a code panel uses the whole page column, half for prose and half for files.
|
|
@@ -6,6 +8,10 @@ const hasCodePanel = computed(() => found.value?.page.codePanel === true)
|
|
|
6
8
|
// Pages show the sidebar unless they set `sidebar: false`. A page with `sidebar: "collapsed"`, and a code panel tutorial,
|
|
7
9
|
// shows a narrow strip until the reader opens the sidebar.
|
|
8
10
|
const sidebar = useDocsSidebar()
|
|
11
|
+
// A `playground` or `learn` page, and an app page that sets `sidebar: "collapsed"` in its page meta, fill the viewport
|
|
12
|
+
// under the header. Markdown pages with a collapsed sidebar, and code panel tutorials, keep the window scroll.
|
|
13
|
+
const route = useRoute()
|
|
14
|
+
const fills = computed(() => isDocsWorkspaceLayout(found.value?.page.layout) || (sidebar.value.collapsible && route.meta.sidebar === "collapsed"))
|
|
9
15
|
|
|
10
16
|
// The sidebar sits on the left edge of the viewport on every docs page. The page content centers in the remaining space.
|
|
11
17
|
const docsShellUi = {
|
|
@@ -29,15 +35,20 @@ const docsShellUi = {
|
|
|
29
35
|
</UPageAside>
|
|
30
36
|
</template>
|
|
31
37
|
|
|
32
|
-
<!-- The
|
|
33
|
-
<div id="docs-content" tabindex="-1" class="
|
|
34
|
-
|
|
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>
|
|
38
|
+
<!-- The window does not scroll. A page that is taller than the viewport, such as the playground intro on a phone, scrolls in here. -->
|
|
39
|
+
<div v-if="fills" id="docs-content" tabindex="-1" class="vh-docs-fill">
|
|
40
|
+
<slot />
|
|
39
41
|
</div>
|
|
40
|
-
<
|
|
42
|
+
<template v-else>
|
|
43
|
+
<!-- The banner spans the page column, so its border meets the sidebar and the right edge. -->
|
|
44
|
+
<div id="docs-content" tabindex="-1" class="relative">
|
|
45
|
+
<!-- 40px including the border, the same height as the sidebar search, so both bottom rules line up. It grows when the text wraps. -->
|
|
46
|
+
<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">
|
|
47
|
+
<span class="text-muted">{{ banner }}</span>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<slot />
|
|
51
|
+
</template>
|
|
41
52
|
</UPage>
|
|
42
53
|
</UMain>
|
|
43
54
|
</DocsAppShell>
|
|
@@ -63,6 +74,16 @@ const docsShellUi = {
|
|
|
63
74
|
transform: none;
|
|
64
75
|
}
|
|
65
76
|
|
|
77
|
+
/* One cell as tall as the viewport under the header. The root of the page is exactly that size, so `height: 100%` inside it
|
|
78
|
+
fills the viewport. Content that is taller scrolls in here. */
|
|
79
|
+
.vh-docs-fill {
|
|
80
|
+
display: grid;
|
|
81
|
+
height: calc(100dvh - var(--ui-header-height));
|
|
82
|
+
grid-template-columns: minmax(0, 1fr);
|
|
83
|
+
grid-template-rows: minmax(0, 1fr);
|
|
84
|
+
overflow: auto;
|
|
85
|
+
}
|
|
86
|
+
|
|
66
87
|
@media (min-width: 64rem) {
|
|
67
88
|
/* Beside a tutorial the navigation is a short page list, so its panel is narrower and the prose and code keep the width. */
|
|
68
89
|
/* The sum is set again here, because a custom property resolves its calc() where it is declared. */
|
|
@@ -102,3 +123,10 @@ const docsShellUi = {
|
|
|
102
123
|
}
|
|
103
124
|
|
|
104
125
|
</style>
|
|
126
|
+
|
|
127
|
+
<style>
|
|
128
|
+
/* The fill column scrolls instead of the window. */
|
|
129
|
+
:root:has(.vh-docs-fill) {
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineNuxtRouteMiddleware, isDocsStartLink, navigateTo, useDocsConfig, useRuntimeConfig } from "#imports"
|
|
2
2
|
import manifest from "#docs/manifest"
|
|
3
3
|
import panels from "#docs/panels"
|
|
4
|
-
import { docsAppPath, docsSectionForPath, findDocsPage, loadDocsPanels } from "#docs/navigation"
|
|
4
|
+
import { docsAppPath, docsSectionForPath, findDocsPage, isDocsWorkspaceLayout, loadDocsPanels } from "#docs/navigation"
|
|
5
5
|
import { articleLayout } from "#docs/shell"
|
|
6
6
|
|
|
7
7
|
// A docs page renders in the docs shell whichever app page serves its path. A page outside the docs base, such as
|
|
@@ -12,7 +12,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
|
12
12
|
// The pages inside a panel load when the reader opens it, before anything reads the manifest for this route.
|
|
13
13
|
await loadDocsPanels(manifest, to.path, panels)
|
|
14
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
|
|
15
|
+
if (found) to.meta.layout = isDocsWorkspaceLayout(found.page.layout) || (found.page.layout !== "home" && (found.section || found.page.path === manifest.root?.path || isDocsStartLink(useDocsConfig(), to.path))) ? "docs" : articleLayout
|
|
16
16
|
// A new page that exists only as a Content draft renders in the shell of its section.
|
|
17
17
|
else if (docsSectionForPath(manifest, to.path)) to.meta.layout = "docs"
|
|
18
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
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { InjectionKey } from "vue"
|
|
2
|
+
import type { Node as ComarkNode } from "comark"
|
|
3
|
+
|
|
4
|
+
export interface DocsLearnActions {
|
|
5
|
+
available: boolean
|
|
6
|
+
running: boolean
|
|
7
|
+
paths: readonly string[]
|
|
8
|
+
show: (path: string) => void
|
|
9
|
+
run: (command: string) => Promise<string>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const docsLearnActionsKey: InjectionKey<DocsLearnActions> = Symbol("docs-learn-actions")
|
|
13
|
+
|
|
14
|
+
export function docsLearnGuideNodes(nodes: readonly ComarkNode[], paths: ReadonlySet<string>): ComarkNode[] {
|
|
15
|
+
const link = (node: ComarkNode): ComarkNode => {
|
|
16
|
+
if (typeof node === "string" || node[0] === null || node[0] === "pre") return node
|
|
17
|
+
const [tag, attributes, ...children] = node
|
|
18
|
+
if (tag === "code" && children.length === 1 && typeof children[0] === "string" && paths.has(children[0])) {
|
|
19
|
+
return ["docs-learn-file", { path: children[0] }, node]
|
|
20
|
+
}
|
|
21
|
+
return [tag, attributes, ...children.map(link)]
|
|
22
|
+
}
|
|
23
|
+
return nodes.map(link)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function docsLearnStepNodes(step: ComarkNode | undefined): ComarkNode[] {
|
|
27
|
+
if (!step || typeof step === "string" || step[0] === null) return []
|
|
28
|
+
const [, , ...children] = step
|
|
29
|
+
const [first, ...rest] = children
|
|
30
|
+
return first !== undefined && typeof first !== "string" && first[0] === "h2" ? rest : children
|
|
31
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as docsContent } from "../../content-
|
|
1
|
+
import { n as docsContent } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { defineContentLlmsHandler } from "@vite-hub/content";
|
|
3
3
|
//#region src/runtime/server/llms.ts
|
|
4
4
|
/** `/llms.txt`, `/llms-full.txt`, and `/sitemap.md`, from Content. The build prerenders them. */
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { ContentMiddleware } from "@vite-hub/content/markdown";
|
|
2
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
3
|
declare const handler: ContentMiddleware;
|
|
9
4
|
//#endregion
|
|
10
5
|
export { handler as default };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { docsAppPath } from "../../navigation.js";
|
|
2
|
+
import { useRuntimeConfig } from "nitro/runtime-config";
|
|
1
3
|
import { defineContentMarkdownHandler } from "@vite-hub/content/markdown";
|
|
2
4
|
import { serverFetch } from "nitro";
|
|
3
5
|
//#region src/runtime/server/markdown.ts
|
|
@@ -6,6 +8,13 @@ import { serverFetch } from "nitro";
|
|
|
6
8
|
* Content converts the HTML that Nitro renders for the same request. nuxt-agent-discovery answers the docs pages first.
|
|
7
9
|
* Content loads on the first request that asks for Markdown or gets an HTML page.
|
|
8
10
|
*/
|
|
9
|
-
const
|
|
11
|
+
const markdown = defineContentMarkdownHandler(() => import("../../content-BQVlMshL.js").then((n) => n.t).then((module) => module.docsMarkdownContent()), { render: (request) => serverFetch(request) });
|
|
12
|
+
const rawMarkdown = defineContentMarkdownHandler(() => import("../../content-BQVlMshL.js").then((n) => n.t).then((module) => module.docsMarkdownContent(true)));
|
|
13
|
+
const handler = async (event, next) => {
|
|
14
|
+
const path = new URL(event.req.url).pathname;
|
|
15
|
+
const raw = docsAppPath("/raw/", useRuntimeConfig().public.docs.appBase);
|
|
16
|
+
if (path.startsWith(raw) && path.endsWith(".md")) return await rawMarkdown(event, next);
|
|
17
|
+
return await markdown(event, next);
|
|
18
|
+
};
|
|
10
19
|
//#endregion
|
|
11
20
|
export { handler as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as docsContent } from "../../content-
|
|
1
|
+
import { n as docsContent } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { defineContentMcpHandler } from "@vite-hub/content";
|
|
3
3
|
//#region src/runtime/server/mcp.ts
|
|
4
4
|
/** The docs MCP server at `/mcp`, with the `list-pages` and `get-page` tools of Content. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DocsPageResponse } from "../../page-
|
|
1
|
+
import { n as DocsPageResponse } from "../../page-BryUCmYf.js";
|
|
2
2
|
import { EventHandler, EventHandlerRequest } from "nitro/h3";
|
|
3
3
|
//#region src/runtime/server/page.d.ts
|
|
4
4
|
/** `/api/_docs/page/docs/kv.json` is the page at `/docs/kv`. The `.json` suffix lets static hosts store every page beside its folder. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as parseDocsDocument, r as readDocsPage } from "../../content-
|
|
1
|
+
import { a as parseDocsDocument, r as readDocsPage } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { findDocsPage } from "../../navigation.js";
|
|
3
|
-
import { i as docsPageResponse } from "../../page-
|
|
3
|
+
import { i as docsPageResponse } from "../../page-Bb0TfRKi.js";
|
|
4
4
|
import manifest from "#docs/manifest";
|
|
5
5
|
import { HTTPError, defineHandler, getRouterParam } from "nitro/h3";
|
|
6
6
|
import { content } from "#docs/content";
|
|
@@ -9,7 +9,7 @@ import { content } from "#docs/content";
|
|
|
9
9
|
const handler = defineHandler(async (event) => {
|
|
10
10
|
const path = `/${(getRouterParam(event, "_") ?? "").replace(/\.json$/, "")}`;
|
|
11
11
|
if (content && (content.preview.active() || content.preview.frame())) {
|
|
12
|
-
const { docsDraftResponse } = await import("../../draft-
|
|
12
|
+
const { docsDraftResponse } = await import("../../draft-CSsTYSeb.js");
|
|
13
13
|
const draft = await docsDraftResponse(content, manifest, path, parseDocsDocument);
|
|
14
14
|
if (draft) {
|
|
15
15
|
event.res.headers.set("cache-control", "private, no-store");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as readDocsRawCopy } from "../../content-
|
|
1
|
+
import { i as readDocsRawCopy } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { HTTPError, defineHandler } from "nitro/h3";
|
|
3
3
|
//#region src/runtime/server/raw.ts
|
|
4
4
|
/**
|
|
@@ -7,14 +7,7 @@ import { HTTPError, defineHandler } from "nitro/h3";
|
|
|
7
7
|
* fetch the copy inside the server, from this route.
|
|
8
8
|
*/
|
|
9
9
|
const handler = defineHandler(async (event) => {
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
path = decodeURIComponent(event.url.pathname);
|
|
13
|
-
} catch {
|
|
14
|
-
throw HTTPError.status(404, "Page not found");
|
|
15
|
-
}
|
|
16
|
-
const index = path.indexOf("/raw/");
|
|
17
|
-
const markdown = index < 0 || !path.endsWith(".md") ? null : await readDocsRawCopy(path.slice(index));
|
|
10
|
+
const markdown = await readDocsRawCopy(new URL(event.req.url).pathname);
|
|
18
11
|
if (markdown === null) throw HTTPError.status(404, "Page not found");
|
|
19
12
|
event.res.headers.set("content-type", "text/markdown; charset=utf-8");
|
|
20
13
|
return markdown;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as DocsSearchSection } from "../../types-CHU_fy9l.js";
|
|
2
2
|
import { EventHandler, EventHandlerRequest } from "nitro/h3";
|
|
3
3
|
//#region src/runtime/server/search.d.ts
|
|
4
4
|
declare const handler: EventHandler<EventHandlerRequest, Promise<DocsSearchSection[]>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as readDocsPage } from "../../content-
|
|
1
|
+
import { r as readDocsPage } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { docsIndexedPages, docsManifestPages, docsUnindexedSearchSections } from "../../navigation.js";
|
|
3
|
-
import { a as docsSearchSections } from "../../markdown-
|
|
3
|
+
import { a as docsSearchSections } from "../../markdown-1M1FbjCw.js";
|
|
4
4
|
import manifest from "#docs/manifest";
|
|
5
5
|
import { defineHandler } from "nitro/h3";
|
|
6
6
|
//#region src/runtime/server/search.ts
|
|
@@ -8,6 +8,7 @@ import { defineHandler } from "nitro/h3";
|
|
|
8
8
|
async function buildIndex() {
|
|
9
9
|
const sections = [];
|
|
10
10
|
for (const page of docsIndexedPages(manifest)) {
|
|
11
|
+
if (!page.navigation) continue;
|
|
11
12
|
const document = await readDocsPage(page);
|
|
12
13
|
if (!document) continue;
|
|
13
14
|
const [entry, ...headings] = docsSearchSections(page.path, page.sourceTitle, document.nodes);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as docsContent } from "../../content-
|
|
1
|
+
import { n as docsContent } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { docsCanonicalUrl } from "../../navigation.js";
|
|
3
3
|
import { useRuntimeConfig } from "nitro/runtime-config";
|
|
4
4
|
import { defineHandler } from "nitro/h3";
|