@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.
- package/LICENSE +201 -0
- package/README.md +456 -0
- package/dist/agent-copy-xPaWye_g.js +33 -0
- package/dist/assistant-pages-BN7hNsSZ.js +37 -0
- package/dist/assistant-shared-CWIKRtBv.d.ts +28 -0
- package/dist/assistant-shared-WzButktj.js +113 -0
- package/dist/assistant-worker.d.ts +11 -0
- package/dist/assistant-worker.js +16 -0
- package/dist/assistant.d.ts +14 -0
- package/dist/assistant.js +19 -0
- package/dist/content-CPZGnn3S.js +141 -0
- package/dist/draft-BjWmaiLn.js +45 -0
- package/dist/error-diagnostics-B_ZOy7kF.js +93 -0
- package/dist/files-UY4h1_36.js +38 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +27 -0
- package/dist/link-checker-redirects.d.ts +13 -0
- package/dist/link-checker-redirects.js +25 -0
- package/dist/manifest-CMoxcwPm.d.ts +80 -0
- package/dist/manifest-ZdxLrcvt.js +434 -0
- package/dist/markdown-DUWnEMPp.js +378 -0
- package/dist/navigation.d.ts +283 -0
- package/dist/navigation.js +519 -0
- package/dist/nuxt-CAGpKl_-.d.ts +241 -0
- package/dist/nuxt.d.ts +3 -0
- package/dist/nuxt.js +1868 -0
- package/dist/page-Dx2JD3y1.d.ts +74 -0
- package/dist/page-GPt09oex.js +82 -0
- package/dist/primitive-rail.d.ts +110 -0
- package/dist/primitive-rail.js +289 -0
- package/dist/raw-BChwipz_.js +857 -0
- package/dist/redirects-CmR1yu5A.js +74 -0
- package/dist/runtime/app/app.vue +11 -0
- package/dist/runtime/app/assistant/DocsAssistant.vue +81 -0
- package/dist/runtime/app/assistant/DocsAssistantOff.vue +8 -0
- package/dist/runtime/app/assistant/DocsAssistantPanel.vue +322 -0
- package/dist/runtime/app/components/AppHeader.vue +368 -0
- package/dist/runtime/app/components/AppSearch.vue +68 -0
- package/dist/runtime/app/components/DocsAppShell.vue +62 -0
- package/dist/runtime/app/components/DocsArticle.vue +184 -0
- package/dist/runtime/app/components/DocsAsideFooter.vue +94 -0
- package/dist/runtime/app/components/DocsAsideLeftBody.vue +584 -0
- package/dist/runtime/app/components/DocsAsideLeftTop.vue +132 -0
- package/dist/runtime/app/components/DocsBrandMark.vue +52 -0
- package/dist/runtime/app/components/DocsCatalogFooter.vue +129 -0
- package/dist/runtime/app/components/DocsCodePanel.vue +388 -0
- package/dist/runtime/app/components/DocsCodePre.vue +120 -0
- package/dist/runtime/app/components/DocsHeaderActions.vue +4 -0
- package/dist/runtime/app/components/DocsLanding.vue +83 -0
- package/dist/runtime/app/components/DocsMarkdown.vue +64 -0
- package/dist/runtime/app/components/DocsPage.vue +149 -0
- package/dist/runtime/app/components/DocsPageCredits.vue +41 -0
- package/dist/runtime/app/components/DocsPageHeaderLinks.vue +120 -0
- package/dist/runtime/app/components/DocsRail.vue +239 -0
- package/dist/runtime/app/components/DocsSidebarStrip.vue +81 -0
- package/dist/runtime/app/components/DocsSidebars.vue +63 -0
- package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +33 -0
- package/dist/runtime/app/components/content/AgentOnly.vue +9 -0
- package/dist/runtime/app/components/content/CodeTree.vue +203 -0
- package/dist/runtime/app/components/content/ComarkHtml.vue +31 -0
- package/dist/runtime/app/components/content/Correct.vue +17 -0
- package/dist/runtime/app/components/content/Example.vue +260 -0
- package/dist/runtime/app/components/content/ExamplePreview.vue +6 -0
- package/dist/runtime/app/components/content/Examples.vue +71 -0
- package/dist/runtime/app/components/content/Incorrect.vue +17 -0
- package/dist/runtime/app/components/content/McpClient.vue +170 -0
- package/dist/runtime/app/components/content/McpInstall.vue +238 -0
- package/dist/runtime/app/components/content/PageList.vue +206 -0
- package/dist/runtime/app/components/content/ProductFeatureItem.vue +43 -0
- package/dist/runtime/app/components/content/ProductFeatures.vue +17 -0
- package/dist/runtime/app/components/content/TutorialStep.vue +39 -0
- package/dist/runtime/app/composables/docs-assistant-problem.ts +59 -0
- package/dist/runtime/app/composables/docs-theme.ts +15 -0
- package/dist/runtime/app/composables/docs.ts +83 -0
- package/dist/runtime/app/composables/headerActions.ts +6 -0
- package/dist/runtime/app/composables/icons.ts +14 -0
- package/dist/runtime/app/composables/seo.ts +64 -0
- package/dist/runtime/app/composables/tutorial.ts +40 -0
- package/dist/runtime/app/composables/useDocsAssistant.ts +17 -0
- package/dist/runtime/app/error.vue +88 -0
- package/dist/runtime/app/layouts/default.vue +7 -0
- package/dist/runtime/app/layouts/docs.vue +104 -0
- package/dist/runtime/app/middleware/docs-layout.ts +23 -0
- package/dist/runtime/app/pages/docs-page.vue +3 -0
- package/dist/runtime/app/plugins/comark-css.ts +14 -0
- package/dist/runtime/app/plugins/icon-stroke.ts +12 -0
- package/dist/runtime/app/plugins/theme-color.ts +18 -0
- package/dist/runtime/app/utils/docs-theme.ts +43 -0
- package/dist/runtime/app/utils/file-tree.ts +40 -0
- package/dist/runtime/server/llms.d.ts +6 -0
- package/dist/runtime/server/llms.js +7 -0
- package/dist/runtime/server/markdown.d.ts +10 -0
- package/dist/runtime/server/markdown.js +11 -0
- package/dist/runtime/server/mcp.d.ts +6 -0
- package/dist/runtime/server/mcp.js +7 -0
- package/dist/runtime/server/page.d.ts +7 -0
- package/dist/runtime/server/page.js +27 -0
- package/dist/runtime/server/raw.d.ts +10 -0
- package/dist/runtime/server/raw.js +23 -0
- package/dist/runtime/server/search.d.ts +6 -0
- package/dist/runtime/server/search.js +32 -0
- package/dist/runtime/server/sitemap.d.ts +6 -0
- package/dist/runtime/server/sitemap.js +52 -0
- package/dist/runtime/server/trailing-slash.d.ts +10 -0
- package/dist/runtime/server/trailing-slash.js +28 -0
- package/dist/runtime/theme/design.css +464 -0
- package/dist/schema-DwpXW0VZ.js +98 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +5 -0
- package/dist/theme-BXyu4uFL.d.ts +32 -0
- package/dist/theme-DzC8LtMH.js +237 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +2 -0
- package/dist/types-BhG6vGfG.d.ts +212 -0
- package/package.json +144 -1
package/README.md
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
# @vite-hub/docs
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vite-hub/docs)
|
|
4
|
+
[](https://github.com/vite-hub/vitehub/blob/main/LICENSE)
|
|
5
|
+
[](https://vitehub.dev/docs/docs-site)
|
|
6
|
+
|
|
7
|
+
`@vite-hub/docs` turns a folder of Markdown files into a documentation site. It is a Nuxt module. It gives you the docs shell, four page layouts, search, a Markdown copy of each page for agents, llms.txt, an MCP server, and an optional docs assistant. [vitehub.dev](https://vitehub.dev) runs on it.
|
|
8
|
+
|
|
9
|
+
You write Markdown. The defaults give you a complete site. When a default does not fit, you change one option, one frontmatter field, or one component.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @vite-hub/docs nuxt @nuxt/ui tailwindcss comark @comark/vue @comark/html comark-ui
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// nuxt.config.ts
|
|
19
|
+
export default defineNuxtConfig({
|
|
20
|
+
modules: ["@vite-hub/docs/nuxt"],
|
|
21
|
+
docs: {
|
|
22
|
+
site: { name: "Acme", url: "https://docs.acme.dev" },
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The module installs Nuxt UI, `@vite-hub/ui`, `nuxt-agent-discovery`, and `nuxt-link-checker` for you, so a new site does not add them to `modules`. An app that already lists `@nuxt/ui` keeps it before the docs module, as in [Add docs to an existing app](#add-docs-to-an-existing-app). Content serves the agent files: `/raw/<page>.md`, `llms.txt`, `llms-full.txt`, `sitemap.md`, `sitemap.xml`, and the MCP server. Set `site.url` to the public origin: llms.txt, canonical links, and the raw Markdown links use it.
|
|
28
|
+
|
|
29
|
+
The shell uses Lucide, Simple Icons, and VS Code Icons. Install `@iconify-json/lucide`, `@iconify-json/simple-icons`, and `@iconify-json/vscode-icons` to serve them from your app. Without them, `@nuxt/icon` gets them from the Iconify API.
|
|
30
|
+
|
|
31
|
+
Apps that use `vite-hub` add `vite-hub/docs/nuxt` to `modules` in place of `@vite-hub/docs/nuxt`, and import the root and the assistant from `vite-hub/docs` and `vite-hub/docs/assistant`.
|
|
32
|
+
|
|
33
|
+
### Add docs to an existing app
|
|
34
|
+
|
|
35
|
+
Put the pages in `content/docs/`. The module serves them at `/docs`, and the rest of the site stays the app's:
|
|
36
|
+
|
|
37
|
+
```txt
|
|
38
|
+
content/docs/
|
|
39
|
+
index.md → /docs
|
|
40
|
+
guide/
|
|
41
|
+
index.md → /docs/guide
|
|
42
|
+
install.md → /docs/guide/install
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// nuxt.config.ts
|
|
47
|
+
export default defineNuxtConfig({
|
|
48
|
+
modules: ["@nuxt/ui", "@vite-hub/docs/nuxt"],
|
|
49
|
+
docs: { site: { name: "Acme", url: "https://acme.dev" } },
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- The docs page answers only below `/docs`. The app keeps its own pages, its layouts, and its error page, also next to its own `pages/[...slug].vue`.
|
|
54
|
+
- The app keeps its `app.vue`. The docs layouts draw the site header, the search, and the page head on docs pages only. The `app.vue` must wrap `<NuxtPage />` in `<UApp>` and `<NuxtLayout>`, as Nuxt UI and Nuxt layouts need. The development server warns when one is missing.
|
|
55
|
+
- The build prerenders every docs page and crawls nothing else, so the app's own pages stay server-rendered.
|
|
56
|
+
- The docs theme applies to the docs pages only. The app's pages keep its Nuxt UI theme. See [Theme](#theme).
|
|
57
|
+
|
|
58
|
+
## Content
|
|
59
|
+
|
|
60
|
+
```txt
|
|
61
|
+
content/
|
|
62
|
+
index.md → /
|
|
63
|
+
about.md → /about
|
|
64
|
+
docs/
|
|
65
|
+
index.md → /docs
|
|
66
|
+
guide/
|
|
67
|
+
.navigation.yml section title, icon, order, category, group, fold
|
|
68
|
+
index.md → /docs/guide
|
|
69
|
+
install.md → /docs/guide/install
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A page's URL is its path in the folder. With a `content/docs/` folder, the docs are at `/docs`. Without one, the docs are the whole site: `content/index.md` is `/`, and each folder in `content/` is a section. `content/docs/index.md` is the page at `/docs`. Without it, `/docs` is not found, and the Docs links open the first section. Each folder under `content/docs/` is a section: one entry in the rail and its own sidebar. A site with three sections or fewer, or with no section icons, has no rail: the sidebar lists every section with its pages. Pages outside `content/docs/`, such as `about.md`, render as plain articles under the site header. `dir` changes the content folder, and `base` sets the URL prefix of the sections when the default does not fit.
|
|
73
|
+
|
|
74
|
+
The module reads the folder at build time. In development it watches the folder. A body edit, a new or removed page, a title, or an order shows on the next page load without a restart, and the server code reloads once. The app restarts when adding or removing `content/docs/` changes the inferred base, or when a new page changes a route that the module adds at startup: the first page outside `/docs`, a page outside `/docs`, or any new page of an app with an `app.baseURL`, whose Markdown routes list each page. It also restarts for a new page when Nitro does not run in Vite (`experimental.nitroViteEnvironment: false`).
|
|
75
|
+
|
|
76
|
+
### Multiple sources and Markdown components
|
|
77
|
+
|
|
78
|
+
Read pages from more than one place with `sources`. It replaces `dir`. Each entry is a folder relative to the app root, a Source from `vite-hub/source`, such as `glob()` or `github()`, or `{ source, mount?, exclude?, frontmatter? }` with one of them. `mount` is the public path of the pages, `exclude` leaves out file globs, and `frontmatter` adapts metadata before schema validation.
|
|
79
|
+
|
|
80
|
+
The module reads the `.md` and `.navigation.yml` files of every source through ViteHub Content when it builds. In development the server reads folders through Nitro server assets, and the module watches them. The build copies the pages of any other Source into `.nuxt/docs/sources/docs-<index>/` and serves that copy, so a `github()` Source shows its branch as it was at build time. A production build packs the Markdown and rewritten agent copies into one gzip module to stay below Cloudflare’s module limit. A `glob()` Source lists dot files only when its `include` names them, such as `**/.navigation.yml`, and reads only below the app root.
|
|
81
|
+
|
|
82
|
+
`sources` configures the site pages, search, Markdown resources, and the pages that the docs assistant reads.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { github, glob } from "vite-hub/source"
|
|
86
|
+
|
|
87
|
+
export default defineNuxtConfig({
|
|
88
|
+
modules: ["@vite-hub/docs/nuxt"],
|
|
89
|
+
docs: {
|
|
90
|
+
base: "/",
|
|
91
|
+
sources: [
|
|
92
|
+
{ source: "pages", exclude: ["partials/**"] },
|
|
93
|
+
{ source: "../packages/zoom/docs", mount: "/zoom" },
|
|
94
|
+
{ source: glob({ cwd: "guides", include: ["**/*.md", "**/.navigation.yml"] }), mount: "/guides" },
|
|
95
|
+
{ source: github({ repo: "acme/api", root: "docs" }), mount: "/api" },
|
|
96
|
+
],
|
|
97
|
+
sections: { zoom: { category: "Packages", order: 1 } },
|
|
98
|
+
components: "./markdown-components.ts",
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`sections` overrides `.navigation.yml` fields by section id. A source's synchronous `frontmatter(data, { file, path, markdown })` callback can supply generated titles or migrate legacy fields. Its return value still passes the full docs schema. `file` stays relative to the source; `path` is the public page path.
|
|
104
|
+
|
|
105
|
+
The `components` module exports a default map of Comark tags to Vue components. Components passed directly to `DocsMarkdown` override that map. Both maps override app blocks in `components/content/`, which override the built-in Comark blocks and load on demand.
|
|
106
|
+
|
|
107
|
+
### Frontmatter
|
|
108
|
+
|
|
109
|
+
| Field | Default | Use |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| `title` | Required | Page heading and browser title. |
|
|
112
|
+
| `description` | None | Text under the heading, the meta description, and the llms.txt entry. |
|
|
113
|
+
| `tagline` | `description` | Text under the heading, when it must differ from the meta description. |
|
|
114
|
+
| `eyebrow` | none | A short label above the title, such as the package that the page documents. |
|
|
115
|
+
| `credits` | None | Inline Markdown at the end of the page, such as `Icons from [Lucide](https://lucide.dev).` |
|
|
116
|
+
| `keywords` | None | Words that find the page in search besides its own text: a list, or one string with commas. They rank below the page title and with headings. |
|
|
117
|
+
| `icon` | `i-lucide-file-text` | Sidebar icon, as an Iconify name. |
|
|
118
|
+
| `layout` | `article` | `article`, `tutorial`, `landing`, or `home`. |
|
|
119
|
+
| `sidebar` | `true` | `false` hides the left navigation on this page. `collapsed` starts it as a narrow column that the reader opens. |
|
|
120
|
+
| `toc` | `true`, `false` on `landing` | `false` hides the "On this page" outline. |
|
|
121
|
+
| `codePanel` | `false` | Tutorials only. Shows the files of the current step beside the prose. |
|
|
122
|
+
| `tutorial` | None | Tutorials only. `project` or `quickstart`, for your own tutorial catalog. |
|
|
123
|
+
| `navigation` | Listed | `false` keeps the page out of the sidebar. Or `{ title, order, group, kind, panel }`. See [Panels](#panels). |
|
|
124
|
+
| `seo` | None | `{ title, description, image, index }` for search results and shares when they must differ from the page. `image` is a path in `public/` or a URL, or `false` for no share image. `index: false` asks search engines not to index the page. See [Pages that search engines skip](#pages-that-search-engines-skip). |
|
|
125
|
+
|
|
126
|
+
Dotted keys work too, such as `navigation.order: 2`. A wrong field stops the build with `DOCS_CONTENT_INVALID`. In development, the terminal shows the error and the site keeps the last valid pages until you fix the file.
|
|
127
|
+
|
|
128
|
+
`.navigation.yml` in a section folder:
|
|
129
|
+
|
|
130
|
+
| Field | Use |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `title` | Section name. Defaults to the title of `index.md`, then to the folder name. |
|
|
133
|
+
| `icon` | Section icon. |
|
|
134
|
+
| `order` | Position in the rail. Lower comes first. |
|
|
135
|
+
| `category` | Rail group and catalog group. List the categories in the `categories` option to order them. |
|
|
136
|
+
| `group` | Title of the group of the section. See `groups`. |
|
|
137
|
+
| `fold` | `true` folds each page group of the sidebar. The group of the current page opens itself. |
|
|
138
|
+
| `related` | Section ids listed under Related in the sidebar. |
|
|
139
|
+
|
|
140
|
+
### Panels
|
|
141
|
+
|
|
142
|
+
A long list of pages, such as one page for each error code, would bury the other pages of a section. Set `navigation.panel: true` on the `index.md` of a folder inside the section, and the folder becomes a panel:
|
|
143
|
+
|
|
144
|
+
- The section sidebar shows one link to the panel, with the number of its pages, after the section pages.
|
|
145
|
+
- On a page of the panel, the sidebar lists only the panel: a link back to the section, the panel Overview, and its pages by `navigation.group`. Each group folds. A page title that is a code, such as `QUEUE_DISABLED`, shows in monospace on one line. Search finds the panel pages by title, so the panel has no filter of its own.
|
|
146
|
+
- The rail keeps the reader in the panel. On `/docs/queue/diagnostics/queue_disabled`, the KV item opens `/docs/kv/diagnostics` when that folder is a panel too, and `/docs/kv` when it is not.
|
|
147
|
+
- Previous and next stay inside the panel.
|
|
148
|
+
|
|
149
|
+
```md [content/docs/queue/diagnostics/index.md]
|
|
150
|
+
---
|
|
151
|
+
title: Queue diagnostics
|
|
152
|
+
navigation.title: Diagnostics
|
|
153
|
+
navigation.panel: true
|
|
154
|
+
---
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Pages that search engines skip
|
|
158
|
+
|
|
159
|
+
`seo.index: false` adds `<meta name="robots" content="noindex, follow">` and leaves the page out of `sitemap.xml`, llms.txt, `llms-full.txt`, and the share images. The site search lists it by its title and description only. The build does not prerender the page: the server renders it on request, so a site with thousands of generated pages builds as fast as before. Links to the page stay valid for the link checker, and its raw Markdown copy stays at `/raw/...`. Use it for long tails of thin pages, such as one page for each error code, and keep the page that lists them indexed.
|
|
160
|
+
|
|
161
|
+
## Layouts and rails
|
|
162
|
+
|
|
163
|
+
- `article` is prose with the outline on the right.
|
|
164
|
+
- `tutorial` numbers each `::tutorial-step` block. With `codePanel: true`, a sticky panel on wide screens shows the file tree and the file that the reader is on. Code blocks named `commands/...` or `output/...`, and shell blocks, stay in the prose.
|
|
165
|
+
- `landing` is a wide Overview page without the outline. A section Overview ends with the catalog of every section.
|
|
166
|
+
- `home` is a product home page under the site header, with no title, actions, sidebar, or outline. Your `components/content/` blocks, such as a `::product-hero`, take the full width. The Markdown between them, such as a heading, a list, or a code group, gets the prose styles and the width of a docs page. The page keeps its search entry, Markdown copy, and share image.
|
|
167
|
+
|
|
168
|
+
The left navigation (the section rail and the page sidebar) and the right outline show on every docs page. Turn them off for one page with `sidebar: false` or `toc: false`. A page that needs the width, such as a playground, sets `sidebar: collapsed`: wide screens show a narrow column with the logo, a button that opens the navigation, search, and the site links, or the rail on a site that has one. An app page in the docs layout sets it with `definePageMeta({ layout: "docs", sidebar: "collapsed" })`. A code panel tutorial starts collapsed too.
|
|
169
|
+
|
|
170
|
+
````md
|
|
171
|
+
---
|
|
172
|
+
title: Build a CLI
|
|
173
|
+
layout: tutorial
|
|
174
|
+
codePanel: true
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
::tutorial-step{title="Create the project"}
|
|
178
|
+
## Create the project
|
|
179
|
+
|
|
180
|
+
```ts [src/cli.ts]
|
|
181
|
+
console.log("hello")
|
|
182
|
+
```
|
|
183
|
+
::
|
|
184
|
+
````
|
|
185
|
+
|
|
186
|
+
## Customize
|
|
187
|
+
|
|
188
|
+
Most changes are options in `nuxt.config.ts`:
|
|
189
|
+
|
|
190
|
+
| Option | Default | Use |
|
|
191
|
+
| --- | --- | --- |
|
|
192
|
+
| `dir` | `content` | Folder of Markdown pages. |
|
|
193
|
+
| `base` | `/docs`, or `/` without a `docs/` folder | URL prefix whose folders are sections. |
|
|
194
|
+
| `site` | `{ name: "Docs" }` | `name`, `url` (canonical origin), `description`, `logo`, `badge` (`{ label, tooltip }`). A `logo` path is a one-color SVG that the theme fills with the text color. `{ light, dark }` shows a colored logo as it is, with `dark` in dark mode. |
|
|
195
|
+
| `categories` | `[]` | Order of section categories in the rail and the catalog. |
|
|
196
|
+
| `railExclude` | `[]` | Categories that the catalog lists but the rail leaves out. |
|
|
197
|
+
| `groups` | `[]` | `[{ title, icon, sections }]`: rail items that hold several sections, such as every component package of a library. The sidebar of a member lists every section of its group, one row per section. A section also joins with `group` in its `.navigation.yml`. |
|
|
198
|
+
| `start` | None | `{ section, links }`: the section that new readers open first, and site pages listed at its top. |
|
|
199
|
+
| `socials` | `[]` | Community links at the foot of the docs sidebar and in the header of other pages, or in its menu on narrow screens. |
|
|
200
|
+
| `footer` | `[]` | Site pages linked at the end of every docs page, such as About and Privacy. |
|
|
201
|
+
| `banner` | None | One line above every docs page. |
|
|
202
|
+
| `github` | `false` | `{ repo, branch, dir }`. Adds a GitHub link beside the socials, with the star count when available. |
|
|
203
|
+
| `icons` | Lucide fallbacks | Icon maps of the rail and the sidebar. |
|
|
204
|
+
| `sitemap` | `[]` | More paths for `/sitemap.xml`. Every docs page is listed already. |
|
|
205
|
+
| `mcp` | On | `{ name, guide }`, or `false` to turn off the MCP server. |
|
|
206
|
+
| `llms` | None | `{ details, sections }`. Text under the description of `/llms.txt`, and sections of links before the page sections. |
|
|
207
|
+
| `linkChecker` | On | `false` turns off the link checks. The build first runs `vitehub content check` on the Markdown of every page, also the pages it does not prerender, and stops with `DOCS_LINKS_BROKEN` on a link to a missing page, named by file and line. Then `nuxt-link-checker` fails the build on detected link errors in prerendered pages, such as links in the navigation and app pages. Fragments on other pages are checked against the final built HTML. Remote URLs are not fetched. A link to an exact `redirect` route rule passes, and the build checks that the rule leads to a docs page instead. Set the app's own `linkChecker` options to change it. |
|
|
208
|
+
| `seoAudit` | `"warn"` | The search check of prerendered pages. `"warn"` reports one hint for each kind of problem, such as `DOCS_SEO_TITLE_INVALID`, in the build output and in `.vitehub/hints.json`. `"error"` or `true` stops the build with `DOCS_SEO_FAILED`, and `false` turns it off. The audit checks the rendered title and description, including duplicates across indexed pages. When the rendered title or description has the same problem in `vitehub content check`, the audit includes the frontmatter file and line. It also checks sitemap URLs, `h1` and heading order, word count, inbound links, Open Graph tags, HTML over 2 MB, and links to redirects or `/mcp`. A page without a share image (`seo.image: false`, or `ogImage: false`) needs no `og:image`, and a site without `site.url` needs no `og:url`. |
|
|
209
|
+
| `ogImage` | On | Share images. `{ component }` renders the app's own template from `components/OgImage/`, or `false` turns them off. See [Search and share](#search-and-share). |
|
|
210
|
+
| `assistant` | `false` | `true`, or `{ agent }`. See [Docs assistant](#docs-assistant). |
|
|
211
|
+
| `comments` | On with `vite-hub/nuxt` | `false` turns Comments off, or `{ database, dialect, overlay }`. See [Comments](#comments). |
|
|
212
|
+
| `rawMarkdown` | None | `(markdown, page) => string`. Rewrites a page before agents read it. |
|
|
213
|
+
| `markdownPages` | `true` | A Markdown copy of each app page that is not a docs page, converted from its HTML, at its URL plus `.md` and for `Accept: text/markdown`. `false` turns it off. |
|
|
214
|
+
| `parser` | None | Path of a module whose default export is the parser options: `{ comarkUi, examples, plugins }`. See [Comark plugins](#comark-plugins). |
|
|
215
|
+
| `examples` | `examples` | Folder, inside `app/`, of the Vue files that `::example{name}` shows. See [Examples](#examples). |
|
|
216
|
+
|
|
217
|
+
### Components
|
|
218
|
+
|
|
219
|
+
The shell is a set of Nuxt components. Create a component with the same name in your app, and it replaces the default. For example, `app/components/DocsPageHeaderLinks.vue` replaces the page actions.
|
|
220
|
+
|
|
221
|
+
| Component | Part |
|
|
222
|
+
| --- | --- |
|
|
223
|
+
| `AppHeader` | Site header, with search, GitHub, social links, and the color mode button. On wide screens it hides beside the docs sidebar. |
|
|
224
|
+
| `AppSearch` | The search dialog. |
|
|
225
|
+
| `DocsRail`, `DocsSidebars`, `DocsAsideLeftTop`, `DocsAsideLeftBody`, `DocsAsideFooter` | The section rail, the page sidebar with its brand, search, and title, and the row of links at its foot. |
|
|
226
|
+
| `DocsPage`, `DocsArticle`, `DocsLanding`, `DocsMarkdown` | The page and its layouts. |
|
|
227
|
+
| `DocsHeaderActions` | Empty. Replace it to add items to the site header or the desktop sidebar footer. |
|
|
228
|
+
| `DocsPageHeaderLinks` | Copy page, View as Markdown, Open in ChatGPT or Claude, and the MCP links. |
|
|
229
|
+
| `DocsCatalogFooter` | The catalog at the end of an Overview. |
|
|
230
|
+
| `DocsCodePanel`, `DocsCodePre` | The tutorial code panel and code blocks. |
|
|
231
|
+
|
|
232
|
+
Markdown blocks are components in `components/content/`. The package has `::tutorial-step`, `::product-features` with `:::product-feature-item`, `::example` and `::examples`, `::correct` and `::incorrect`, `::code-tree`, `::page-list`, `::mcp-install` with `:::mcp-client`, and `::agent-only`. Add your own in `app/components/content/`, for example `ProductHero.vue` for `::product-hero`. An app `app.vue`, `error.vue`, `layouts/docs.vue`, or `layouts/default.vue` also replaces the package one. In an app with its own `app.vue`, the plain articles outside the sections use the `docs-article` layout, so the app's `default` layout stays on its own pages. A catch-all page replaces the docs page only at the docs prefix: `pages/[...slug].vue` for docs at `/`, and `pages/docs/[...slug].vue` for docs at `/docs`. One at another prefix, such as `pages/blog/[...slug].vue`, does not.
|
|
233
|
+
|
|
234
|
+
A replacement docs layout or sidebar keeps the site header. Render `<DocsSidebars panel head />` to supply the sidebar controls and hide the desktop header. A replacement `DocsSidebars` can opt in with `data-docs-sidebar-head` on its root after it supplies the brand, badge tooltip, search, and `<DocsAsideFooter />`. The header owns one `DocsHeaderActions` instance and moves it into the mounted footer on wide screens.
|
|
235
|
+
|
|
236
|
+
Components read the site with auto-imported composables: `useDocsConfig()`, `useDocsManifest()`, `useDocsPage()`, `useDocsSection()`, `useDocsIcons()`, and `useDocsAssistant()`.
|
|
237
|
+
|
|
238
|
+
A Vue entry holds the parts that docs pages share with other ViteHub surfaces. Their styles are in `@vite-hub/ui/styles.css`, which the module loads.
|
|
239
|
+
|
|
240
|
+
| Entry | Parts |
|
|
241
|
+
| --- | --- |
|
|
242
|
+
| `@vite-hub/docs/primitive-rail` | `PrimitiveRail`, `PrimitiveRailGroup`, `PrimitiveRailItem`, and `PrimitiveIcon`, which draws a [`@vite-hub/icons`](../icons/README.md) icon inline so its rail item can move it on hover. The docs rail and the Console use them. They are internal and can change in any release. |
|
|
243
|
+
|
|
244
|
+
### Examples
|
|
245
|
+
|
|
246
|
+
`::example` shows a preview and its source, with a Preview and Code switch. Around an `md`, `markdown`, `mdc`, or `comark` code block, the preview is that Markdown, rendered with the same plugins as the page:
|
|
247
|
+
|
|
248
|
+
`````md
|
|
249
|
+
::example
|
|
250
|
+
````md
|
|
251
|
+
Some **bold** text.
|
|
252
|
+
````
|
|
253
|
+
::
|
|
254
|
+
`````
|
|
255
|
+
|
|
256
|
+
With `name`, the preview is a Vue file in `app/examples/`, and Code shows its source. `::example{name="ButtonExample"}` renders `app/examples/ButtonExample.vue`. `height` keeps that many rem for it before its module loads, `flush` shows it edge to edge at that height, and `reset` adds a control that mounts it again. `play` links the example to a playground that opens it.
|
|
257
|
+
|
|
258
|
+
`::examples` puts several `:::example` blocks in underlined tabs named by their `label`. The examples share one view, so a reader who picks Code keeps reading code from tab to tab. A site that renders the preview itself, as comark-ui does to write `play`, passes a parser plugin named `docs-examples`.
|
|
259
|
+
|
|
260
|
+
`::correct` and `::incorrect` are examples titled Correct and Incorrect, as on a lint rule's page. Any example takes a `#title` slot that leads its bar, and these two fill it; `title` renames them. Markdown that doesn't parse, such as broken frontmatter on purpose, shows its source alone.
|
|
261
|
+
|
|
262
|
+
### Code trees and page lists
|
|
263
|
+
|
|
264
|
+
`::code-tree` shows its code blocks as a project: file tabs beside the open file, or above it in a narrow panel. Each block names its file, such as ```` ```ts [server/api/kv.ts] ````, and `default-value` picks the file that opens first.
|
|
265
|
+
|
|
266
|
+
`::page-list` lists the pages of the page's section under their sidebar groups, with their icons and descriptions, for an Overview. On a panel Overview it lists the pages of the panel. `section` lists another section, `group="Runtime errors"` lists one group, and `exclude="Start"` leaves groups out. `compact` shows one line for each page, without icons: use it for long lists, such as one page per error code, because a Markdown table of a thousand rows is more HTML than crawlers read. Put a plain Markdown list or table inside it: the site doesn't show it, and agents read it in the Markdown copy.
|
|
267
|
+
|
|
268
|
+
`::mcp-install` connects a reader's agent to the site's MCP server at `/mcp`. Its Client tab shows each `:::mcp-client{label icon method}` as a logo, and the steps of the client that the reader picks. The pick is kept for the next visit. Write the steps as a numbered list. `install="cursor"` or `install="vscode"` adds a one-click install button, and `note` adds a footer line. The Prompt, MCP URL, and Command tabs come from the `mcp` option, so they always name the real server. Agents get every client's steps under its name in the Markdown copy.
|
|
269
|
+
|
|
270
|
+
### Comark plugins
|
|
271
|
+
|
|
272
|
+
The server parses each page with Comark, and the browser renders the nodes with [comark-ui](https://comark-ui.onmax.me)'s blocks: GitHub callouts (`> [!NOTE]`, and `::note`, `::tip`, `::warning`, `::caution`, `::important`), tabs and code groups, steps, code with a copy bar, zoomable images, charts, diagrams, file trees, cards, and the rest. comark-ui's typeset is off, since the design styles the prose. Chips are off too: they turn every web link into a chip and fetch its favicon. Annotated screenshots, diffs, quizzes, and comments have no Vue components, so the server draws them as HTML in a `comark-html` node, with the block's tag in `block`.
|
|
273
|
+
|
|
274
|
+
An image from `public/`, such as ``, gets its `width` and `height` from the file, so the page does not move when the picture loads. The build measures the pictures in the `public/` folders of the app and its layers. A side that the page sets, such as `{width=640}`, stays, and the other follows the picture's ratio. Restart the development server to measure a picture added while it runs.
|
|
275
|
+
|
|
276
|
+
`::examples` and `:::example{label play}` show rendered Markdown next to its source, with underlined tabs, a Preview and Code switch, and an optional link to a playground. The parser renders the example's first fenced block as its preview, with the page's plugins. An example whose Markdown doesn't parse shows its source alone. A site's parser can still supply its own `example-preview` node. Content without a preview node stays visible.
|
|
277
|
+
|
|
278
|
+
Parser options go in a module that `parser` names, since Comark plugins are functions:
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
// docs.parser.ts
|
|
282
|
+
import type { DocsParserOptions } from "@vite-hub/docs/server"
|
|
283
|
+
import emoji from "comark/plugins/emoji"
|
|
284
|
+
|
|
285
|
+
export default {
|
|
286
|
+
plugins: [emoji()],
|
|
287
|
+
comarkUi: { chips: true },
|
|
288
|
+
examples: { play: source => `/play#md=${encodeURIComponent(source)}` },
|
|
289
|
+
} satisfies DocsParserOptions
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Set `docs: { parser: "./docs.parser.ts" }`. The page route, search, and Console drafts parse with these options. The page route reads each page with `content.get()` from a Content runtime over the bundled pages, so Content caches the parsed page. To parse docs pages in your own `server/content.ts`, pass `defineContent({ markdown: docsMarkdown(options) })` from `@vite-hub/docs/server`. It turns off Content's own comark-ui preset, so the output is the same as the page route's.
|
|
293
|
+
|
|
294
|
+
| Option | Default | Use |
|
|
295
|
+
| --- | --- | --- |
|
|
296
|
+
| `comarkUi` | `{ typeset: false, chips: false, diagrams: false, badge: { download: false } }` | Options of comark-ui's preset, merged over the defaults, such as `{ chips: true }`. `mermaid` fences render as SVG on the server with no network request. `diagrams: true` draws D2, PlantUML, and Graphviz fences through kroki.io, which receives their source; `diagrams: { server }` uses your own Kroki server. When `docs.github` is set, `github.references.repo` defaults to its repository, so `#123` links to its issues. |
|
|
297
|
+
| `examples.tags` | `["example", "correct", "incorrect"]` | Tags of the blocks that get a preview of their first fenced block, such as `["example", "correct", "incorrect"]`. |
|
|
298
|
+
| `examples.play` | None | `(source, tag) => url`: a playground URL for the block's Markdown, written as its `play`. Return `undefined` for no link. |
|
|
299
|
+
| `plugins` | `[]` | More Comark plugins, after the built-in ones. A plugin with a built-in name, such as `alert` or `comark-tabs`, replaces it. A plugin that adds a tag that comark-ui doesn't render needs a component for it in `app/components/content/`. |
|
|
300
|
+
|
|
301
|
+
### Design
|
|
302
|
+
|
|
303
|
+
The design follows the comark-ui site on top of the ViteHub design system (`@vite-hub/ui/theme.css` and `vitehubTheme`): Geist, neutral grays, hairline rings, 6px controls and 8px cards, one blue focus ring, a faint grain on the page, and GitHub code colors. On docs pages the sidebar holds the brand, search, a rail of sections or groups next to the page list, and a row at its foot with GitHub, the socials, and the color mode button. Other pages, and phones, get a header with the same parts. Text, code, and focus rings pass WCAG AA in light and dark mode. Change it in two places:
|
|
304
|
+
|
|
305
|
+
- `app.config.ts` `ui` keys. Your values win over the design. The design wins over the Nuxt UI defaults, also when `@nuxt/ui` comes first in `modules`.
|
|
306
|
+
- CSS variables in your stylesheet, such as `--vh-content-width` (prose width), `--vh-toc-width`, `--vh-panel-width`, `--vh-grain` (`none` turns the grain off), `--font-sans`, and the Nuxt UI `--ui-*` colors.
|
|
307
|
+
|
|
308
|
+
In an app with its own `app.vue`, the theme stays on the docs pages:
|
|
309
|
+
|
|
310
|
+
- The theme's CSS applies below the `vh-docs` class. The docs layouts put it on `<html>` on docs pages only.
|
|
311
|
+
- The docs layouts give the theme's slot classes and default props to Nuxt UI's `<UTheme>`, with the live `app.config.ts` UI values above the design. The app's pages keep their look.
|
|
312
|
+
- The docs pages use the app's Nuxt UI colors and icons. To change the docs pages only, set the CSS variables on `:root.vh-docs`.
|
|
313
|
+
|
|
314
|
+
### Link checks
|
|
315
|
+
|
|
316
|
+
The build also checks cross-page fragments in the final HTML output. Routes excluded by `routeRules` with `prerender: false` or `nitro.prerender.ignore`, including the enabled ViteHub Console, do not need output files: the server can answer them at request time. Files that do exist still have their fragments checked. More specific `prerender: true` rules remain checked.
|
|
317
|
+
|
|
318
|
+
`docs.linkChecker` accepts `excludeLinks` for intentionally unchecked URLs, `excludePages` for embedded documents, `ignoreFragments` for pages that use the hash as application state, and `redirect(url)` for application redirects. Lists accept exact public paths, globs such as `/blog/**`, or regular expressions; include `app.baseURL` when it is not `/`. The app's `linkChecker.excludeLinks` and `docs.linkChecker.excludeLinks` are combined. `linkChecker: false` disables both checks. For a standalone output check, use `checkDocsLinks({ dir, siteUrl, appBase?, excludeLinks?, excludePages?, ignoreFragments?, redirect?, isRuntimePath? })` from `@vite-hub/docs/server`; `isRuntimePath(pathname)` identifies server routes whose output files may be absent.
|
|
319
|
+
|
|
320
|
+
## Agent resources
|
|
321
|
+
|
|
322
|
+
Every page has a Markdown copy for coding agents. You get these routes with no setup:
|
|
323
|
+
|
|
324
|
+
| Route | Content |
|
|
325
|
+
| --- | --- |
|
|
326
|
+
| `/raw/<page>.md` | The page as Markdown, with absolute links. `::agent-only` blocks stay in it. It ends with the pages of its section, the next page, and a link to `/llms.txt`. |
|
|
327
|
+
| `/llms.txt`, `/llms-full.txt` | An index of every page, and every page in one file without the section links. |
|
|
328
|
+
| `/sitemap.md`, `/sitemap.xml` | Every page, for agents and for search engines. |
|
|
329
|
+
| `/mcp` | An MCP server with the `list-pages` and `get-page` tools. |
|
|
330
|
+
| `/.well-known/skills/<name>/SKILL.md` | Agent Skills from the `skills/` folder of the app, when it has one. |
|
|
331
|
+
| `/<page>.md` | Any other app page, such as `/index.md` for the home page, converted from its HTML by Content. `markdownPages: false` turns it off. |
|
|
332
|
+
|
|
333
|
+
Product landing components become plain Markdown, with the hero tagline, hosts, channels, linked feature titles, and descriptions. Component syntax inside code examples stays literal.
|
|
334
|
+
|
|
335
|
+
`::agent-only` content shows only to agents. The site renders nothing for it, and search skips it. Use `rawMarkdown` to expand your own components into plain Markdown in the agent copy. Each page header links to its Markdown copy and opens it in ChatGPT or Claude.
|
|
336
|
+
|
|
337
|
+
## Search and share
|
|
338
|
+
|
|
339
|
+
Every page gets its title, description, canonical link, Open Graph and Twitter tags, Schema.org (`WebSite`, `WebPage`, `TechArticle`, and a breadcrumb), and a share image, from its frontmatter and the `site` options. [Nuxt SEO](https://nuxtseo.com) does the work: `nuxt-site-config` takes `site`, `nuxt-schema-org` writes the graph, and `nuxt-og-image` renders each image while the build prerenders, so the server carries no renderer and a Worker stays small. The default image shows the site, the section, the page title, and the description. A page sets `seo.image` to share a file of its own. For another design, add `components/OgImage/Docs.takumi.vue` with the props `title`, `description`, `site`, `section`, `logo`, and `host`, and set `ogImage: { component: "Docs" }`. An app page, such as a playground, calls `useDocsSeo({ title, description })` to get the same tags and image.
|
|
340
|
+
|
|
341
|
+
Search indexes every page by heading. `⌘K` opens it. Page titles rank first, then headings, then text, and a typo still finds the page. The index loads the first time the dialog opens, from `/api/_docs/search.json`. `::agent-only` content is not indexed.
|
|
342
|
+
|
|
343
|
+
## Comments
|
|
344
|
+
|
|
345
|
+
A docs site on `vite-hub/nuxt` has ViteHub Comments on every page. The team pins comments, replies, mentions people with `@`, and resolves threads. Install `@vite-hub/comments` beside `vite-hub`:
|
|
346
|
+
|
|
347
|
+
```sh
|
|
348
|
+
pnpm add @vite-hub/comments
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
The module sets the `comments` option of `vite-hub/nuxt`, which turns on the Database. Run `vitehub database generate` and `vitehub database migrate` once. No `server/comments.ts` is needed; add one to set `authorize` or `people`.
|
|
352
|
+
|
|
353
|
+
- A thread belongs to the page path, such as `/docs/kv`, so it stays on its page across deploys.
|
|
354
|
+
- Readers see nothing. The overlay loads only with `?vitehub` or the `vitehub-tools` cookie, for people that `authorize` lets read. Without `authorize`, a production build admits the people of the Console's Comments section and people signed in with GitHub who can push to the repository.
|
|
355
|
+
- `@` suggests the users of ViteHub Auth when the app has Auth, else the people who wrote in the threads.
|
|
356
|
+
- The Console's Comments section lists the threads.
|
|
357
|
+
|
|
358
|
+
Turn it off with `docs: { comments: false }`. An object goes to the `comments` option of `vite-hub/nuxt`, such as `{ database: "docs" }` or `{ overlay: false }`. A site without `vite-hub/nuxt` has no Comments; `comments: true` there fails the build with `DOCS_COMMENTS_VITEHUB_MISSING`.
|
|
359
|
+
|
|
360
|
+
## Docs assistant
|
|
361
|
+
|
|
362
|
+
The docs assistant answers reader questions from your pages and links the pages that it used. It is a ViteHub Agent preset, `docsAssistant`. By default it runs on your ChatGPT plan, so you need no API key: with Codex on Node.js, and with a model-backed Driver in a Cloudflare Worker build.
|
|
363
|
+
|
|
364
|
+
```sh
|
|
365
|
+
pnpm add vite-hub @vite-hub/agent @vite-hub/workflow @vite-hub/connections @vite-hub/database drizzle-orm@1.0.0-rc.5 @openai/codex
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
// nuxt.config.ts
|
|
370
|
+
export default defineNuxtConfig({
|
|
371
|
+
modules: [
|
|
372
|
+
["vite-hub/nuxt", { host: "node", agent: true, connections: true, database: true }],
|
|
373
|
+
"@vite-hub/docs/nuxt",
|
|
374
|
+
],
|
|
375
|
+
docs: { assistant: true },
|
|
376
|
+
})
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
// server/agents/docs.ts
|
|
381
|
+
// server/agents/docs/agent.ts. `workspace: {}` says that this Agent owns the pages Workspace of the preset.
|
|
382
|
+
import { docsAssistant } from "@vite-hub/docs/assistant"
|
|
383
|
+
import { defineAgent } from "vite-hub/agent"
|
|
384
|
+
|
|
385
|
+
export default defineAgent({ extends: docsAssistant, workspace: {} })
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
// server/connections/chatgpt.ts
|
|
390
|
+
import { defineConnection } from "vite-hub/connections"
|
|
391
|
+
import { chatgpt } from "vite-hub/connections/chatgpt"
|
|
392
|
+
|
|
393
|
+
export default defineConnection({
|
|
394
|
+
provider: chatgpt({ appName: "Acme docs", appVersion: "1.0.0" }),
|
|
395
|
+
access: { "agent:docs": { read: true } },
|
|
396
|
+
})
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
// server/databases/default.ts: Connections keeps the grant in the app Database. Skip it when the app has one.
|
|
401
|
+
import { defineDatabase } from "vite-hub/database"
|
|
402
|
+
|
|
403
|
+
export default defineDatabase({ schema: {} })
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
The Agent and the Connection are app files on purpose. ViteHub discovers Agents and Connections from `server/`, so the ViteHub CLI and the Console show them like every other Agent and Connection. The Connection grants the Agent use of your ChatGPT plan, and a grant of that kind stays in your code, where you can read it. `docs.assistant` only adds the panel and checks this setup.
|
|
407
|
+
|
|
408
|
+
Set `VITEHUB_CONNECTIONS_KEY` to 32 random bytes in `.env`, start the app, and sign in once with `pnpm vitehub connections connect chatgpt --url http://localhost:3000`. Every page then shows an **Ask** button. `⌘I` (`Ctrl+I` on Windows and Linux) opens and closes the panel, and `Esc` closes it. On wide screens the panel is a column beside the page that you resize from its left edge. On narrow screens it is a sheet. `useDocsAssistant().toggle()` opens the panel from your own control.
|
|
409
|
+
|
|
410
|
+
The preset reads the site's pages from a read-only Workspace, answers in the `web` Chat Channel at `/_vitehub/agents/docs/chat`, and gets the path of the open page. It allows 30 questions per hour for the whole site, 2 answers at a time, and 8 waiting. Change any part with `defineAgent({ extends: docsAssistant, ... })`, for example `driver: { instructions }`, `driver: { gateway: openai(), model }` for an API key, or `docsRateLimit({ limit, identity })`. Set `docs: { assistant: { agent: "support" } }` to use an Agent with another name.
|
|
411
|
+
|
|
412
|
+
The Workspace has every page of the site in its `pages` folder, at its URL path: `/docs/guide/setup` is `pages/docs/guide/setup.md`. It reads the same pages as the site, from `docs.dir` or `docs.sources`, for each question. In development a new page shows at once, and a Worker reads the pages that the docs build packed. The assistant reads the source Markdown, so frontmatter adapters change only the site metadata. To read other files, override the Source: `workspace: { sources: { pages: glob({ cwd, include: ["**/*.md"], keyCache: false }) } }` with `glob` from `@vite-hub/workspace`.
|
|
413
|
+
|
|
414
|
+
Limits:
|
|
415
|
+
|
|
416
|
+
- **Worker builds.** Under the `workerd` and `worker` conditions, `docsAssistant` uses `driver: { model: "gpt-6.1-sol", gateway: chatgpt() }`, because a Worker cannot start Codex. The model reads the pages with the read-only Workspace shell. Change the model with `driver: { model }`, from `vitehub connections models chatgpt`. An Agent that sets `codexDriver()` itself fails a Worker build with `AGENT_B0019`.
|
|
417
|
+
- **Plan use.** OpenAI allows plan usage for open-source projects, personal apps that run locally, and selected private apps. Paid or remotely hosted apps must join OpenAI's waitlist first.
|
|
418
|
+
- **Shell access.** Codex reads the pages with shell commands in a temporary copy. It cannot write outside that copy or use the network, but it can read other files that the server user can read, and a reader can ask for them. Run a public assistant as a user that can read only the app.
|
|
419
|
+
- **Rate limit and budget.** The default limit is in process memory. It resets on restart, does not span processes, and one reader can use the whole hour. The token budget records an answer over 200,000 tokens; it does not stop it.
|
|
420
|
+
|
|
421
|
+
The [assistant guide](https://vitehub.dev/docs/docs-site/assistant) has every default and option.
|
|
422
|
+
|
|
423
|
+
## Edit in the Console
|
|
424
|
+
|
|
425
|
+
The ViteHub Console edits, previews, and publishes pages through the CMS. Add `vite-hub/nuxt` and one file:
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
// server/content.ts
|
|
429
|
+
import { defineContent } from "vite-hub/content"
|
|
430
|
+
import cms from "vite-hub/cms"
|
|
431
|
+
import { docsCollection } from "@vite-hub/docs"
|
|
432
|
+
|
|
433
|
+
export default defineContent({
|
|
434
|
+
extends: [cms, { repo: "owner/name", publish: "pr", roles: true }],
|
|
435
|
+
collections: { docs: docsCollection() },
|
|
436
|
+
})
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
`docsCollection({ path?, label? })` is a `documents()` collection over `content/**/*.md` with the page frontmatter as fields, and each document URL is its page URL. With `repo`, a save commits to a draft branch and a publish opens a pull request, so the site shows the change after it merges and builds. In the Console preview pane the page route renders the draft, uncached. Leave out the Content `seo` option: the docs module serves the sitemap and the Markdown copies, and Content's `.md` copies would compete with them in another format. See [Edit in the Console](https://vitehub.dev/docs/docs-site/configure#edit-in-the-console).
|
|
440
|
+
|
|
441
|
+
## Errors
|
|
442
|
+
|
|
443
|
+
| Code | When | Fix |
|
|
444
|
+
| --- | --- | --- |
|
|
445
|
+
| `DOCS_CONTENT_INVALID` | A page frontmatter or a `.navigation.yml` file does not match the schema. The message names the file and the field. | Fix the field. The schema is `docsPageSchema` and `docsSectionSchema` from `@vite-hub/docs`. |
|
|
446
|
+
| `DOCS_REDIRECTS_BROKEN` | A production build with the link checker on finds a redirect route rule into the docs that no page or server route answers, or one that hides a docs page. | Point the rule to a page, or remove it. |
|
|
447
|
+
| `DOCS_ASSISTANT_AGENTS_MISSING` | `assistant` is on, and `vite-hub/nuxt` with `agent: true` is missing. | Add `vite-hub/nuxt` with `agent: true` and `connections: true`, or turn `assistant` off. |
|
|
448
|
+
|
|
449
|
+
## Inspect
|
|
450
|
+
|
|
451
|
+
- The manifest, every section and page with its resolved title, order, layout, and flags, is in `.nuxt/docs/manifest.mjs`. The server reads it. Components read the copy in `.nuxt/docs/app-manifest.mjs` with `useDocsManifest()`: each page has only its `DocsAppPage` fields, such as `title`, `description`, `icon`, and `layout`. The page route returns the other fields of a page, such as `seo`, `tagline`, and `credits`. The build lists the pages and `.navigation.yml` files through ViteHub Content: `createDocsContent()` gives one Content Source per docs source, named `docs_<index>`: a `glob()` Source for a folder, or the Source that `sources` names. A script reads the whole manifest with `await createDocsManifest({ dir, base })`, or `{ dir, base, sources, rootDir }`, from `@vite-hub/docs/server`.
|
|
452
|
+
- The agent copy of each page is in `.nuxt/docs/raw/`.
|
|
453
|
+
- The Markdown blocks that pages can use are in `.nuxt/docs/components.mjs`.
|
|
454
|
+
- A running site serves the parsed page at `/api/_docs/page/<page>.json` and the search index at `/api/_docs/search.json`.
|
|
455
|
+
|
|
456
|
+
See the [docs site documentation](https://vitehub.dev/docs/docs-site).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { docsManifestPages, docsRawSectionLinks } from "./navigation.js";
|
|
2
|
+
import { t as toRawMarkdown } from "./raw-BChwipz_.js";
|
|
3
|
+
//#region src/agent-copy.ts
|
|
4
|
+
/**
|
|
5
|
+
* The copy of a page that agents read at `/raw/<page>.md`: the source as plain Markdown with absolute links, then the
|
|
6
|
+
* links of its section. `siteUrl` is the public origin with the app base, such as `https://docs.example.com/portal`.
|
|
7
|
+
*/
|
|
8
|
+
function docsAgentCopy(manifest, page, source, siteUrl) {
|
|
9
|
+
return {
|
|
10
|
+
markdown: toRawMarkdown(source, {
|
|
11
|
+
siteUrl,
|
|
12
|
+
pagePath: page.path
|
|
13
|
+
}),
|
|
14
|
+
footer: docsRawSectionLinks(manifest, page.path, siteUrl)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** The Content Source of a page, named like `createDocsContent()` names it: `docs_<index>` for the server asset `docs-<index>`. */
|
|
18
|
+
function docsContentSource(page) {
|
|
19
|
+
return `docs_${page.source ? page.source.slice(5) : 0}`;
|
|
20
|
+
}
|
|
21
|
+
/** The pages of each Content Source of the docs, `docs_<index>`, by their file in the Source. */
|
|
22
|
+
function docsAgentPages(manifest) {
|
|
23
|
+
const sources = /* @__PURE__ */ new Map();
|
|
24
|
+
for (const page of docsManifestPages(manifest)) {
|
|
25
|
+
const name = docsContentSource(page);
|
|
26
|
+
const pages = sources.get(name) ?? /* @__PURE__ */ new Map();
|
|
27
|
+
pages.set(page.file, page);
|
|
28
|
+
sources.set(name, pages);
|
|
29
|
+
}
|
|
30
|
+
return sources;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { docsAgentPages as n, docsContentSource as r, docsAgentCopy as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { docsManifestPages } from "./navigation.js";
|
|
2
|
+
import { t as docsErrorDiagnostics } from "./error-diagnostics-B_ZOy7kF.js";
|
|
3
|
+
import { n as readDocsFile, t as hasDocsFile } from "./files-UY4h1_36.js";
|
|
4
|
+
import manifest from "#docs/manifest";
|
|
5
|
+
//#region src/runtime/assistant-pages.ts
|
|
6
|
+
/**
|
|
7
|
+
* The Workspace path of a page: its URL path as a Markdown file, and `index.md` for a folder page. The assistant's rules
|
|
8
|
+
* turn a path back into the URL, so `docs/guide/setup.md` is `/docs/guide/setup`, whatever the source and mount of the page.
|
|
9
|
+
*/
|
|
10
|
+
function docsAssistantPagePath(page) {
|
|
11
|
+
if (page.path === "/") return "index.md";
|
|
12
|
+
const path = page.path.replace(/^\/+/, "");
|
|
13
|
+
return /(?:^|\/)index\.md$/.test(page.file) ? `${path}/index.md` : `${path}.md`;
|
|
14
|
+
}
|
|
15
|
+
let pageIndex;
|
|
16
|
+
function docsAssistantPages() {
|
|
17
|
+
const snapshot = manifest;
|
|
18
|
+
if (!pageIndex || pageIndex.manifest !== snapshot) pageIndex = {
|
|
19
|
+
manifest: snapshot,
|
|
20
|
+
pages: new Map(docsManifestPages(snapshot).map((page) => [docsAssistantPagePath(page), page]))
|
|
21
|
+
};
|
|
22
|
+
return pageIndex.pages;
|
|
23
|
+
}
|
|
24
|
+
function listDocsAssistantPagePaths() {
|
|
25
|
+
const paths = [];
|
|
26
|
+
for (const [path, page] of docsAssistantPages()) if (hasDocsFile(page.source ?? "docs", page.file)) paths.push(path);
|
|
27
|
+
return paths;
|
|
28
|
+
}
|
|
29
|
+
/** The source Markdown of a page at its Workspace path, from the same files that the docs Content reads. */
|
|
30
|
+
async function readDocsAssistantPage(path) {
|
|
31
|
+
const page = docsAssistantPages().get(path);
|
|
32
|
+
const text = page ? await readDocsFile(page.source ?? "docs", page.file) : null;
|
|
33
|
+
if (text === null) throw docsErrorDiagnostics.DOCS_ASSISTANT_PAGE_MISSING({ path });
|
|
34
|
+
return text;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { listDocsAssistantPagePaths, readDocsAssistantPage };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RateLimitIdentity } from "@vite-hub/agent/capabilities";
|
|
2
|
+
import { AgentCapabilityDefinition, WorkspaceAgentDefinition } from "@vite-hub/agent";
|
|
3
|
+
import { RateLimitPolicy } from "@vite-hub/rate-limit";
|
|
4
|
+
import "@vite-hub/workspace";
|
|
5
|
+
//#region src/assistant-shared.d.ts
|
|
6
|
+
/** Invocation context key that holds the path of the page the reader has open. */
|
|
7
|
+
declare const docsPageContextKey = "docsPage";
|
|
8
|
+
/** Returns the page path from a chat request body, or an empty string when it is missing or not a plain path. */
|
|
9
|
+
declare function docsPageFromBody(body: Readonly<Record<string, unknown>>): string;
|
|
10
|
+
interface DocsRateLimitOptions {
|
|
11
|
+
/** Questions per window. Defaults to 30. */
|
|
12
|
+
limit?: number;
|
|
13
|
+
/** Defaults to `1h`. */
|
|
14
|
+
window?: RateLimitPolicy["window"];
|
|
15
|
+
/**
|
|
16
|
+
* Who shares one budget. Defaults to the whole site, because anonymous readers have no stable identity. Use `"ip"`
|
|
17
|
+
* with `trustedIpHeaders` behind a proxy that sets them, or a function of the Invocation context.
|
|
18
|
+
*/
|
|
19
|
+
identity?: RateLimitIdentity;
|
|
20
|
+
trustedIpHeaders?: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The assistant's question limit, with the id `docs-rate-limit` that replaces the default one. Counters live in process
|
|
24
|
+
* memory: they reset on restart and do not span processes.
|
|
25
|
+
*/
|
|
26
|
+
declare function docsRateLimit(options?: DocsRateLimitOptions): AgentCapabilityDefinition;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { docsRateLimit as i, docsPageContextKey as n, docsPageFromBody as r, DocsRateLimitOptions as t };
|