@vite-hub/docs 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -19
- package/dist/{agent-copy-BJp_Yf5d.js → agent-copy-xPaWye_g.js} +1 -1
- package/dist/assistant-pages-CqNlHsx-.js +37 -0
- package/dist/{assistant-shared-Dll_F_yy.d.ts → assistant-shared-CWIKRtBv.d.ts} +3 -2
- package/dist/{assistant-shared-CdtXowot.js → assistant-shared-DhiLHKSl.js} +23 -7
- package/dist/assistant-worker.d.ts +1 -1
- package/dist/assistant-worker.js +1 -1
- package/dist/assistant.d.ts +1 -1
- package/dist/assistant.js +1 -1
- package/dist/{content-9CINWiRf.js → content-BQVlMshL.js} +57 -47
- package/dist/{draft-DUBx--r9.js → draft-CSsTYSeb.js} +2 -2
- package/dist/error-diagnostics-CmgtG9xa.js +157 -0
- package/dist/files-UY4h1_36.js +38 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +4 -4
- package/dist/link-checker-redirects.js +1 -1
- package/dist/{manifest-Dzp5-_AJ.d.ts → manifest-Drbdw1us.d.ts} +9 -3
- package/dist/{manifest-D66AEF8F.js → manifest-DvECmwX-.js} +101 -51
- package/dist/{markdown-Cn9-4oVG.js → markdown-1M1FbjCw.js} +1 -1
- package/dist/{page-Dx2JD3y1.d.ts → markdown-BiKrT08O.d.ts} +2 -25
- package/dist/navigation.d.ts +10 -5
- package/dist/navigation.js +23 -10
- package/dist/{nuxt-B5LrERKc.d.ts → nuxt-8O2OB_hI.d.ts} +84 -7
- package/dist/nuxt.d.ts +2 -2
- package/dist/nuxt.js +1699 -105
- package/dist/{page-BbmSfZO8.js → page-Bb0TfRKi.js} +21 -4
- package/dist/page-BryUCmYf.d.ts +26 -0
- package/dist/primitive-rail.d.ts +2 -5
- package/dist/primitive-rail.js +8 -6
- package/dist/{raw-C03EUJKw.js → raw-BChwipz_.js} +6 -0
- package/dist/redirects-BJj58IsY.js +87 -0
- package/dist/runnable.d.ts +37 -0
- package/dist/runnable.js +105 -0
- package/dist/runtime/app/components/DocsAsideLeftBody.vue +2 -8
- package/dist/runtime/app/components/DocsLearn.vue +215 -0
- package/dist/runtime/app/components/DocsLearnCodePre.vue +98 -0
- package/dist/runtime/app/components/DocsLearnFile.vue +21 -0
- package/dist/runtime/app/components/DocsPage.vue +11 -5
- package/dist/runtime/app/components/DocsPlayground.vue +117 -0
- package/dist/runtime/app/components/content/Example.vue +18 -49
- package/dist/runtime/app/components/content/McpClient.vue +170 -0
- package/dist/runtime/app/components/content/McpInstall.vue +238 -0
- package/dist/runtime/app/components/content/PageList.vue +1 -5
- package/dist/runtime/app/layouts/docs.vue +36 -8
- package/dist/runtime/app/middleware/docs-layout.ts +2 -2
- package/dist/runtime/app/utils/docs-learn.ts +31 -0
- package/dist/runtime/app/utils/docs-playground.ts +3 -0
- package/dist/runtime/server/llms.js +1 -1
- package/dist/runtime/server/markdown.d.ts +0 -5
- package/dist/runtime/server/markdown.js +10 -1
- package/dist/runtime/server/mcp.js +1 -1
- package/dist/runtime/server/page.d.ts +1 -1
- package/dist/runtime/server/page.js +3 -3
- package/dist/runtime/server/raw.js +2 -9
- package/dist/runtime/server/search.d.ts +1 -1
- package/dist/runtime/server/search.js +3 -2
- package/dist/runtime/server/sitemap.js +1 -1
- package/dist/{schema-DwpXW0VZ.js → schema-DcWZ3Q3M.js} +97 -5
- package/dist/server.d.ts +3 -2
- package/dist/server.js +4 -4
- package/dist/snapshot-worker.mjs +40 -0
- package/dist/steps-DBlkJwtD.d.ts +105 -0
- package/dist/steps-DF-11dJn.js +32 -0
- package/dist/{types-BhG6vGfG.d.ts → types-CHU_fy9l.d.ts} +69 -4
- package/package.json +18 -11
- package/dist/error-diagnostics-BoOsP6Y4.js +0 -53
- package/dist/redirects-BrbWFSzW.js +0 -62
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as docsContent } from "../../content-
|
|
1
|
+
import { n as docsContent } from "../../content-BQVlMshL.js";
|
|
2
2
|
import { docsCanonicalUrl } from "../../navigation.js";
|
|
3
3
|
import { useRuntimeConfig } from "nitro/runtime-config";
|
|
4
4
|
import { defineHandler } from "nitro/h3";
|
|
@@ -3,13 +3,23 @@ import { z } from "zod";
|
|
|
3
3
|
/**
|
|
4
4
|
* How a page renders. `article` is prose with an outline, `tutorial` numbers its steps, `landing` is a wide Overview,
|
|
5
5
|
* and `home` is the page's own blocks at full width under the site header, without the docs sidebar, such as a
|
|
6
|
-
* product home page.
|
|
6
|
+
* product home page. `playground` and `learn` fill the page with a code workspace: `playground` opens the apps of
|
|
7
|
+
* `examples`, and `learn` runs the `::tutorial-step` blocks of a lesson on its `fixture`.
|
|
7
8
|
*/
|
|
8
9
|
const docsLayouts = [
|
|
9
10
|
"article",
|
|
10
11
|
"tutorial",
|
|
11
12
|
"landing",
|
|
12
|
-
"home"
|
|
13
|
+
"home",
|
|
14
|
+
"playground",
|
|
15
|
+
"learn"
|
|
16
|
+
];
|
|
17
|
+
const connectProviders = [
|
|
18
|
+
"anthropic",
|
|
19
|
+
"github",
|
|
20
|
+
"netlify",
|
|
21
|
+
"openai",
|
|
22
|
+
"vercel"
|
|
13
23
|
];
|
|
14
24
|
const navigationFields = {
|
|
15
25
|
title: z.string().optional(),
|
|
@@ -24,6 +34,16 @@ const seoFields = {
|
|
|
24
34
|
image: z.union([z.string(), z.literal(false)]).optional(),
|
|
25
35
|
index: z.boolean().optional()
|
|
26
36
|
};
|
|
37
|
+
const exampleFields = {
|
|
38
|
+
id: z.string().regex(/^[\w-]+$/, "Use letters, digits, `-`, or `_`"),
|
|
39
|
+
label: z.string(),
|
|
40
|
+
group: z.string().optional(),
|
|
41
|
+
description: z.string().optional(),
|
|
42
|
+
dir: z.string(),
|
|
43
|
+
open: z.string().optional(),
|
|
44
|
+
preview: z.string().startsWith("/").optional(),
|
|
45
|
+
readonly: z.array(z.string()).optional()
|
|
46
|
+
};
|
|
27
47
|
const pageFields = {
|
|
28
48
|
title: z.string(),
|
|
29
49
|
description: z.string().optional(),
|
|
@@ -38,8 +58,77 @@ const pageFields = {
|
|
|
38
58
|
sidebar: z.union([z.boolean(), z.literal("collapsed")]).optional(),
|
|
39
59
|
toc: z.boolean().optional(),
|
|
40
60
|
navigation: z.union([z.literal(false), z.strictObject(navigationFields)]).optional(),
|
|
41
|
-
seo: z.strictObject(seoFields).optional()
|
|
61
|
+
seo: z.strictObject(seoFields).optional(),
|
|
62
|
+
examples: z.array(z.strictObject(exampleFields)).optional(),
|
|
63
|
+
tabs: z.array(z.strictObject({
|
|
64
|
+
value: z.string().regex(/^[a-z][\w-]*$/i, "Use letters, digits, `-`, or `_`, starting with a letter"),
|
|
65
|
+
label: z.string()
|
|
66
|
+
})).optional(),
|
|
67
|
+
render: z.string().optional(),
|
|
68
|
+
connect: z.array(z.enum(connectProviders)).min(1).optional(),
|
|
69
|
+
port: z.number().int().min(1).max(65535).optional(),
|
|
70
|
+
fixture: z.string().optional(),
|
|
71
|
+
guide: z.enum(["top", "side"]).optional(),
|
|
72
|
+
lesson: z.string().startsWith("/").optional(),
|
|
73
|
+
preview: z.string().startsWith("/").optional()
|
|
74
|
+
};
|
|
75
|
+
const layoutFields = {
|
|
76
|
+
examples: ["playground"],
|
|
77
|
+
tabs: ["playground"],
|
|
78
|
+
render: ["playground"],
|
|
79
|
+
connect: ["playground"],
|
|
80
|
+
port: ["playground", "learn"],
|
|
81
|
+
fixture: ["learn"],
|
|
82
|
+
guide: ["learn"],
|
|
83
|
+
lesson: ["learn"],
|
|
84
|
+
preview: ["learn"]
|
|
42
85
|
};
|
|
86
|
+
function checkLayoutFields(page, context) {
|
|
87
|
+
const layout = page.layout ?? "article";
|
|
88
|
+
for (const [field, layouts] of Object.entries(layoutFields)) {
|
|
89
|
+
if (page[field] === void 0 || layouts.includes(layout)) continue;
|
|
90
|
+
context.addIssue({
|
|
91
|
+
code: "custom",
|
|
92
|
+
path: [field],
|
|
93
|
+
message: `Only a page with \`layout: ${layouts.join("` or `layout: ")}\` reads \`${field}\``
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (layout === "playground") {
|
|
97
|
+
if (!page.examples?.length) context.addIssue({
|
|
98
|
+
code: "custom",
|
|
99
|
+
path: ["examples"],
|
|
100
|
+
message: "A playground page needs at least one example"
|
|
101
|
+
});
|
|
102
|
+
const ids = /* @__PURE__ */ new Set();
|
|
103
|
+
for (const [index, example] of (page.examples ?? []).entries()) {
|
|
104
|
+
if (ids.has(example.id)) context.addIssue({
|
|
105
|
+
code: "custom",
|
|
106
|
+
path: [
|
|
107
|
+
"examples",
|
|
108
|
+
index,
|
|
109
|
+
"id"
|
|
110
|
+
],
|
|
111
|
+
message: `Two examples have the id \`${example.id}\``
|
|
112
|
+
});
|
|
113
|
+
ids.add(example.id);
|
|
114
|
+
}
|
|
115
|
+
if (page.render !== void 0 && page.port !== void 0) context.addIssue({
|
|
116
|
+
code: "custom",
|
|
117
|
+
path: ["port"],
|
|
118
|
+
message: "A `render` page runs in the browser page and has no dev server port"
|
|
119
|
+
});
|
|
120
|
+
if (page.render !== void 0 && page.connect !== void 0) context.addIssue({
|
|
121
|
+
code: "custom",
|
|
122
|
+
path: ["connect"],
|
|
123
|
+
message: "A `render` page runs no app, so it has no accounts to connect"
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (layout === "learn" && page.fixture === void 0) context.addIssue({
|
|
127
|
+
code: "custom",
|
|
128
|
+
path: ["fixture"],
|
|
129
|
+
message: "A learn page needs the `fixture` folder of its app"
|
|
130
|
+
});
|
|
131
|
+
}
|
|
43
132
|
/**
|
|
44
133
|
* Frontmatter fields of a docs page as files store them, one Standard Schema per field. `docsCollection()` passes them
|
|
45
134
|
* to `documents()`, so the Console editor validates the same values that the build validates, and a save writes
|
|
@@ -57,8 +146,11 @@ const docsPageFields = {
|
|
|
57
146
|
"seo.image": seoFields.image,
|
|
58
147
|
"seo.index": seoFields.index
|
|
59
148
|
};
|
|
60
|
-
/**
|
|
61
|
-
|
|
149
|
+
/**
|
|
150
|
+
* The build validates frontmatter with this schema after `docsFrontmatter()` expanded its dotted keys. It also checks
|
|
151
|
+
* that the workspace fields sit on the layouts that read them.
|
|
152
|
+
*/
|
|
153
|
+
const docsPageSchema = z.strictObject(pageFields).superRefine(checkLayoutFields);
|
|
62
154
|
const docsSectionSchema = z.strictObject({
|
|
63
155
|
title: z.string().optional(),
|
|
64
156
|
icon: z.string().optional(),
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
1
|
+
import { a as docsSearchSections, i as docsMarkdown, n as DocsParserOptions, r as createDocsParser, t as DocsDocument } from "./markdown-BiKrT08O.js";
|
|
2
|
+
import { n as DocsPageResponse, r as docsPageResponse, t as DocsPageLink } from "./page-BryUCmYf.js";
|
|
3
|
+
import { a as createDocsContent, c as checkDocsLinks, i as DocsSourceInput, n as DocsManifestOptions, o as createDocsManifest, r as DocsSource, s as DocsLinkCheckOptions, t as DocsContentSource } from "./manifest-Drbdw1us.js";
|
|
3
4
|
//#region src/raw.d.ts
|
|
4
5
|
type RawMarkdownOptions = {
|
|
5
6
|
/** Origin that site-relative links point to, such as `https://vitehub.dev`. Empty keeps them relative. */
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as docsPageResponse } from "./page-
|
|
2
|
-
import {
|
|
3
|
-
import { t as toRawMarkdown } from "./raw-
|
|
4
|
-
import { a as docsSearchSections, i as docsMarkdown, t as createDocsParser } from "./markdown-
|
|
1
|
+
import { i as docsPageResponse } from "./page-Bb0TfRKi.js";
|
|
2
|
+
import { l as checkDocsLinks, n as createDocsContent, r as createDocsManifest } from "./manifest-DvECmwX-.js";
|
|
3
|
+
import { t as toRawMarkdown } from "./raw-BChwipz_.js";
|
|
4
|
+
import { a as docsSearchSections, i as docsMarkdown, t as createDocsParser } from "./markdown-1M1FbjCw.js";
|
|
5
5
|
export { checkDocsLinks, createDocsContent, createDocsManifest, createDocsParser, docsMarkdown, docsPageResponse, docsSearchSections, toRawMarkdown };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Runs in its own Node process, so the snapshot (hundreds of MiB in memory) does not share the heap of the docs build.
|
|
2
|
+
// node snapshot-worker.mjs <app dir> <out dir> <file prefix> <lockfile>
|
|
3
|
+
// Prints the written file names as JSON, with the SHA-256 of the joined parts and the sizes.
|
|
4
|
+
import { createHash } from "node:crypto"
|
|
5
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises"
|
|
6
|
+
import { dirname, resolve } from "node:path"
|
|
7
|
+
import { createNodeModulesSnapshot, packSnapshot } from "@vite-hub/web-container/snapshot"
|
|
8
|
+
|
|
9
|
+
const [dir, outDir, prefix, lockPath] = process.argv.slice(2)
|
|
10
|
+
// The lockfile pins every version, so two builds of one commit give the same bytes.
|
|
11
|
+
const lockfile = await readFile(lockPath, "utf8").catch((error) => {
|
|
12
|
+
if (error.code === "ENOENT") return undefined
|
|
13
|
+
throw error
|
|
14
|
+
})
|
|
15
|
+
let result
|
|
16
|
+
try {
|
|
17
|
+
result = await createNodeModulesSnapshot({ dir, lockfile })
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (lockfile === undefined || error?.code !== "WEB_CONTAINER_SNAPSHOT_LOCKFILE_MISMATCH") throw error
|
|
21
|
+
// The dependencies changed since the lockfile was written. Update it, keeping the versions that still fit.
|
|
22
|
+
console.warn(`[docs] ${lockPath} does not match the dependencies (${error.message.split("\n")[0]}). Updating it; commit the change.`)
|
|
23
|
+
result = await createNodeModulesSnapshot({ dir, lockfile, frozenLockfile: false })
|
|
24
|
+
}
|
|
25
|
+
if (result.lockfile !== lockfile) {
|
|
26
|
+
await mkdir(dirname(lockPath), { recursive: true })
|
|
27
|
+
await writeFile(lockPath, result.lockfile)
|
|
28
|
+
console.warn(`[docs] Wrote ${lockPath}. Commit it, so the next build installs the same versions.`)
|
|
29
|
+
}
|
|
30
|
+
const parts = packSnapshot(result.snapshot)
|
|
31
|
+
const hash = createHash("sha256")
|
|
32
|
+
for (const part of parts) hash.update(part)
|
|
33
|
+
const sha256 = hash.digest("hex")
|
|
34
|
+
const files = []
|
|
35
|
+
for (const [index, part] of parts.entries()) {
|
|
36
|
+
const file = `${prefix}.${sha256.slice(0, 12)}.${index}.bin`
|
|
37
|
+
await writeFile(resolve(outDir, file), part)
|
|
38
|
+
files.push(file)
|
|
39
|
+
}
|
|
40
|
+
console.log(JSON.stringify({ files, sha256, bytes: result.snapshot.byteLength, compressed: parts.reduce((total, part) => total + part.byteLength, 0) }))
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { c as DocsConnectProvider } from "./types-CHU_fy9l.js";
|
|
2
|
+
import { WorkspaceRenderContext, WorkspaceRenderResult } from "@vite-hub/ui/workspace";
|
|
3
|
+
import { Component } from "vue";
|
|
4
|
+
//#region src/runnable/steps.d.ts
|
|
5
|
+
/** Text files of an app, keyed by a relative path such as `server/api/greet.post.ts`. */
|
|
6
|
+
type TutorialFiles = Record<string, string>;
|
|
7
|
+
/** Binary files of an app, such as model weights, keyed by a relative path. */
|
|
8
|
+
type TutorialAssets = Record<string, Uint8Array>;
|
|
9
|
+
interface RunnableTutorialStep {
|
|
10
|
+
/** The `::tutorial-step` title. */
|
|
11
|
+
title: string;
|
|
12
|
+
/** The files that this step writes, with their final contents from the fixture. */
|
|
13
|
+
files: TutorialFiles;
|
|
14
|
+
}
|
|
15
|
+
/** What the workspace of one tutorial mounts, built from its lesson page and its fixture. */
|
|
16
|
+
interface RunnableTutorialData {
|
|
17
|
+
slug: string;
|
|
18
|
+
/** The docs page that holds the lesson prose. */
|
|
19
|
+
page: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
/** The files before step 1: the fixture without the files that the steps write, with the fixture's dependencies. */
|
|
23
|
+
files: TutorialFiles;
|
|
24
|
+
steps: RunnableTutorialStep[];
|
|
25
|
+
/** The parts of the `node_modules` snapshot and their SHA-256, for `fetchSnapshot()`. Without it, the workspace runs `npm install`. */
|
|
26
|
+
snapshot?: {
|
|
27
|
+
parts: string[];
|
|
28
|
+
sha256: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** A starting app of `/playground`, read from a fixture. */
|
|
32
|
+
interface PlaygroundTemplate {
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
/** The heading of the example in the examples menu. */
|
|
37
|
+
group?: string;
|
|
38
|
+
/** The file that the editor opens first. */
|
|
39
|
+
open?: string;
|
|
40
|
+
/** The path that the preview opens when the dev server is ready. */
|
|
41
|
+
preview?: string;
|
|
42
|
+
/** The paths of `files` that the editor does not let the reader change. */
|
|
43
|
+
readonly?: string[];
|
|
44
|
+
files: TutorialFiles;
|
|
45
|
+
/**
|
|
46
|
+
* The files that are not valid UTF-8, such as model weights. The page module of a `playground` page carries them.
|
|
47
|
+
* `#build/playground-templates.mjs` leaves them out.
|
|
48
|
+
*/
|
|
49
|
+
assets?: TutorialAssets;
|
|
50
|
+
/** The slug of the snapshot that this template mounts. Templates with the same dependencies share one. */
|
|
51
|
+
snapshotOf: string;
|
|
52
|
+
/** The parts of that snapshot and their SHA-256, for `fetchSnapshot()`. Without it, the workspace runs `npm install`. */
|
|
53
|
+
snapshot?: RunnableTutorialData["snapshot"];
|
|
54
|
+
}
|
|
55
|
+
/** An example of a `playground` page. Examples with the same `snapshotOf` mount one snapshot. A `render` page has none. */
|
|
56
|
+
type DocsPlaygroundExampleData = Omit<PlaygroundTemplate, "snapshotOf"> & {
|
|
57
|
+
snapshotOf?: string;
|
|
58
|
+
};
|
|
59
|
+
/** What the page module of a `playground` page holds, besides its loaders. */
|
|
60
|
+
interface DocsPlaygroundData {
|
|
61
|
+
layout: "playground";
|
|
62
|
+
examples: DocsPlaygroundExampleData[];
|
|
63
|
+
/** Without `render`: the port of the dev server. */
|
|
64
|
+
port: number;
|
|
65
|
+
/** Without `render`: the accounts that the reader can connect. */
|
|
66
|
+
connect?: DocsConnectProvider[];
|
|
67
|
+
}
|
|
68
|
+
/** What the page module of a `learn` page holds. */
|
|
69
|
+
interface DocsLearnData {
|
|
70
|
+
layout: "learn";
|
|
71
|
+
tutorial: RunnableTutorialData;
|
|
72
|
+
guide: "top" | "side";
|
|
73
|
+
port: number;
|
|
74
|
+
preview?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The default export of the `render` module of a `layout: playground` page. It gets the text files, and the open
|
|
78
|
+
* example with its binary files in `example.assets`.
|
|
79
|
+
*/
|
|
80
|
+
type DocsRenderFunction = (files: TutorialFiles, context: WorkspaceRenderContext) => WorkspaceRenderResult | Promise<WorkspaceRenderResult>;
|
|
81
|
+
/** An output tab of a `layout: playground` page, with the component that draws it. */
|
|
82
|
+
interface DocsWorkspaceTab {
|
|
83
|
+
value: string;
|
|
84
|
+
label: string;
|
|
85
|
+
component: () => Promise<{
|
|
86
|
+
default: Component;
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
/** The workspace of a `playground` or `learn` page, as `#build/docs/workspaces.mjs` loads it by page path. */
|
|
90
|
+
type DocsWorkspaceData = (DocsPlaygroundData & {
|
|
91
|
+
render?: () => Promise<{
|
|
92
|
+
default: DocsRenderFunction;
|
|
93
|
+
}>;
|
|
94
|
+
tabs?: DocsWorkspaceTab[];
|
|
95
|
+
}) | DocsLearnData;
|
|
96
|
+
/** The files at the start of step `index` (from 0), or at its end with `solution`. Each step builds on the one before. */
|
|
97
|
+
declare function tutorialStepFiles(tutorial: Pick<RunnableTutorialData, "files" | "steps">, index: number, state: "start" | "solution"): TutorialFiles;
|
|
98
|
+
/** Loads a lesson state, removing absent tutorial files while keeping unrelated reader additions. */
|
|
99
|
+
declare function tutorialWorkspaceFiles(tutorial: Pick<RunnableTutorialData, "files" | "steps">, current: TutorialFiles, target: TutorialFiles): TutorialFiles;
|
|
100
|
+
/** Whether going from `before` to `after` adds or removes a file that the dev server reads only when its process starts. */
|
|
101
|
+
declare function restartsDevServer(before: TutorialFiles, after: TutorialFiles): boolean;
|
|
102
|
+
/** The `dependencies` of a `package.json`, sorted, so two apps with the same install compare equal. Invalid JSON has its own key. */
|
|
103
|
+
declare function dependencyKey(packageJson: string | undefined): string;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { DocsWorkspaceData as a, RunnableTutorialData as c, dependencyKey as d, restartsDevServer as f, DocsRenderFunction as i, RunnableTutorialStep as l, tutorialWorkspaceFiles as m, DocsPlaygroundData as n, DocsWorkspaceTab as o, tutorialStepFiles as p, DocsPlaygroundExampleData as r, PlaygroundTemplate as s, DocsLearnData as t, TutorialFiles as u };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/runnable/steps.ts
|
|
2
|
+
/** The files at the start of step `index` (from 0), or at its end with `solution`. Each step builds on the one before. */
|
|
3
|
+
function tutorialStepFiles(tutorial, index, state) {
|
|
4
|
+
const last = state === "solution" ? index : index - 1;
|
|
5
|
+
const files = { ...tutorial.files };
|
|
6
|
+
for (let step = 0; step <= last && step < tutorial.steps.length; step++) Object.assign(files, tutorial.steps[step].files);
|
|
7
|
+
return files;
|
|
8
|
+
}
|
|
9
|
+
/** Loads a lesson state, removing absent tutorial files while keeping unrelated reader additions. */
|
|
10
|
+
function tutorialWorkspaceFiles(tutorial, current, target) {
|
|
11
|
+
const owned = /* @__PURE__ */ new Set([...Object.keys(tutorial.files), ...tutorial.steps.flatMap((step) => Object.keys(step.files))]);
|
|
12
|
+
const next = { ...current };
|
|
13
|
+
for (const path of owned) if (!(path in target)) delete next[path];
|
|
14
|
+
return Object.assign(next, target);
|
|
15
|
+
}
|
|
16
|
+
const startFiles = ["index.html"];
|
|
17
|
+
/** Whether going from `before` to `after` adds or removes a file that the dev server reads only when its process starts. */
|
|
18
|
+
function restartsDevServer(before, after) {
|
|
19
|
+
return startFiles.some((path) => path in before !== path in after);
|
|
20
|
+
}
|
|
21
|
+
/** The `dependencies` of a `package.json`, sorted, so two apps with the same install compare equal. Invalid JSON has its own key. */
|
|
22
|
+
function dependencyKey(packageJson) {
|
|
23
|
+
try {
|
|
24
|
+
const dependencies = packageJson ? JSON.parse(packageJson).dependencies : void 0;
|
|
25
|
+
const entries = dependencies && typeof dependencies === "object" ? Object.entries(dependencies) : [];
|
|
26
|
+
return JSON.stringify(entries.sort(([a], [b]) => a.localeCompare(b)));
|
|
27
|
+
} catch {
|
|
28
|
+
return "invalid";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { tutorialWorkspaceFiles as i, restartsDevServer as n, tutorialStepFiles as r, dependencyKey as t };
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { ConnectProviderName } from "@vite-hub/web-container/connect";
|
|
2
3
|
//#region src/schema.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* How a page renders. `article` is prose with an outline, `tutorial` numbers its steps, `landing` is a wide Overview,
|
|
5
6
|
* and `home` is the page's own blocks at full width under the site header, without the docs sidebar, such as a
|
|
6
|
-
* product home page.
|
|
7
|
+
* product home page. `playground` and `learn` fill the page with a code workspace: `playground` opens the apps of
|
|
8
|
+
* `examples`, and `learn` runs the `::tutorial-step` blocks of a lesson on its `fixture`.
|
|
7
9
|
*/
|
|
8
|
-
declare const docsLayouts: readonly ["article", "tutorial", "landing", "home"];
|
|
10
|
+
declare const docsLayouts: readonly ["article", "tutorial", "landing", "home", "playground", "learn"];
|
|
9
11
|
type DocsLayout = (typeof docsLayouts)[number];
|
|
12
|
+
/** An app of a `layout: playground` page. */
|
|
13
|
+
interface DocsPlaygroundExample {
|
|
14
|
+
/** The `?example=` value and the id in share links. */
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** The heading of the example in the examples menu. */
|
|
18
|
+
group?: string;
|
|
19
|
+
/** One line under the label in the examples menu and on the start screen. */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** The folder of the app, relative to the app root, such as `examples/hello`. */
|
|
22
|
+
dir: string;
|
|
23
|
+
/** The file that the editor opens first. Defaults to the first file. */
|
|
24
|
+
open?: string;
|
|
25
|
+
/** The path that the preview opens when the dev server is ready. Defaults to `/`. */
|
|
26
|
+
preview?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Text files of `dir` that the editor does not let the reader change, such as `["model.ts"]`. Code can still change
|
|
29
|
+
* them. A path that is not a text file of `dir` fails the build with `DOCS_WORKSPACE_READONLY_MISSING`.
|
|
30
|
+
*/
|
|
31
|
+
readonly?: string[];
|
|
32
|
+
}
|
|
33
|
+
/** An output tab of a `layout: playground` page. */
|
|
34
|
+
interface DocsPlaygroundTab {
|
|
35
|
+
/** Names the component that draws the tab: `messages` is `app/components/playground/PlaygroundTabMessages.vue`. */
|
|
36
|
+
value: string;
|
|
37
|
+
label: string;
|
|
38
|
+
}
|
|
39
|
+
/** An account that a playground page can connect: each one takes a token in its Connect tab. */
|
|
40
|
+
type DocsConnectProvider = Exclude<ConnectProviderName, "cloudflare">;
|
|
10
41
|
/** Navigation fields of a page. `false` keeps the page out of the sidebar. */
|
|
11
42
|
type DocsPageNavigation = false | {
|
|
12
43
|
/** Label in the sidebar. Defaults to the page title. */
|
|
@@ -49,6 +80,33 @@ interface DocsPageFrontmatter {
|
|
|
49
80
|
/** `false` hides the "On this page" outline. */
|
|
50
81
|
toc?: boolean;
|
|
51
82
|
navigation?: DocsPageNavigation;
|
|
83
|
+
/** `layout: playground` only. The apps that the workspace opens, in menu order. */
|
|
84
|
+
examples?: DocsPlaygroundExample[];
|
|
85
|
+
/** `layout: playground` only. More output tabs after the tabs of the runner. */
|
|
86
|
+
tabs?: DocsPlaygroundTab[];
|
|
87
|
+
/**
|
|
88
|
+
* `layout: playground` only. A module, relative to the app root, such as `app/playground/render.ts`, whose default
|
|
89
|
+
* export renders the files to HTML in the page. Without it, the examples run in a WebContainer.
|
|
90
|
+
*/
|
|
91
|
+
render?: string;
|
|
92
|
+
/**
|
|
93
|
+
* `layout: playground` without `render`. The accounts that the reader can connect in a Connect tab, such as
|
|
94
|
+
* `[github, vercel]`. A credential stays in the browser tab and reaches the app as an environment variable.
|
|
95
|
+
*/
|
|
96
|
+
connect?: DocsConnectProvider[];
|
|
97
|
+
/** `playground` and `learn` without `render`. The port of the dev server of the app. Defaults to `3000`. */
|
|
98
|
+
port?: number;
|
|
99
|
+
/** `layout: learn` only. The folder of the app after the last step, in the `docs.runnable.fixtures` folder. */
|
|
100
|
+
fixture?: string;
|
|
101
|
+
/** `layout: learn` only. Where the step text goes: `side` in a column beside the code (the default), or `top` over it. */
|
|
102
|
+
guide?: "top" | "side";
|
|
103
|
+
/**
|
|
104
|
+
* `layout: learn` only. The URL of the docs page whose `::tutorial-step` blocks are the steps, such as
|
|
105
|
+
* `/docs/getting-started/first-agent`. Defaults to this page, so the steps can live in the page itself.
|
|
106
|
+
*/
|
|
107
|
+
lesson?: string;
|
|
108
|
+
/** `layout: learn` only. The path that the preview opens when the dev server is ready. Defaults to `/`. */
|
|
109
|
+
preview?: string;
|
|
52
110
|
/**
|
|
53
111
|
* Search and share fields, when they differ from the page's own. `image` is the share image: a path in `public/` or a
|
|
54
112
|
* URL, or `false` for none. Without it the build renders one from the title and description. `index: false` asks
|
|
@@ -98,13 +156,18 @@ type Fields<T> = { [K in keyof T]-?: z.ZodType<T[K]>; };
|
|
|
98
156
|
* dotted keys back as dotted keys.
|
|
99
157
|
*/
|
|
100
158
|
declare const docsPageFields: Fields<DocsPageFile>;
|
|
101
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* The build validates frontmatter with this schema after `docsFrontmatter()` expanded its dotted keys. It also checks
|
|
161
|
+
* that the workspace fields sit on the layouts that read them.
|
|
162
|
+
*/
|
|
102
163
|
declare const docsPageSchema: z.ZodType<DocsPageFrontmatter>;
|
|
103
164
|
declare const docsSectionSchema: z.ZodType<DocsSectionFile>;
|
|
104
165
|
/** YAML keys such as `navigation.order: 2` become nested objects, as Markdown frontmatter writers expect. */
|
|
105
166
|
declare function expandDottedKeys(input: Record<string, unknown>): Record<string, unknown>;
|
|
106
167
|
//#endregion
|
|
107
168
|
//#region src/types.d.ts
|
|
169
|
+
/** The workspace fields of a `layout: playground` or `layout: learn` page, as its frontmatter sets them. */
|
|
170
|
+
type DocsPageWorkspace = Pick<DocsPageFrontmatter, "examples" | "tabs" | "render" | "connect" | "port" | "fixture" | "guide" | "lesson" | "preview">;
|
|
108
171
|
/**
|
|
109
172
|
* The fields of a page that the app reads. `useDocsManifest()` returns pages with only these fields, so every page of
|
|
110
173
|
* the site does not carry the text and SEO options of every other page. The page route returns the whole `DocsPage`.
|
|
@@ -161,6 +224,8 @@ interface DocsPage extends DocsAppPage {
|
|
|
161
224
|
image?: string | false;
|
|
162
225
|
index?: boolean;
|
|
163
226
|
};
|
|
227
|
+
/** On a `playground` or `learn` page: the fields that set up its workspace. */
|
|
228
|
+
workspace?: DocsPageWorkspace;
|
|
164
229
|
}
|
|
165
230
|
/** A folder under the docs base: one rail entry with its own page list. */
|
|
166
231
|
interface DocsSection<Page extends DocsAppPage = DocsPage> {
|
|
@@ -209,4 +274,4 @@ interface DocsSearchSection {
|
|
|
209
274
|
indexed?: false;
|
|
210
275
|
}
|
|
211
276
|
//#endregion
|
|
212
|
-
export {
|
|
277
|
+
export { docsPageFields as _, DocsSearchSection as a, expandDottedKeys as b, DocsConnectProvider as c, DocsPageFrontmatter as d, DocsPageNavigation as f, docsLayouts as g, DocsSectionFile as h, DocsPageWorkspace as i, DocsLayout as l, DocsPlaygroundTab as m, DocsManifest as n, DocsSection as o, DocsPlaygroundExample as p, DocsPage as r, DocsTocLink as s, DocsAppPage as t, DocsPageFile as u, docsPageSchema as v, docsSectionSchema as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A documentation site on ViteHub primitives: typed Markdown pages, navigation, tutorials, search, agent resources, Console editing, and a docs assistant.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"content",
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
"import": "./dist/nuxt.js",
|
|
51
51
|
"default": "./dist/nuxt.js"
|
|
52
52
|
},
|
|
53
|
+
"./runnable": {
|
|
54
|
+
"types": "./dist/runnable.d.ts",
|
|
55
|
+
"import": "./dist/runnable.js",
|
|
56
|
+
"default": "./dist/runnable.js"
|
|
57
|
+
},
|
|
53
58
|
"./server": {
|
|
54
59
|
"types": "./dist/server.d.ts",
|
|
55
60
|
"import": "./dist/server.js",
|
|
@@ -66,11 +71,12 @@
|
|
|
66
71
|
"@nuxt/fonts": "^1.2.0",
|
|
67
72
|
"@nuxt/kit": "4.6.2",
|
|
68
73
|
"@takumi-rs/core": "2.19.0",
|
|
69
|
-
"@vite-hub/content": "0.
|
|
70
|
-
"@vite-hub/rate-limit": "0.
|
|
71
|
-
"@vite-hub/source": "0.
|
|
72
|
-
"@vite-hub/ui": "0.
|
|
73
|
-
"@vite-hub/
|
|
74
|
+
"@vite-hub/content": "0.5.0",
|
|
75
|
+
"@vite-hub/rate-limit": "0.5.0",
|
|
76
|
+
"@vite-hub/source": "0.5.0",
|
|
77
|
+
"@vite-hub/ui": "0.5.0",
|
|
78
|
+
"@vite-hub/web-container": "0.5.0",
|
|
79
|
+
"@vite-hub/workspace": "0.5.0",
|
|
74
80
|
"@vueuse/core": "^14.4.0",
|
|
75
81
|
"comark-content": "0.5.1",
|
|
76
82
|
"comark-zoom": "^0.12.0",
|
|
@@ -94,8 +100,8 @@
|
|
|
94
100
|
"@nuxt/ui": "^4.12.0",
|
|
95
101
|
"@types/node": "^24.19.1",
|
|
96
102
|
"@vue/test-utils": "2.5.1",
|
|
97
|
-
"@vite-hub/agent": "0.
|
|
98
|
-
"@vite-hub/gateways": "0.
|
|
103
|
+
"@vite-hub/agent": "0.5.0",
|
|
104
|
+
"@vite-hub/gateways": "0.5.0",
|
|
99
105
|
"@vite-hub/icons": "0.1.0",
|
|
100
106
|
"@vite-hub/internal": "0.0.1",
|
|
101
107
|
"comark": "^0.9.0",
|
|
@@ -105,6 +111,7 @@
|
|
|
105
111
|
"linkedom": "^0.18.13",
|
|
106
112
|
"nitro": "^3.0.261103-rc",
|
|
107
113
|
"nuxt": "npm:nuxt-nightly@5.0.0-2611052317-a04317f",
|
|
114
|
+
"playwright-core": "^1.63.0",
|
|
108
115
|
"publint": "^0.3.25",
|
|
109
116
|
"tailwindcss": "^4.3.3",
|
|
110
117
|
"typescript": "^6.0.3",
|
|
@@ -117,8 +124,8 @@
|
|
|
117
124
|
"@comark/html": "^0.8.1 || ^0.9.0",
|
|
118
125
|
"@comark/vue": "^0.8.1 || ^0.9.0",
|
|
119
126
|
"@nuxt/ui": "^4.11.0",
|
|
120
|
-
"@vite-hub/agent": "0.
|
|
121
|
-
"@vite-hub/gateways": "0.
|
|
127
|
+
"@vite-hub/agent": "0.5.0",
|
|
128
|
+
"@vite-hub/gateways": "0.5.0",
|
|
122
129
|
"comark": "^0.8.1 || ^0.9.0",
|
|
123
130
|
"comark-ui": "^0.12.0",
|
|
124
131
|
"nuxt": ">=5.0.0-0",
|
|
@@ -133,7 +140,7 @@
|
|
|
133
140
|
}
|
|
134
141
|
},
|
|
135
142
|
"engines": {
|
|
136
|
-
"node": ">=
|
|
143
|
+
"node": ">=24.15.0"
|
|
137
144
|
},
|
|
138
145
|
"scripts": {
|
|
139
146
|
"build": "vp pack",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { defineDiagnostics } from "nostics";
|
|
2
|
-
//#region src/error-diagnostics.ts
|
|
3
|
-
const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
|
-
docsBase: "https://vitehub.dev/docs/docs-site/diagnostics",
|
|
5
|
-
codes: {
|
|
6
|
-
DOCS_ASSISTANT_AGENTS_MISSING: {
|
|
7
|
-
why: ({ agent }) => `[@vite-hub/docs] docs.assistant needs ViteHub Agents to answer from the "${agent}" Agent.`,
|
|
8
|
-
fix: "Add `vite-hub/nuxt` to modules and set `vitehub: { agent: true, connections: true }` in nuxt.config.ts, or set `docs: { assistant: false }`."
|
|
9
|
-
},
|
|
10
|
-
DOCS_COMMENTS_DATABASE_OFF: {
|
|
11
|
-
why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which keeps threads in the Database, but vitehub sets database: false.",
|
|
12
|
-
fix: "Remove `database: false` from the `vitehub` options in nuxt.config.ts, or set `docs: { comments: false }`."
|
|
13
|
-
},
|
|
14
|
-
DOCS_COMMENTS_PACKAGE_MISSING: {
|
|
15
|
-
why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which needs @vite-hub/comments.",
|
|
16
|
-
fix: "Run `pnpm add @vite-hub/comments`, or set `docs: { comments: false }` in nuxt.config.ts."
|
|
17
|
-
},
|
|
18
|
-
DOCS_COMMENTS_VITEHUB_MISSING: {
|
|
19
|
-
why: "[@vite-hub/docs] docs.comments needs vite-hub/nuxt, which keeps the threads in a ViteHub Database.",
|
|
20
|
-
fix: "Add `vite-hub/nuxt` to modules in nuxt.config.ts, or set `docs: { comments: false }`."
|
|
21
|
-
},
|
|
22
|
-
DOCS_CONTENT_INVALID: {
|
|
23
|
-
why: ({ details, file }) => `Invalid docs frontmatter in ${file}: ${details}`,
|
|
24
|
-
fix: "Fix the field that the message names in the page frontmatter or the `.navigation.yml` file. The schemas are `docsPageSchema` and `docsSectionSchema` from `@vite-hub/docs`."
|
|
25
|
-
},
|
|
26
|
-
DOCS_EXAMPLE_MISSING: {
|
|
27
|
-
why: ({ name }) => `::example names "${name}", but the examples folder has no ${name}.vue.`,
|
|
28
|
-
fix: "Add the component that the message names to the examples folder of the docs, or correct the `name` of the `::example` block."
|
|
29
|
-
},
|
|
30
|
-
DOCS_LINKS_BROKEN: {
|
|
31
|
-
why: ({ problems }) => `Broken docs links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
32
|
-
fix: "Fix each link that the message lists in the page that it names, or add the target to `checkDocsLinks({ excludeLinks })` when it is served outside the docs output."
|
|
33
|
-
},
|
|
34
|
-
DOCS_OUTPUT_MISSING: {
|
|
35
|
-
why: ({ root }) => `Docs output does not exist: ${root}`,
|
|
36
|
-
fix: "Build the docs site first, or pass `checkDocsLinks({ dir })` the folder that the build writes."
|
|
37
|
-
},
|
|
38
|
-
DOCS_REDIRECTS_BROKEN: {
|
|
39
|
-
why: ({ problems }) => `Docs redirects break links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
40
|
-
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."
|
|
41
|
-
},
|
|
42
|
-
DOCS_SEO_FAILED: {
|
|
43
|
-
why: ({ problems }) => `Docs pages fail the search checks:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
44
|
-
fix: "Fix each page that the message lists, or set `docs: { seoAudit: \"warn\" }` to log the problems without stopping the build."
|
|
45
|
-
},
|
|
46
|
-
DOCS_SOURCE_MOUNT_INVALID: {
|
|
47
|
-
why: ({ mount }) => `Invalid docs source mount: ${mount}`,
|
|
48
|
-
fix: "Set the `mount` of the docs source to a URL path such as `/guide`, without `.`, `..`, `?`, `#`, or backslash segments."
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
//#endregion
|
|
53
|
-
export { docsErrorDiagnostics as t };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { docsManifestPages, docsRawPath, docsSectionForPath, isDocsPath, normalizeDocsPath } from "./navigation.js";
|
|
2
|
-
import { t as docsErrorDiagnostics } from "./error-diagnostics-BoOsP6Y4.js";
|
|
3
|
-
//#region src/redirects.ts
|
|
4
|
-
/**
|
|
5
|
-
* The redirect route rules from an exact app path. Keep external targets so a chain can end at another site.
|
|
6
|
-
* A wildcard rule, such as `/docs/old/**`, has no single target page, so it is left out.
|
|
7
|
-
*/
|
|
8
|
-
function docsRedirects(routeRules) {
|
|
9
|
-
return Object.entries(routeRules).flatMap(([from, rule]) => {
|
|
10
|
-
const to = typeof rule?.redirect === "string" ? rule.redirect : rule?.redirect ? rule.redirect.to : void 0;
|
|
11
|
-
if (!to || from.includes("*") || !from.startsWith("/")) return [];
|
|
12
|
-
return [{
|
|
13
|
-
from,
|
|
14
|
-
to
|
|
15
|
-
}];
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/** A docs page or the Markdown copy of one that answers a URL path. */
|
|
19
|
-
function docsPaths(manifest) {
|
|
20
|
-
return new Set(docsManifestPages(manifest).flatMap((page) => [page.path, docsRawPath(page.path)]));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Redirects that break a link. A redirect from a docs page hides the page, as nobody can open it. A redirect into a
|
|
24
|
-
* section, the docs base, or `/raw/` must open a docs page or its Markdown copy, or another redirect. Other targets
|
|
25
|
-
* belong to the app, so they are not checked here. Each problem is one sentence that names the fix.
|
|
26
|
-
*/
|
|
27
|
-
function docsRedirectProblems(manifest, redirects) {
|
|
28
|
-
const pages = docsPaths(manifest);
|
|
29
|
-
const next = new Map(redirects.map((redirect) => [normalizeDocsPath(redirect.from), redirect.to]));
|
|
30
|
-
const problems = [];
|
|
31
|
-
for (const { from, to } of redirects) {
|
|
32
|
-
const source = normalizeDocsPath(from);
|
|
33
|
-
const page = docsManifestPages(manifest).find((candidate) => candidate.path === source || docsRawPath(candidate.path) === source);
|
|
34
|
-
if (page) problems.push(`The redirect from ${from} hides the page ${page.file}. Remove the route rule, or move the page.`);
|
|
35
|
-
const seen = /* @__PURE__ */ new Set([source]);
|
|
36
|
-
let end = to;
|
|
37
|
-
let target = targetPath(end);
|
|
38
|
-
while (target !== void 0 && next.has(target) && !seen.has(target)) {
|
|
39
|
-
seen.add(target);
|
|
40
|
-
end = next.get(target);
|
|
41
|
-
target = targetPath(end);
|
|
42
|
-
}
|
|
43
|
-
if (target === void 0) continue;
|
|
44
|
-
if (seen.has(target)) {
|
|
45
|
-
problems.push(`The redirect from ${from} comes back to ${target} and never reaches a page. Point one of its route rules to a page.`);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if ((target.startsWith("/raw/") || docsSectionForPath(manifest, target) !== null || manifest.base !== "/" && isDocsPath(target, manifest.base)) && !pages.has(target)) problems.push(`The redirect from ${from} goes to ${end}, which is not a docs page. Point it to a page, or remove the route rule.`);
|
|
49
|
-
}
|
|
50
|
-
return problems;
|
|
51
|
-
}
|
|
52
|
-
function targetPath(to) {
|
|
53
|
-
if (!to.startsWith("/") || to.startsWith("//")) return void 0;
|
|
54
|
-
return normalizeDocsPath(to.replace(/[?#].*$/, ""));
|
|
55
|
-
}
|
|
56
|
-
/** Redirect route rules that break links. The build stops on them while the link checker is on. */
|
|
57
|
-
/** `DOCS_REDIRECTS_BROKEN`, with the list of problems in `problems`. */
|
|
58
|
-
function docsRedirectError(problems) {
|
|
59
|
-
return Object.assign(docsErrorDiagnostics.DOCS_REDIRECTS_BROKEN({ problems }), { problems });
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { docsRedirectProblems as n, docsRedirects as r, docsRedirectError as t };
|