@vite-hub/docs 0.4.1 → 0.5.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/README.md +167 -7
- package/dist/{agent-copy-xPaWye_g.js → agent-copy-CY9_RkHN.js} +2 -3
- package/dist/{assistant-pages-BN7hNsSZ.js → assistant-pages-BbWfd69g.js} +3 -4
- package/dist/{assistant-shared-CWIKRtBv.d.ts → assistant-shared-BWeRcmVS.d.ts} +0 -2
- package/dist/{assistant-shared-WzButktj.js → assistant-shared-JcfjK-qg.js} +3 -4
- package/dist/assistant-worker.d.ts +1 -3
- package/dist/assistant-worker.js +2 -3
- package/dist/assistant.d.ts +1 -3
- package/dist/assistant.js +2 -3
- package/dist/{content-CPZGnn3S.js → content-C_WXjV3y.js} +60 -28
- package/dist/{draft-BjWmaiLn.js → draft-rOGhtXch.js} +3 -4
- package/dist/{error-diagnostics-B_ZOy7kF.js → error-diagnostics-Daz9oBJS.js} +65 -2
- package/dist/{files-UY4h1_36.js → files-BBoAGhhM.js} +1 -2
- package/dist/index.d.ts +7 -8
- package/dist/index.js +5 -6
- package/dist/link-checker-redirects.d.ts +0 -2
- package/dist/link-checker-redirects.js +2 -3
- package/dist/{manifest-ZdxLrcvt.js → manifest-Bti_WxDZ.js} +64 -30
- package/dist/{manifest-CMoxcwPm.d.ts → manifest-DJ2DyNue.d.ts} +1 -5
- package/dist/{page-Dx2JD3y1.d.ts → markdown-B97RuMXs.d.ts} +2 -27
- package/dist/{markdown-DUWnEMPp.js → markdown-BzZkYb24.js} +2 -3
- package/dist/navigation.d.ts +10 -6
- package/dist/navigation.js +23 -10
- package/dist/{nuxt-CAGpKl_-.d.ts → nuxt-CYAIBEHE.d.ts} +74 -8
- package/dist/nuxt.d.ts +3 -3
- package/dist/nuxt.js +1286 -89
- package/dist/page-B8_70-5D.d.ts +24 -0
- package/dist/{page-GPt09oex.js → page-DWsretqk.js} +20 -5
- package/dist/primitive-rail.d.ts +1 -10
- package/dist/primitive-rail.js +4 -10
- package/dist/{raw-BChwipz_.js → raw-CQukuLuj.js} +1 -2
- package/dist/{redirects-CmR1yu5A.js → redirects-BEFu4KLR.js} +35 -23
- package/dist/runnable.d.ts +33 -0
- package/dist/runnable.js +104 -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.d.ts +0 -2
- package/dist/runtime/server/llms.js +2 -3
- package/dist/runtime/server/markdown.d.ts +0 -7
- package/dist/runtime/server/markdown.js +11 -3
- package/dist/runtime/server/mcp.d.ts +0 -2
- package/dist/runtime/server/mcp.js +2 -3
- package/dist/runtime/server/page.d.ts +1 -3
- package/dist/runtime/server/page.js +4 -5
- package/dist/runtime/server/raw.d.ts +0 -2
- package/dist/runtime/server/raw.js +3 -11
- package/dist/runtime/server/search.d.ts +1 -3
- package/dist/runtime/server/search.js +4 -4
- package/dist/runtime/server/sitemap.d.ts +0 -2
- package/dist/runtime/server/sitemap.js +3 -5
- package/dist/runtime/server/trailing-slash.d.ts +0 -2
- package/dist/runtime/server/trailing-slash.js +1 -2
- package/dist/schema-CmSiwC4t.js +189 -0
- package/dist/server.d.ts +3 -4
- package/dist/server.js +4 -4
- package/dist/snapshot-worker.mjs +40 -0
- package/dist/steps-C3tGwhNK.d.ts +103 -0
- package/dist/steps-muDP1nYT.js +31 -0
- package/dist/{theme-BXyu4uFL.d.ts → theme-CgJRnVdT.d.ts} +0 -4
- package/dist/{theme-DzC8LtMH.js → theme-CxBzPBZ9.js} +2 -4
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +1 -2
- package/dist/{types-BhG6vGfG.d.ts → types-B6YlHil4.d.ts} +69 -8
- package/package.json +40 -32
- package/dist/schema-DwpXW0VZ.js +0 -98
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// src/error-diagnostics.ts
|
|
3
3
|
const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
4
|
docsBase: "https://vitehub.dev/docs/docs-site/diagnostics",
|
|
5
5
|
codes: {
|
|
@@ -11,10 +11,18 @@ const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
11
11
|
why: ({ path }) => `[@vite-hub/docs] The docs assistant's Workspace has no page at ${path}. The pages changed after the Workspace listed them.`,
|
|
12
12
|
fix: "Ask the question again. The next Invocation lists the current pages."
|
|
13
13
|
},
|
|
14
|
+
DOCS_BASE_EMPTY: {
|
|
15
|
+
why: ({ base, path }) => `[@vite-hub/docs] With docs.sources, the docs base defaults to ${base}. No page is at or below it, so pages such as ${path} render as standalone articles.`,
|
|
16
|
+
fix: "To show sections, set `docs: { base: '/' }` in nuxt.config.ts or mount the pages at `/docs`. To keep the pages standalone, set `docs: { base: '/docs' }`."
|
|
17
|
+
},
|
|
14
18
|
DOCS_COMMENTS_DATABASE_OFF: {
|
|
15
19
|
why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which keeps threads in the Database, but vitehub sets database: false.",
|
|
16
20
|
fix: "Remove `database: false` from the `vitehub` options in nuxt.config.ts, or set `docs: { comments: false }`."
|
|
17
21
|
},
|
|
22
|
+
DOCS_COMMENTS_OFF_IGNORED: {
|
|
23
|
+
why: "[@vite-hub/docs] docs.comments is false, but the vitehub options turn Comments on, and they win. Comments stay on.",
|
|
24
|
+
fix: "Remove `comments: false` from the `docs` options in nuxt.config.ts. To turn Comments off, set `comments: false` in the `vitehub` options."
|
|
25
|
+
},
|
|
18
26
|
DOCS_COMMENTS_PACKAGE_MISSING: {
|
|
19
27
|
why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which needs @vite-hub/comments.",
|
|
20
28
|
fix: "Run `pnpm add @vite-hub/comments`, or set `docs: { comments: false }` in nuxt.config.ts."
|
|
@@ -43,6 +51,38 @@ const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
43
51
|
why: ({ problems }) => `Docs redirects break links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
44
52
|
fix: "Point each redirect route rule that the message lists to a docs page, or remove the rule when the page that it hides still exists."
|
|
45
53
|
},
|
|
54
|
+
DOCS_RUNNABLE_CATALOG_VERSION_MISSING: {
|
|
55
|
+
why: ({ catalog, name }) => `[@vite-hub/docs] A fixture of docs.runnable uses catalog:, but the pnpm catalog "${catalog}" has no version of ${name}.`,
|
|
56
|
+
fix: "Set `docs.runnable.pnpmWorkspace` to the folder of pnpm-workspace.yaml, and add the package to the catalog that the specifier names."
|
|
57
|
+
},
|
|
58
|
+
DOCS_RUNNABLE_DEV_SERVER_MISSING: {
|
|
59
|
+
why: ({ fixture, name }) => `[@vite-hub/docs] The dev script of the fixture ${fixture} runs ${name}, but ${name} is in devDependencies. The snapshot of docs.runnable installs dependencies only, so the workspace cannot start.`,
|
|
60
|
+
fix: "Move the package that the message names from `devDependencies` to `dependencies` in the package.json of the fixture."
|
|
61
|
+
},
|
|
62
|
+
DOCS_RUNNABLE_FIXTURE_FILE_MISSING: {
|
|
63
|
+
why: ({ fixture, label, page }) => `[@vite-hub/docs] ${page} shows ${label}, but the fixture ${fixture} has no such file.`,
|
|
64
|
+
fix: "Add the file to the fixture folder, or correct the label of the code block in the lesson page."
|
|
65
|
+
},
|
|
66
|
+
DOCS_RUNNABLE_PACK_FAILED: {
|
|
67
|
+
why: ({ name }) => `[@vite-hub/docs] pnpm pack wrote no tarball for ${name}, so the snapshot of docs.runnable cannot install it.`,
|
|
68
|
+
fix: "Run `pnpm pack` in the folder of the package that the message names, and fix the error that it shows."
|
|
69
|
+
},
|
|
70
|
+
DOCS_RUNNABLE_PAGE_MISSING: {
|
|
71
|
+
why: ({ page }) => `[@vite-hub/docs] docs.runnable names the page ${page}, but the docs site has no page at that URL.`,
|
|
72
|
+
fix: "Set `page` of the lesson, or `docs.runnable.start`, to the URL of a docs page, such as `/docs/getting-started/first-agent`."
|
|
73
|
+
},
|
|
74
|
+
DOCS_RUNNABLE_STEPS_MISSING: {
|
|
75
|
+
why: ({ page }) => `[@vite-hub/docs] ${page} has no ::tutorial-step blocks, so docs.runnable cannot build its lesson.`,
|
|
76
|
+
fix: "Add `::tutorial-step{title=\"...\"}` blocks to the lesson page, or remove the lesson from `docs.runnable.lessons`."
|
|
77
|
+
},
|
|
78
|
+
DOCS_RUNNABLE_TITLE_MISSING: {
|
|
79
|
+
why: ({ block }) => `[@vite-hub/docs] A ::tutorial-step block has no title: ${block}`,
|
|
80
|
+
fix: "Give the block a title, such as `::tutorial-step{title=\"Add the route\"}`."
|
|
81
|
+
},
|
|
82
|
+
DOCS_RUNNABLE_WORKSPACE_PACKAGE_MISSING: {
|
|
83
|
+
why: ({ name }) => `[@vite-hub/docs] A fixture of docs.runnable uses workspace:, but the pnpm workspace has no package named ${name}.`,
|
|
84
|
+
fix: "Set `docs.runnable.pnpmWorkspace` to the folder of pnpm-workspace.yaml, and check that its `packages` patterns include the package."
|
|
85
|
+
},
|
|
46
86
|
DOCS_SEO_DESCRIPTION_INVALID: {
|
|
47
87
|
why: ({ problems }) => `Docs pages have no description, one of the wrong length, or the description of another page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
48
88
|
fix: "Set `description` in the frontmatter of each page that the message lists, with 70 to 160 characters, and give each page its own."
|
|
@@ -86,8 +126,31 @@ const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
86
126
|
DOCS_SOURCE_MOUNT_INVALID: {
|
|
87
127
|
why: ({ mount }) => `Invalid docs source mount: ${mount}`,
|
|
88
128
|
fix: "Set the `mount` of the docs source to a URL path such as `/guide`, without `.`, `..`, `?`, `#`, or backslash segments."
|
|
129
|
+
},
|
|
130
|
+
DOCS_WORKSPACE_DIR_MISSING: {
|
|
131
|
+
why: ({ dir, page }) => `The docs page ${page} runs the folder ${dir}, which does not exist.`,
|
|
132
|
+
fix: "Set `dir` of each example in `examples` to a folder of the app relative to the app root, or set `fixture` of a learn page to a folder in the `docs.runnable.fixtures` folder (`fixtures` by default)."
|
|
133
|
+
},
|
|
134
|
+
DOCS_WORKSPACE_ID_COLLISION: {
|
|
135
|
+
why: ({ id, owners }) => `${owners.join(" and ")} get the same workspace id ${id}, so their lessons, examples, or snapshots would overwrite each other.`,
|
|
136
|
+
fix: "Rename a page, or change the `slug` of a lesson or the `id` of an example in `docs.runnable`. A page's id is its path in lower case with each run of other characters as `-`, so `/docs/a/b` and `/docs/a-b` are both `docs-a-b`, and its examples are `<page id>--<example id>`. An example `kv` also takes the snapshot id `playground-kv`."
|
|
137
|
+
},
|
|
138
|
+
DOCS_WORKSPACE_READONLY_MISSING: {
|
|
139
|
+
why: ({ dir, example, page, path }) => `The example ${example} of the docs page ${page} marks ${path} read-only, but ${dir} has no text file at that path.`,
|
|
140
|
+
fix: "Set each path in `readonly` to a text file of the example's `dir`, relative to that folder, such as `model.ts`. Binary files, such as `weights.bin`, are never editable, so leave them out."
|
|
141
|
+
},
|
|
142
|
+
DOCS_WORKSPACE_RENDER_MISSING: {
|
|
143
|
+
why: ({ file, page }) => `The docs page ${page} renders with ${file}, which does not exist.`,
|
|
144
|
+
fix: "Set `render` to a module relative to the app root, such as `app/playground/render.ts`, whose default export takes the files and returns `{ html }`."
|
|
145
|
+
},
|
|
146
|
+
DOCS_WORKSPACE_TAB_MISSING: {
|
|
147
|
+
why: ({ file, page, tab }) => `The docs page ${page} has the tab \`${tab}\`, but ${file} does not exist.`,
|
|
148
|
+
fix: "Add the component that draws the tab, or remove the tab from `tabs`. The tab `messages` renders `app/components/playground/PlaygroundTabMessages.vue`, which reads the workspace with `useWorkspace()`."
|
|
149
|
+
},
|
|
150
|
+
DOCS_WORKSPACE_VITEHUB_MISSING: {
|
|
151
|
+
why: ({ pages }) => `[@vite-hub/docs] These pages run apps in a WebContainer, which needs vite-hub/nuxt for cross-origin isolation: ${pages.join(", ")}.`,
|
|
152
|
+
fix: "Add `vite-hub/nuxt` and `@vite-hub/web-container` to the app, or give each playground page a `render` module, which runs without a WebContainer."
|
|
89
153
|
}
|
|
90
154
|
}
|
|
91
155
|
});
|
|
92
|
-
//#endregion
|
|
93
156
|
export { docsErrorDiagnostics as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import files from "#docs/files";
|
|
2
|
-
|
|
2
|
+
// src/runtime/files.ts
|
|
3
3
|
const decoder = new TextDecoder();
|
|
4
4
|
let unpacked;
|
|
5
5
|
async function unpack(base64) {
|
|
@@ -34,5 +34,4 @@ async function readDocsFile(store, file) {
|
|
|
34
34
|
const bytes = await (unpacked ??= unpack(files.packed));
|
|
35
35
|
return decoder.decode(bytes.subarray(range[0], range[1]));
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { readDocsFile as n, hasDocsFile as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DocsCatalogGroup, DocsGroup, DocsIcons, DocsLink, DocsMarkdownLinks, DocsPanelLoaders, DocsRailEntry, DocsSidebarGroup, DocsSidebarSection, DocsSidebarSectionBlock, docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
1
|
+
import { _ as docsPageFields, a as DocsSearchSection, b as expandDottedKeys, d as DocsPageFrontmatter, f as DocsPageNavigation, g as docsLayouts, h as DocsSectionFile, i as DocsPageWorkspace, l as DocsLayout, m as DocsPlaygroundTab, n as DocsManifest, o as DocsSection, p as DocsPlaygroundExample, r as DocsPage, s as DocsTocLink, t as DocsAppPage, u as DocsPageFile, v as docsPageSchema, y as docsSectionSchema } from "./types-B6YlHil4.js";
|
|
2
|
+
import { t as DocsDocument } from "./markdown-B97RuMXs.js";
|
|
3
|
+
import { n as DocsPageResponse, t as DocsPageLink } from "./page-B8_70-5D.js";
|
|
4
|
+
import { a as DocsPublicConfig, d as DocsRunnableOptions, l as DocsRunnableExample, n as DocsLogo, o as DocsSiteOptions, r as DocsModuleOptions, s as DocsStartOptions, u as DocsRunnableLesson } from "./nuxt-CYAIBEHE.js";
|
|
5
|
+
import { DocsCatalogGroup, DocsGroup, DocsIcons, DocsLink, DocsMarkdownLinks, DocsPanelLoaders, DocsRailEntry, DocsSidebarGroup, DocsSidebarSection, DocsSidebarSectionBlock, docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
6
|
+
import { i as DocsSourceInput, r as DocsSource, t as DocsContentSource } from "./manifest-DJ2DyNue.js";
|
|
6
7
|
import { ContentLabel, DocumentsDefinition } from "@vite-hub/content";
|
|
7
|
-
//#region src/collection.d.ts
|
|
8
8
|
interface DocsCollectionOptions {
|
|
9
9
|
/**
|
|
10
10
|
* Glob of the Markdown pages in the Content Workspace, such as `content/**\/*.md`. The folder before the first
|
|
@@ -24,5 +24,4 @@ interface DocsCollectionOptions {
|
|
|
24
24
|
* export default defineContent({ extends: cms, collections: { docs: docsCollection() } })
|
|
25
25
|
*/
|
|
26
26
|
export declare function docsCollection(options?: DocsCollectionOptions): DocumentsDefinition<typeof docsPageFields>;
|
|
27
|
-
|
|
28
|
-
export { type DocsAppPage, type DocsCatalogGroup, type DocsCollectionOptions, type DocsContentSource, type DocsDocument, type DocsGroup, type DocsIcons, type DocsLayout, type DocsLink, type DocsLogo, type DocsManifest, type DocsMarkdownLinks, type DocsModuleOptions, type DocsPage, type DocsPageFile, type DocsPageFrontmatter, type DocsPageLink, type DocsPageNavigation, type DocsPageResponse, type DocsPanelLoaders, type DocsPublicConfig, type DocsRailEntry, type DocsSearchSection, type DocsSection, type DocsSectionFile, type DocsSidebarGroup, type DocsSidebarSection, type DocsSidebarSectionBlock, type DocsSiteOptions, type DocsSource, type DocsSourceInput, type DocsStartOptions, type DocsTocLink, docsCatalog, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, normalizeDocsBase, normalizeDocsPath };
|
|
27
|
+
export { type DocsAppPage, type DocsCatalogGroup, type DocsCollectionOptions, type DocsContentSource, type DocsDocument, type DocsGroup, type DocsIcons, type DocsLayout, type DocsLink, type DocsLogo, type DocsManifest, type DocsMarkdownLinks, type DocsModuleOptions, type DocsPage, type DocsPageFile, type DocsPageFrontmatter, type DocsPageLink, type DocsPageNavigation, type DocsPageResponse, type DocsPageWorkspace, type DocsPanelLoaders, type DocsPlaygroundExample, type DocsPlaygroundTab, type DocsPublicConfig, type DocsRailEntry, type DocsRunnableExample, type DocsRunnableLesson, type DocsRunnableOptions, type DocsSearchSection, type DocsSection, type DocsSectionFile, type DocsSidebarGroup, type DocsSidebarSection, type DocsSidebarSectionBlock, type DocsSiteOptions, type DocsSource, type DocsSourceInput, type DocsStartOptions, type DocsTocLink, docsCatalog, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as docsSectionSchema, i as docsPageSchema, n as docsLayouts, o as expandDottedKeys, r as docsPageFields } from "./schema-CmSiwC4t.js";
|
|
2
|
+
import { r as docsPagePath } from "./page-DWsretqk.js";
|
|
3
|
+
import { docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
4
4
|
import { documents } from "@vite-hub/content/collections";
|
|
5
|
-
|
|
5
|
+
// src/collection.ts
|
|
6
6
|
/**
|
|
7
7
|
* A Content collection over the docs Markdown pages, so the Console edits, previews, and publishes them. Its fields are
|
|
8
8
|
* the page frontmatter, and each document's URL is the page URL: `content/docs/kv/index.md` is `/docs/kv`.
|
|
@@ -23,5 +23,4 @@ function docsCollection(options = {}) {
|
|
|
23
23
|
url: ({ id }) => docsPagePath(id)
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
export { docsCatalog, docsCollection, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, normalizeDocsBase, normalizeDocsPath };
|
|
26
|
+
export { docsCatalog, docsCollection, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/link-checker-redirects.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The link checker reads its options once, when Nuxt installs it, and reports every link to a redirect. The docs module
|
|
4
3
|
* installs this module just before it, after the app's modules have added their route rules, so a link to a redirect
|
|
@@ -9,5 +8,4 @@
|
|
|
9
8
|
declare const linkCheckerRedirects: {
|
|
10
9
|
(inlineOptions: Record<string, never>, nuxt: never): unknown;
|
|
11
10
|
};
|
|
12
|
-
//#endregion
|
|
13
11
|
export { linkCheckerRedirects as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { docsAppPath } from "./navigation.js";
|
|
2
|
-
import { r as docsRedirects } from "./redirects-
|
|
2
|
+
import { r as docsRedirects } from "./redirects-BEFu4KLR.js";
|
|
3
3
|
import { defineNuxtModule } from "@nuxt/kit";
|
|
4
|
-
|
|
4
|
+
// src/link-checker-redirects.ts
|
|
5
5
|
/**
|
|
6
6
|
* The link checker reads its options once, when Nuxt installs it, and reports every link to a redirect. The docs module
|
|
7
7
|
* installs this module just before it, after the app's modules have added their route rules, so a link to a redirect
|
|
@@ -21,5 +21,4 @@ const linkCheckerRedirects = defineNuxtModule({
|
|
|
21
21
|
linkChecker.excludeLinks = [...linkChecker.excludeLinks ?? [], ...redirects.map((redirect) => docsAppPath(redirect.from, options.app.baseURL))];
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
//#endregion
|
|
25
24
|
export { linkCheckerRedirects as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { docsManifestPages,
|
|
2
|
-
import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-
|
|
3
|
-
import { n as docsPageOf, r as docsPagePath } from "./page-
|
|
4
|
-
import { t as docsErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { docsManifestPages, normalizeDocsBase } from "./navigation.js";
|
|
2
|
+
import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-CmSiwC4t.js";
|
|
3
|
+
import { n as docsPageOf, r as docsPagePath } from "./page-DWsretqk.js";
|
|
4
|
+
import { t as docsErrorDiagnostics } from "./error-diagnostics-Daz9oBJS.js";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
6
|
import { join, matchesGlob, posix, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { ELEMENT_NODE, parse as parse$1, walkSync } from "ultrahtml";
|
|
@@ -9,7 +9,7 @@ import { contentSource, defineContent } from "@vite-hub/content";
|
|
|
9
9
|
import { glob, useSource } from "@vite-hub/source";
|
|
10
10
|
import { parseFrontmatter } from "comark/parse";
|
|
11
11
|
import yaml from "comark-content/plugins/yaml";
|
|
12
|
-
|
|
12
|
+
// src/check-links.ts
|
|
13
13
|
/** `DOCS_LINKS_BROKEN`, with the list of problems in `problems`. */
|
|
14
14
|
function docsLinkError(problems) {
|
|
15
15
|
return Object.assign(docsErrorDiagnostics.DOCS_LINKS_BROKEN({ problems }), { problems });
|
|
@@ -36,6 +36,10 @@ function docsLinkExclusion(patterns) {
|
|
|
36
36
|
const excluded = matcher(patterns);
|
|
37
37
|
return (url, href) => excluded(href) || excluded(url.pathname) || excluded(url.pathname + url.hash);
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* The output file that answers `pathname`. A path with a trailing slash matches only `<path>/index.html`: hosts such
|
|
41
|
+
* as Cloudflare redirect `/guide/` to `/guide` when the output has `guide.html`.
|
|
42
|
+
*/
|
|
39
43
|
function docsOutputFile(dir, base = "/") {
|
|
40
44
|
const root = resolve(dir);
|
|
41
45
|
const appBase = `/${base.replace(/^\/+|\/+$/g, "")}`.replace(/\/$/, "");
|
|
@@ -47,12 +51,11 @@ function docsOutputFile(dir, base = "/") {
|
|
|
47
51
|
} catch {
|
|
48
52
|
return;
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
return [
|
|
54
|
+
return (path.endsWith("/") ? [`${path}index.html`] : [
|
|
52
55
|
path,
|
|
53
|
-
`${
|
|
54
|
-
`${
|
|
55
|
-
].map((candidate) => resolve(root, `.${candidate.startsWith("/") ? candidate : `/${candidate}`}`)).find((file) => file.startsWith(`${root}${sep}`) && existsSync(file) && statSync(file).isFile());
|
|
56
|
+
`${path}.html`,
|
|
57
|
+
`${path}/index.html`
|
|
58
|
+
]).map((candidate) => resolve(root, `.${candidate.startsWith("/") ? candidate : `/${candidate}`}`)).find((file) => file.startsWith(`${root}${sep}`) && existsSync(file) && statSync(file).isFile());
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
/** Check built HTML against the files and fragment ids in the same output, without fetching remote URLs. */
|
|
@@ -82,7 +85,15 @@ function checkDocsLinks(options) {
|
|
|
82
85
|
cache.set(file, result);
|
|
83
86
|
return result;
|
|
84
87
|
};
|
|
85
|
-
const
|
|
88
|
+
const outputFile = docsOutputFile(root, appBase);
|
|
89
|
+
const targets = /* @__PURE__ */ new Map();
|
|
90
|
+
function fileOf(path) {
|
|
91
|
+
const known = targets.get(path);
|
|
92
|
+
if (known !== void 0) return known;
|
|
93
|
+
const target = outputFile(path) ?? null;
|
|
94
|
+
targets.set(path, target);
|
|
95
|
+
return target;
|
|
96
|
+
}
|
|
86
97
|
const files = readdirSync(root, {
|
|
87
98
|
recursive: true,
|
|
88
99
|
withFileTypes: true
|
|
@@ -113,7 +124,9 @@ function checkDocsLinks(options) {
|
|
|
113
124
|
const target = fileOf(url.pathname);
|
|
114
125
|
if (!target) {
|
|
115
126
|
if (options.isRuntimePath?.(url.pathname)) continue;
|
|
116
|
-
|
|
127
|
+
const page = url.pathname.replace(/\/+$/, "");
|
|
128
|
+
if (page !== url.pathname && fileOf(page)) problems.add(`${path} links to ${url.pathname}, but the page is ${page}, without the trailing slash`);
|
|
129
|
+
else problems.add(`${path} links to ${url.pathname}, which has no page or file`);
|
|
117
130
|
continue;
|
|
118
131
|
}
|
|
119
132
|
if (url.hash.length <= 1 || !target.endsWith(".html") || ignoredFragment(url.pathname)) continue;
|
|
@@ -145,8 +158,7 @@ function decode(text) {
|
|
|
145
158
|
return value > 0 && value <= 1114111 ? String.fromCodePoint(value) : "�";
|
|
146
159
|
});
|
|
147
160
|
}
|
|
148
|
-
|
|
149
|
-
//#region src/manifest.ts
|
|
161
|
+
// src/manifest.ts
|
|
150
162
|
const isContentSource = (input) => "getKeys" in input;
|
|
151
163
|
/** The `sources` entries with absolute folders, in order. Page `source` names, such as `docs-1`, follow this order. */
|
|
152
164
|
function resolveDocsSources(inputs, rootDir = process.cwd()) {
|
|
@@ -277,9 +289,23 @@ function docsManifestOf(options, listed) {
|
|
|
277
289
|
};
|
|
278
290
|
const prefix = base === "/" ? "" : `${base.slice(1)}/`;
|
|
279
291
|
const rootFile = `${prefix}index.md`;
|
|
280
|
-
const
|
|
292
|
+
const sectionFiles = /* @__PURE__ */ new Map();
|
|
293
|
+
const standaloneFiles = [];
|
|
294
|
+
for (const file of files.keys()) {
|
|
295
|
+
if (file === rootFile) continue;
|
|
296
|
+
const slash = file.startsWith(prefix) ? file.indexOf("/", prefix.length) : -1;
|
|
297
|
+
if (slash === -1) {
|
|
298
|
+
standaloneFiles.push(file);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const id = file.slice(prefix.length, slash);
|
|
302
|
+
const group = sectionFiles.get(id);
|
|
303
|
+
if (group) group.push(file);
|
|
304
|
+
else sectionFiles.set(id, [file]);
|
|
305
|
+
}
|
|
306
|
+
const sections = [...sectionFiles].map(([id, entries], index) => {
|
|
281
307
|
const sectionPrefix = `${prefix}${id}/`;
|
|
282
|
-
const pages =
|
|
308
|
+
const pages = entries.map((file) => {
|
|
283
309
|
const pageId = idOf(file.slice(sectionPrefix.length));
|
|
284
310
|
return read(file, pageId, pageId === "index" ? joinPath(base, id) : joinPath(base, id, pageId));
|
|
285
311
|
}).sort((left, right) => left.id === "index" ? -1 : right.id === "index" ? 1 : left.order - right.order || left.id.localeCompare(right.id));
|
|
@@ -307,7 +333,7 @@ function docsManifestOf(options, listed) {
|
|
|
307
333
|
pages
|
|
308
334
|
};
|
|
309
335
|
}).sort((left, right) => left.order - right.order || left.title.localeCompare(right.title));
|
|
310
|
-
const pages =
|
|
336
|
+
const pages = standaloneFiles.map((file) => read(file, "", docsPagePath(file))).sort((left, right) => left.path.localeCompare(right.path));
|
|
311
337
|
const manifest = {
|
|
312
338
|
base,
|
|
313
339
|
root: files.has(rootFile) ? read(rootFile, "index", base) : null,
|
|
@@ -364,24 +390,33 @@ function appPage(full) {
|
|
|
364
390
|
function docsAppManifest(manifest, options) {
|
|
365
391
|
const panels = [];
|
|
366
392
|
const sections = manifest.sections.map((section) => {
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
393
|
+
const children = /* @__PURE__ */ new Map();
|
|
394
|
+
if (options.panels) {
|
|
395
|
+
for (const page of section.pages) if (page.panel) children.set(page.id, []);
|
|
396
|
+
}
|
|
397
|
+
function parentPanelPages(id) {
|
|
398
|
+
for (let slash = id.lastIndexOf("/"); slash >= 0; slash = id.lastIndexOf("/")) {
|
|
399
|
+
id = id.slice(0, slash);
|
|
400
|
+
const pages = children.get(id);
|
|
401
|
+
if (pages) return pages;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (!children.size || [...children.keys()].some((id) => parentPanelPages(id))) return {
|
|
370
405
|
...section,
|
|
371
406
|
pages: section.pages.map(appPage)
|
|
372
407
|
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
408
|
+
const pages = [];
|
|
409
|
+
for (const page of section.pages) (parentPanelPages(page.id) ?? pages).push(appPage(page));
|
|
410
|
+
for (const page of pages) {
|
|
411
|
+
const entries = children.get(page.id);
|
|
412
|
+
if (!entries) continue;
|
|
413
|
+
page.panelSize = entries.filter((entry) => entry.navigation).length;
|
|
414
|
+
if (entries.length) panels.push({
|
|
415
|
+
path: page.path,
|
|
377
416
|
section: section.id,
|
|
378
|
-
pages:
|
|
417
|
+
pages: entries
|
|
379
418
|
});
|
|
380
419
|
}
|
|
381
|
-
const pages = section.pages.filter((page) => page.panel || !docsPanelOf(section, page)).map((page) => page.panel ? {
|
|
382
|
-
...appPage(page),
|
|
383
|
-
panelSize: docsPanelPages(section, page).filter((candidate) => candidate.navigation && candidate.id !== page.id).length
|
|
384
|
-
} : appPage(page));
|
|
385
420
|
return {
|
|
386
421
|
...section,
|
|
387
422
|
pages
|
|
@@ -430,5 +465,4 @@ function joinPath(base, ...segments) {
|
|
|
430
465
|
function titleCase(input) {
|
|
431
466
|
return input.split(/[-/]/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
432
467
|
}
|
|
433
|
-
//#endregion
|
|
434
468
|
export { docsAppManifestSource as a, resolveDocsSources as c, docsLinkExclusion as d, docsOutputFile as f, docsAppManifest as i, checkDocsLinks as l, createDocsContent as n, docsAppPanelSource as o, createDocsManifest as r, readDocsContent as s, contentName as t, docsLinkError as u };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as DocsSectionFile, n as DocsManifest } from "./types-B6YlHil4.js";
|
|
2
2
|
import "nostics";
|
|
3
3
|
import { ContentCheckOptions, ContentRuntime } from "@vite-hub/content";
|
|
4
4
|
import { Source } from "@vite-hub/source";
|
|
5
|
-
//#region src/check-links.d.ts
|
|
6
5
|
interface DocsLinkCheckOptions {
|
|
7
6
|
dir: string;
|
|
8
7
|
siteUrl: string;
|
|
@@ -21,8 +20,6 @@ interface DocsLinkCheckOptions {
|
|
|
21
20
|
declare function checkDocsLinks(options: DocsLinkCheckOptions): {
|
|
22
21
|
pages: number;
|
|
23
22
|
};
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/manifest.d.ts
|
|
26
23
|
/**
|
|
27
24
|
* Pages from a Content Source, such as `glob()` or `github()` from `@vite-hub/source`. The build reads its `.md` files
|
|
28
25
|
* and its `.navigation.yml` files.
|
|
@@ -76,5 +73,4 @@ interface DocsContentOptions {
|
|
|
76
73
|
}
|
|
77
74
|
/** Read every docs source through Content and compute sections, pages, and their order. */
|
|
78
75
|
declare function createDocsManifest(options: DocsManifestOptions): Promise<DocsManifest>;
|
|
79
|
-
//#endregion
|
|
80
76
|
export { createDocsContent as a, checkDocsLinks as c, DocsSourceInput as i, DocsManifestOptions as n, createDocsManifest as o, DocsSource as r, DocsLinkCheckOptions as s, DocsContentSource as t };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as DocsSearchSection, s as DocsTocLink } from "./types-B6YlHil4.js";
|
|
2
2
|
import { PresetOptions } from "comark-ui/vue";
|
|
3
3
|
import { Node, ParserOptions } from "comark";
|
|
4
|
-
//#region src/markdown.d.ts
|
|
5
4
|
/** A page parsed on the server. The client renders `nodes` and never parses Markdown itself. */
|
|
6
5
|
interface DocsDocument {
|
|
7
6
|
nodes: Node[];
|
|
@@ -47,28 +46,4 @@ declare function docsMarkdown(options?: DocsParserOptions): {
|
|
|
47
46
|
declare function createDocsParser(options?: DocsParserOptions): (markdown: string) => Promise<DocsDocument>;
|
|
48
47
|
/** Split a page into one search entry per h2 and h3, like Nuxt UI's content search expects. */
|
|
49
48
|
declare function docsSearchSections(path: string, title: string, nodes: Node[]): DocsSearchSection[];
|
|
50
|
-
|
|
51
|
-
//#region src/page.d.ts
|
|
52
|
-
interface DocsPageLink {
|
|
53
|
-
path: string;
|
|
54
|
-
title: string;
|
|
55
|
-
description: string | null;
|
|
56
|
-
}
|
|
57
|
-
/** What the page route returns for one URL. The client renders it as is. */
|
|
58
|
-
interface DocsPageResponse {
|
|
59
|
-
page: DocsPage;
|
|
60
|
-
/** Id of the section that owns the page, or `null` for the root page and pages outside the base. */
|
|
61
|
-
section: string | null;
|
|
62
|
-
document: DocsDocument;
|
|
63
|
-
/** The page's `credits`, parsed like its body, or `null` without them. */
|
|
64
|
-
credits: DocsDocument | null;
|
|
65
|
-
prev: DocsPageLink | null;
|
|
66
|
-
next: DocsPageLink | null;
|
|
67
|
-
}
|
|
68
|
-
/** Previous and next follow the sidebar order of the page's section, or of its panel for a page inside one. */
|
|
69
|
-
declare function docsPageResponse(manifest: DocsManifest, found: {
|
|
70
|
-
page: DocsPage;
|
|
71
|
-
section: DocsSection | null;
|
|
72
|
-
}, document: DocsDocument, credits?: DocsDocument | null): DocsPageResponse;
|
|
73
|
-
//#endregion
|
|
74
|
-
export { DocsParserOptions as a, docsSearchSections as c, DocsDocument as i, DocsPageResponse as n, createDocsParser as o, docsPageResponse as r, docsMarkdown as s, DocsPageLink as t };
|
|
49
|
+
export { docsSearchSections as a, docsMarkdown as i, DocsParserOptions as n, createDocsParser as r, DocsDocument as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as docsErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as docsErrorDiagnostics } from "./error-diagnostics-Daz9oBJS.js";
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { ELEMENT_NODE, parse, walkSync } from "ultrahtml";
|
|
4
4
|
import { contentSearchSections } from "@vite-hub/content";
|
|
@@ -20,7 +20,7 @@ import markdownLanguage from "shiki/dist/langs/markdown.mjs";
|
|
|
20
20
|
import mdc from "shiki/dist/langs/mdc.mjs";
|
|
21
21
|
import githubDark from "shiki/dist/themes/github-dark-default.mjs";
|
|
22
22
|
import githubLight from "shiki/dist/themes/github-light-default.mjs";
|
|
23
|
-
|
|
23
|
+
// src/markdown.ts
|
|
24
24
|
const languages = [
|
|
25
25
|
css,
|
|
26
26
|
diff,
|
|
@@ -374,5 +374,4 @@ function docsSearchSections(path, title, nodes) {
|
|
|
374
374
|
nodes
|
|
375
375
|
}, { ignore: searchIgnore });
|
|
376
376
|
}
|
|
377
|
-
//#endregion
|
|
378
377
|
export { docsSearchSections as a, docsMarkdown as i, docsDocumentOf as n, docsImageSizes as r, createDocsParser as t };
|
package/dist/navigation.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
//#region src/navigation.d.ts
|
|
1
|
+
import { a as DocsSearchSection, l as DocsLayout, n as DocsManifest, o as DocsSection, r as DocsPage, t as DocsAppPage } from "./types-B6YlHil4.js";
|
|
3
2
|
/** A link that the site options add to the shell, such as a tutorials page or a community chat. */
|
|
4
3
|
export interface DocsLink {
|
|
5
4
|
label: string;
|
|
@@ -117,8 +116,9 @@ export type DocsStart = {
|
|
|
117
116
|
links?: Pick<DocsLink, "to">[];
|
|
118
117
|
} | "";
|
|
119
118
|
/**
|
|
120
|
-
* The first start link that opens a docs page outside the docs base, such as an Introduction outside every
|
|
121
|
-
* It leads the start section, so the links that open it begin there. `
|
|
119
|
+
* The first start link that opens a docs page to read outside the docs base, such as an Introduction outside every
|
|
120
|
+
* section. It leads the start section, so the links that open it begin there. A `home`, `playground` or `learn` page is
|
|
121
|
+
* not a page to read first. `null` when no start link is such a page.
|
|
122
122
|
*/
|
|
123
123
|
export declare function docsStartPage(manifest: DocsManifest<DocsAppPage>, start?: DocsStart): string | null;
|
|
124
124
|
/**
|
|
@@ -249,6 +249,11 @@ export declare function docsRawSectionLinks(manifest: DocsManifest, path: string
|
|
|
249
249
|
* that serves prerendered HTML reads it.
|
|
250
250
|
*/
|
|
251
251
|
export declare const docsTutorialNavigationCookie = "vh-tutorial-navigation";
|
|
252
|
+
/**
|
|
253
|
+
* Whether a layout fills the page with a workspace: `playground` and `learn`. Such a page renders in the docs shell
|
|
254
|
+
* wherever it lives, and fills the viewport under the header.
|
|
255
|
+
*/
|
|
256
|
+
export declare function isDocsWorkspaceLayout(layout: DocsLayout | undefined): layout is "playground" | "learn";
|
|
252
257
|
/** Whether a docs page starts with its sidebar collapsed: `sidebar: "collapsed"`, or a code panel tutorial that keeps it. */
|
|
253
258
|
export declare function docsSidebarCollapses(page: Pick<DocsPage, "sidebar" | "codePanel">): boolean;
|
|
254
259
|
/** Links of the page actions: the Markdown twin and chat tools that read it. */
|
|
@@ -279,5 +284,4 @@ export declare function docsMcpInstallLinks(server: {
|
|
|
279
284
|
* query words come first, then the higher score: page titles over headings and keywords over text. Titles tolerate typos and prefixes, text
|
|
280
285
|
* matches whole words and prefixes. Ties keep the order of the index, which follows the navigation.
|
|
281
286
|
*/
|
|
282
|
-
export declare function createDocsSearch(records: readonly DocsSearchSection[]): (query: string, limit: number) => DocsSearchSection[];
|
|
283
|
-
//#endregion
|
|
287
|
+
export declare function createDocsSearch(records: readonly DocsSearchSection[]): (query: string, limit: number) => DocsSearchSection[];
|
package/dist/navigation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/navigation.ts
|
|
2
2
|
/** Every page of the manifest, root first. */
|
|
3
3
|
function docsManifestPages(manifest) {
|
|
4
4
|
return [
|
|
@@ -9,7 +9,7 @@ function docsManifestPages(manifest) {
|
|
|
9
9
|
}
|
|
10
10
|
/** A URL path without a trailing slash or `/index`, as the manifest stores it. */
|
|
11
11
|
function normalizeDocsPath(path) {
|
|
12
|
-
return path.replace(
|
|
12
|
+
return path.replace(/\/+(?:index\/*)?$/, "") || "/";
|
|
13
13
|
}
|
|
14
14
|
/** A browser URL for an app-relative route or asset. Router links keep their app-relative paths. */
|
|
15
15
|
function docsAppPath(path, appBase = "/") {
|
|
@@ -76,12 +76,14 @@ function docsSectionHome(section) {
|
|
|
76
76
|
return (section.pages.find((page) => page.path === section.path) ?? section.pages.find((page) => page.navigation) ?? section.pages[0])?.path ?? section.path;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* The first start link that opens a docs page outside the docs base, such as an Introduction outside every
|
|
80
|
-
* It leads the start section, so the links that open it begin there. `
|
|
79
|
+
* The first start link that opens a docs page to read outside the docs base, such as an Introduction outside every
|
|
80
|
+
* section. It leads the start section, so the links that open it begin there. A `home`, `playground` or `learn` page is
|
|
81
|
+
* not a page to read first. `null` when no start link is such a page.
|
|
81
82
|
*/
|
|
82
83
|
function docsStartPage(manifest, start) {
|
|
83
|
-
|
|
84
|
-
const
|
|
84
|
+
if (!start || !start.links?.length) return null;
|
|
85
|
+
const pages = new Set(docsManifestPages(manifest).filter((page) => page !== manifest.root && page.layout !== "home" && !isDocsWorkspaceLayout(page.layout)).map((page) => page.path));
|
|
86
|
+
const link = start.links.find((candidate) => pages.has(normalizeDocsPath(candidate.to)));
|
|
85
87
|
return link ? normalizeDocsPath(link.to) : null;
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
@@ -162,7 +164,10 @@ function docsRailEntries(manifest, options) {
|
|
|
162
164
|
const members = /* @__PURE__ */ new Map();
|
|
163
165
|
for (const section of manifest.sections) {
|
|
164
166
|
const title = docsSectionGroup(section, options.groups);
|
|
165
|
-
if (title
|
|
167
|
+
if (title === null) continue;
|
|
168
|
+
const group = members.get(title);
|
|
169
|
+
if (group) group.push(section);
|
|
170
|
+
else members.set(title, [section]);
|
|
166
171
|
}
|
|
167
172
|
const placed = /* @__PURE__ */ new Set();
|
|
168
173
|
return railGroups.map((sections) => sections.flatMap((section) => {
|
|
@@ -246,7 +251,9 @@ function sidebarGroups(pages, fold) {
|
|
|
246
251
|
for (const page of pages) {
|
|
247
252
|
if (!page.navigation) continue;
|
|
248
253
|
const label = page.group?.trim() || null;
|
|
249
|
-
|
|
254
|
+
const group = groups.get(label);
|
|
255
|
+
if (group) group.push(page);
|
|
256
|
+
else groups.set(label, [page]);
|
|
250
257
|
}
|
|
251
258
|
return [...groups].map(([label, groupPages]) => {
|
|
252
259
|
const heading = groupPages.length > 1 ? label : null;
|
|
@@ -389,6 +396,13 @@ function docsRawSectionLinks(manifest, path, siteUrl) {
|
|
|
389
396
|
* that serves prerendered HTML reads it.
|
|
390
397
|
*/
|
|
391
398
|
const docsTutorialNavigationCookie = "vh-tutorial-navigation";
|
|
399
|
+
/**
|
|
400
|
+
* Whether a layout fills the page with a workspace: `playground` and `learn`. Such a page renders in the docs shell
|
|
401
|
+
* wherever it lives, and fills the viewport under the header.
|
|
402
|
+
*/
|
|
403
|
+
function isDocsWorkspaceLayout(layout) {
|
|
404
|
+
return layout === "playground" || layout === "learn";
|
|
405
|
+
}
|
|
392
406
|
/** Whether a docs page starts with its sidebar collapsed: `sidebar: "collapsed"`, or a code panel tutorial that keeps it. */
|
|
393
407
|
function docsSidebarCollapses(page) {
|
|
394
408
|
return page.sidebar === "collapsed" || page.codePanel === true && page.sidebar !== false;
|
|
@@ -515,5 +529,4 @@ function createDocsSearch(records) {
|
|
|
515
529
|
return hits.slice(0, limit).map((hit) => hit.entry.record);
|
|
516
530
|
};
|
|
517
531
|
}
|
|
518
|
-
|
|
519
|
-
export { createDocsSearch, docsAppPath, docsCanonicalUrl, docsCatalog, docsHasRail, docsHomePath, docsIconStroke, docsIndexedPages, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsPageIndexed, docsPanelGroupWindow, docsPanelOf, docsPanelPages, docsPanelSidebarGroups, docsPanelWindow, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRailTarget, docsRawFile, docsRawPath, docsRawSectionLinks, docsRawSectionLinksMarker, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionHome, docsSectionIcon, docsSectionPanels, docsSidebarCollapses, docsSidebarGroup, docsSidebarGroups, docsSidebarSections, docsStartPage, docsTutorialNavigationCookie, docsUnindexedSearchSections, findDocsPage, isDocsPath, loadDocsPanels, normalizeDocsBase, normalizeDocsPath };
|
|
532
|
+
export { createDocsSearch, docsAppPath, docsCanonicalUrl, docsCatalog, docsHasRail, docsHomePath, docsIconStroke, docsIndexedPages, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsPageIndexed, docsPanelGroupWindow, docsPanelOf, docsPanelPages, docsPanelSidebarGroups, docsPanelWindow, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRailTarget, docsRawFile, docsRawPath, docsRawSectionLinks, docsRawSectionLinksMarker, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionHome, docsSectionIcon, docsSectionPanels, docsSidebarCollapses, docsSidebarGroup, docsSidebarGroups, docsSidebarSections, docsStartPage, docsTutorialNavigationCookie, docsUnindexedSearchSections, findDocsPage, isDocsPath, isDocsWorkspaceLayout, loadDocsPanels, normalizeDocsBase, normalizeDocsPath };
|