@takazudo/zudo-doc 10.0.3 → 12.0.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/CHANGELOG.md +47 -0
- package/dist/agent-docs/search.js +6 -3
- package/dist/asset-index-page/index.js +1 -1
- package/dist/asset-page/index.js +1 -1
- package/dist/asset-path/index.d.ts +2 -0
- package/dist/asset-path/index.js +1 -0
- package/dist/catalog.js +1 -1
- package/dist/chrome/derive.js +14 -2
- package/dist/compiled.css +178 -30
- package/dist/config-assertions/index.d.ts +54 -0
- package/dist/config-assertions/index.js +205 -0
- package/dist/config.d.ts +12 -9
- package/dist/config.js +13 -0
- package/dist/content/index.d.ts +1 -0
- package/dist/content/index.js +2 -0
- package/dist/content/wide-section-heading.d.ts +12 -0
- package/dist/content/wide-section-heading.js +8 -0
- package/dist/content-admonition/index.d.ts +2 -1
- package/dist/content-admonition/index.js +2 -1
- package/dist/doc-body-end-islands/index.d.ts +0 -7
- package/dist/doc-body-end-islands/index.js +0 -6
- package/dist/doc-card-nav/index.d.ts +78 -0
- package/dist/doc-card-nav/index.js +82 -0
- package/dist/doc-card-nav/slug.d.ts +6 -0
- package/dist/doc-card-nav/slug.js +6 -0
- package/dist/doc-page-renderer/index.d.ts +5 -0
- package/dist/doc-page-renderer/index.js +7 -0
- package/dist/doc-page-shell/index.d.ts +12 -0
- package/dist/doc-page-shell/index.js +6 -1
- package/dist/docs-schema/index.d.ts +2 -0
- package/dist/docs-schema/index.js +9 -0
- package/dist/features.css +201 -0
- package/dist/frontmatter-preview-defaults/index.js +3 -1
- package/dist/head-with-defaults/index.d.ts +20 -0
- package/dist/head-with-defaults/index.js +25 -3
- package/dist/home-hero/index.d.ts +36 -0
- package/dist/home-hero/index.js +128 -0
- package/dist/home-page/index.js +157 -58
- package/dist/i18n-defaults/index.js +8 -0
- package/dist/mcp/constants.d.ts +11 -0
- package/dist/mcp/constants.js +20 -0
- package/dist/mcp/discovery.d.ts +45 -0
- package/dist/mcp/discovery.js +138 -0
- package/dist/mcp/handler.js +5 -9
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +37 -1
- package/dist/md-utils/index.d.ts +6 -1
- package/dist/md-utils/index.js +3 -2
- package/dist/mdx-components/index.js +4 -7
- package/dist/mdx-components/vocabulary.d.ts +19 -0
- package/dist/mdx-components/vocabulary.js +32 -0
- package/dist/nav-indexing/doc-card-grid.d.ts +6 -0
- package/dist/nav-indexing/doc-card-grid.js +26 -16
- package/dist/plugins/internal/agent-export/components.d.ts +27 -0
- package/dist/plugins/internal/agent-export/components.js +125 -0
- package/dist/plugins/internal/agent-export/index.d.ts +4 -0
- package/dist/plugins/internal/agent-export/index.js +29 -8
- package/dist/plugins/internal/agent-export/normalize.d.ts +18 -1
- package/dist/plugins/internal/agent-export/normalize.js +91 -5
- package/dist/plugins/internal/llms-txt/dev-middleware.d.ts +2 -0
- package/dist/plugins/internal/llms-txt/dev-middleware.js +6 -1
- package/dist/plugins/internal/llms-txt/emit.js +8 -1
- package/dist/plugins/internal/llms-txt/generate.d.ts +2 -0
- package/dist/plugins/internal/llms-txt/generate.js +3 -0
- package/dist/plugins/internal/llms-txt/load.js +2 -2
- package/dist/plugins/internal/llms-txt/types.d.ts +4 -0
- package/dist/plugins/internal/search-index/collect.js +5 -4
- package/dist/plugins/internal/search-index/types.d.ts +2 -0
- package/dist/plugins/routes.js +6 -1
- package/dist/preset.d.ts +6 -1
- package/dist/preset.js +13 -1
- package/dist/robots.d.ts +14 -0
- package/dist/robots.js +22 -4
- package/dist/route-enumerators/index.d.ts +63 -2
- package/dist/route-enumerators/index.js +124 -21
- package/dist/routes/404.js +1 -1
- package/dist/routes/_context.d.ts +1 -1
- package/dist/routes/_context.js +6 -0
- package/dist/routes/ai-catalog.d.ts +5 -0
- package/dist/routes/ai-catalog.js +28 -0
- package/dist/routes/mcp-server-card.d.ts +5 -0
- package/dist/routes/mcp-server-card.js +24 -0
- package/dist/routes/sitemap.xml.js +19 -9
- package/dist/settings-defaults.js +1 -1
- package/dist/settings.d.ts +102 -6
- package/dist/sidebar/client-data.d.ts +1 -1
- package/dist/sidebar/client-data.js +2 -0
- package/dist/sidebar/types.d.ts +4 -0
- package/dist/sidebar-tree/build-tree.js +1 -0
- package/dist/sidebar-tree/types.d.ts +4 -0
- package/dist/site-schema/nav-tree.js +2 -0
- package/dist/site-schema/types.d.ts +3 -0
- package/dist/site-tree-nav/index.d.ts +18 -0
- package/dist/site-tree-nav/index.js +18 -3
- package/dist/site-tree-nav/normalize-island-props.d.ts +6 -0
- package/dist/site-tree-nav/normalize-island-props.js +15 -0
- package/dist/site-tree-nav-island/count.d.ts +3 -0
- package/dist/site-tree-nav-island/count.js +11 -0
- package/dist/site-tree-nav-island/index.d.ts +22 -2
- package/dist/site-tree-nav-island/index.js +272 -221
- package/dist/tag-pages/index.d.ts +1 -0
- package/dist/tag-pages/index.js +2 -2
- package/dist/theme-packs/bauhaus/meta.json +1 -1
- package/dist/theme-packs/bauhaus/pack.css +2 -2
- package/dist/theme-packs/beacon/meta.json +1 -1
- package/dist/theme-packs/beacon/pack.css +0 -15
- package/dist/theme-packs/eink/meta.json +1 -1
- package/dist/theme-packs/eink/pack.css +1 -14
- package/dist/theme.css +0 -16
- package/dist/versions-page/index.d.ts +1 -0
- package/dist/versions-page/index.js +1 -1
- package/dist/wind.json +4 -6
- package/eject/content-admonition/index.tsx +4 -9
- package/eject/sidebar/client-data.ts +3 -1
- package/eject/sidebar/types.ts +4 -0
- package/eject/site-tree-nav-island/count.ts +11 -0
- package/eject/site-tree-nav-island/index.tsx +359 -256
- package/package.json +19 -7
- package/routes-src/404.tsx +1 -1
- package/routes-src/_context.ts +3 -0
- package/routes-src/ai-catalog.tsx +26 -0
- package/routes-src/mcp-server-card.tsx +21 -0
- package/routes-src/sitemap.xml.tsx +36 -12
- package/dist/find-in-page/find-bar.d.ts +0 -11
- package/dist/find-in-page/find-bar.js +0 -103
- package/dist/find-in-page/find-in-page.d.ts +0 -17
- package/dist/find-in-page/find-in-page.js +0 -131
- package/dist/find-in-page/index.d.ts +0 -5
- package/dist/find-in-page/index.js +0 -52
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { SUPPORTED_PROTOCOL_VERSIONS } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import {
|
|
3
|
+
AI_CATALOG_SPEC_VERSION,
|
|
4
|
+
MCP_ENDPOINT_PATH,
|
|
5
|
+
MCP_SERVER_CARD_MEDIA_TYPE,
|
|
6
|
+
MCP_SERVER_CARD_PATH,
|
|
7
|
+
MCP_SERVER_CARD_SCHEMA,
|
|
8
|
+
MCP_SERVER_VERSION
|
|
9
|
+
} from "./constants.js";
|
|
10
|
+
const TITLE_MAX = 100;
|
|
11
|
+
const DESCRIPTION_MAX = 100;
|
|
12
|
+
const NAME_MAX = 200;
|
|
13
|
+
const SERVER_NAME_MAX = 64;
|
|
14
|
+
const ALLOW = "GET, HEAD, OPTIONS";
|
|
15
|
+
const CORS_HEADERS = {
|
|
16
|
+
"access-control-allow-origin": "*",
|
|
17
|
+
"access-control-allow-methods": "GET",
|
|
18
|
+
"access-control-allow-headers": "Content-Type, If-None-Match",
|
|
19
|
+
"access-control-expose-headers": "ETag"
|
|
20
|
+
};
|
|
21
|
+
const CACHE_CONTROL = "public, max-age=3600";
|
|
22
|
+
function mcpBasePath(base) {
|
|
23
|
+
const segments = base.split("/").filter(Boolean);
|
|
24
|
+
return segments.length > 0 ? `/${segments.join("/")}` : "";
|
|
25
|
+
}
|
|
26
|
+
function mcpPublicOrigin(siteUrl2, requestUrl) {
|
|
27
|
+
if (siteUrl2) {
|
|
28
|
+
try {
|
|
29
|
+
const url = new URL(siteUrl2);
|
|
30
|
+
if (url.protocol === "http:" || url.protocol === "https:") return url.origin;
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return new URL(requestUrl).origin;
|
|
35
|
+
}
|
|
36
|
+
function siteUrl(options, path) {
|
|
37
|
+
return new URL(`${mcpBasePath(options.base)}${path}`, options.origin).href;
|
|
38
|
+
}
|
|
39
|
+
function mcpEndpointUrl(options) {
|
|
40
|
+
return siteUrl(options, MCP_ENDPOINT_PATH);
|
|
41
|
+
}
|
|
42
|
+
function mcpServerCardUrl(options) {
|
|
43
|
+
return siteUrl(options, MCP_SERVER_CARD_PATH);
|
|
44
|
+
}
|
|
45
|
+
function clip(text, max) {
|
|
46
|
+
const chars = Array.from(text);
|
|
47
|
+
return chars.length <= max ? text : `${chars.slice(0, max - 1).join("")}\u2026`;
|
|
48
|
+
}
|
|
49
|
+
function cardTitle(siteName) {
|
|
50
|
+
const name = siteName.trim();
|
|
51
|
+
return name ? clip(name, TITLE_MAX) : void 0;
|
|
52
|
+
}
|
|
53
|
+
function serverName(base) {
|
|
54
|
+
const name = base.split("/").filter(Boolean).join("-").replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^[._-]+|[._-]+$/g, "").slice(0, SERVER_NAME_MAX);
|
|
55
|
+
return name || "docs";
|
|
56
|
+
}
|
|
57
|
+
function cardName(hostname, base) {
|
|
58
|
+
const server = serverName(base);
|
|
59
|
+
const namespace = hostname.toLowerCase().split(".").filter(Boolean).reverse().join(".").replace(/[^a-z0-9.-]+/g, "-").slice(0, NAME_MAX - server.length - 1).replace(/^[.-]+|[.-]+$/g, "");
|
|
60
|
+
return `${namespace || "localhost"}/${server}`;
|
|
61
|
+
}
|
|
62
|
+
function buildMcpServerCard(options) {
|
|
63
|
+
const { hostname } = new URL(options.origin);
|
|
64
|
+
const siteName = options.siteName.trim();
|
|
65
|
+
const title = cardTitle(siteName);
|
|
66
|
+
const describedSite = `Read-only search and fetch for the ${siteName} documentation.`;
|
|
67
|
+
return {
|
|
68
|
+
$schema: MCP_SERVER_CARD_SCHEMA,
|
|
69
|
+
name: cardName(hostname, options.base),
|
|
70
|
+
version: MCP_SERVER_VERSION,
|
|
71
|
+
description: siteName && Array.from(describedSite).length <= DESCRIPTION_MAX ? describedSite : "Read-only search and fetch for this documentation site.",
|
|
72
|
+
...title === void 0 ? {} : { title },
|
|
73
|
+
websiteUrl: siteUrl(options, "/"),
|
|
74
|
+
remotes: [{
|
|
75
|
+
type: "streamable-http",
|
|
76
|
+
url: mcpEndpointUrl(options),
|
|
77
|
+
supportedProtocolVersions: [...SUPPORTED_PROTOCOL_VERSIONS]
|
|
78
|
+
}]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function buildAiCatalog(options) {
|
|
82
|
+
const { hostname } = new URL(options.origin);
|
|
83
|
+
return {
|
|
84
|
+
specVersion: AI_CATALOG_SPEC_VERSION,
|
|
85
|
+
host: {
|
|
86
|
+
displayName: options.siteName.trim() || hostname,
|
|
87
|
+
identifier: hostname,
|
|
88
|
+
documentationUrl: siteUrl(options, "/")
|
|
89
|
+
},
|
|
90
|
+
entries: [{
|
|
91
|
+
identifier: `urn:air:${hostname}:mcp:${serverName(options.base)}`,
|
|
92
|
+
displayName: cardTitle(options.siteName) ?? hostname,
|
|
93
|
+
type: MCP_SERVER_CARD_MEDIA_TYPE,
|
|
94
|
+
url: mcpServerCardUrl(options)
|
|
95
|
+
}]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function strongEtag(body) {
|
|
99
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(body));
|
|
100
|
+
const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
101
|
+
return `"${hex.slice(0, 32)}"`;
|
|
102
|
+
}
|
|
103
|
+
function ifNoneMatchHits(header, etag) {
|
|
104
|
+
if (header === null) return false;
|
|
105
|
+
if (header.trim() === "*") return true;
|
|
106
|
+
return header.split(",").some((tag) => tag.trim().replace(/^W\//, "") === etag);
|
|
107
|
+
}
|
|
108
|
+
async function respondWithDiscoveryDocument(request, document, mediaType) {
|
|
109
|
+
if (request.method === "OPTIONS") {
|
|
110
|
+
return new Response(null, { status: 204, headers: { ...CORS_HEADERS, allow: ALLOW, "access-control-max-age": "86400" } });
|
|
111
|
+
}
|
|
112
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
113
|
+
return new Response(JSON.stringify({ error: "Method not allowed." }), {
|
|
114
|
+
status: 405,
|
|
115
|
+
headers: { allow: ALLOW, "content-type": "application/json; charset=utf-8", "cache-control": "no-store" }
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const body = `${JSON.stringify(document, null, 2)}
|
|
119
|
+
`;
|
|
120
|
+
const etag = await strongEtag(body);
|
|
121
|
+
const headers = { ...CORS_HEADERS, "cache-control": CACHE_CONTROL, etag, "x-content-type-options": "nosniff" };
|
|
122
|
+
if (ifNoneMatchHits(request.headers.get("if-none-match"), etag)) {
|
|
123
|
+
return new Response(null, { status: 304, headers });
|
|
124
|
+
}
|
|
125
|
+
return new Response(request.method === "HEAD" ? null : body, {
|
|
126
|
+
status: 200,
|
|
127
|
+
headers: { ...headers, "content-type": mediaType }
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
buildAiCatalog,
|
|
132
|
+
buildMcpServerCard,
|
|
133
|
+
mcpBasePath,
|
|
134
|
+
mcpEndpointUrl,
|
|
135
|
+
mcpPublicOrigin,
|
|
136
|
+
mcpServerCardUrl,
|
|
137
|
+
respondWithDiscoveryDocument
|
|
138
|
+
};
|
package/dist/mcp/handler.js
CHANGED
|
@@ -4,6 +4,8 @@ import { z } from "zod";
|
|
|
4
4
|
import { AGENT_MAX_POST_BYTES, AGENT_MAX_TOOL_RESPONSE_BYTES } from "../agent-docs/limits.js";
|
|
5
5
|
import { searchAgentIndex } from "../agent-docs/search.js";
|
|
6
6
|
import { AgentCorpusLoader, CorpusUnavailable } from "./loader.js";
|
|
7
|
+
import { MCP_SERVER_NAME, MCP_SERVER_VERSION } from "./constants.js";
|
|
8
|
+
import { mcpPublicOrigin } from "./discovery.js";
|
|
7
9
|
const encoder = new TextEncoder();
|
|
8
10
|
const annotations = { readOnlyHint: true, idempotentHint: true, destructiveHint: false, openWorldHint: false };
|
|
9
11
|
function json(body, status) {
|
|
@@ -47,13 +49,7 @@ function createMcpHandler(options) {
|
|
|
47
49
|
return async (request) => {
|
|
48
50
|
const requestOrigin = new URL(request.url).origin;
|
|
49
51
|
const origin = request.headers.get("origin");
|
|
50
|
-
const allowed = /* @__PURE__ */ new Set([requestOrigin]);
|
|
51
|
-
if (options.siteUrl) {
|
|
52
|
-
try {
|
|
53
|
-
allowed.add(new URL(options.siteUrl).origin);
|
|
54
|
-
} catch {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
52
|
+
const allowed = /* @__PURE__ */ new Set([requestOrigin, mcpPublicOrigin(options.siteUrl, request.url)]);
|
|
57
53
|
const cors = origin && allowed.has(origin) ? origin : void 0;
|
|
58
54
|
const finish = (response) => {
|
|
59
55
|
const headers = new Headers(response.headers);
|
|
@@ -91,8 +87,8 @@ function createMcpHandler(options) {
|
|
|
91
87
|
if (error instanceof CorpusUnavailable) return finish(json({ error: error.message }, 503));
|
|
92
88
|
throw error;
|
|
93
89
|
}
|
|
94
|
-
const server = new McpServer({ name:
|
|
95
|
-
const publicOrigin = options.siteUrl
|
|
90
|
+
const server = new McpServer({ name: MCP_SERVER_NAME, version: MCP_SERVER_VERSION });
|
|
91
|
+
const publicOrigin = mcpPublicOrigin(options.siteUrl, request.url);
|
|
96
92
|
server.registerTool("search", { description: "Search published documentation.", inputSchema: { query: z.string() }, outputSchema: { results: z.array(z.object({ id: z.string(), title: z.string(), url: z.string() })) }, annotations }, async ({ query }) => {
|
|
97
93
|
const corpus = await loader.corpus();
|
|
98
94
|
const outcome = searchAgentIndex(corpus.index, query);
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -2,3 +2,6 @@ export { createMcpHandler } from "./handler.js";
|
|
|
2
2
|
export { AgentCorpusLoader, CorpusUnavailable } from "./loader.js";
|
|
3
3
|
export type { McpHandlerOptions } from "./handler.js";
|
|
4
4
|
export type { ReadAsset } from "./loader.js";
|
|
5
|
+
export { AI_CATALOG_MEDIA_TYPE, AI_CATALOG_SPEC_VERSION, AI_CATALOG_WELL_KNOWN_PATH, MCP_ENDPOINT_PATH, MCP_SERVER_CARD_MEDIA_TYPE, MCP_SERVER_CARD_PATH, MCP_SERVER_CARD_SCHEMA, MCP_SERVER_NAME, MCP_SERVER_VERSION, } from "./constants.js";
|
|
6
|
+
export { buildAiCatalog, buildMcpServerCard, mcpBasePath, mcpEndpointUrl, mcpPublicOrigin, mcpServerCardUrl, respondWithDiscoveryDocument, } from "./discovery.js";
|
|
7
|
+
export type { AiCatalog, McpDiscoveryOptions, McpServerCard } from "./discovery.js";
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
import { createMcpHandler } from "./handler.js";
|
|
2
2
|
import { AgentCorpusLoader, CorpusUnavailable } from "./loader.js";
|
|
3
|
+
import {
|
|
4
|
+
AI_CATALOG_MEDIA_TYPE,
|
|
5
|
+
AI_CATALOG_SPEC_VERSION,
|
|
6
|
+
AI_CATALOG_WELL_KNOWN_PATH,
|
|
7
|
+
MCP_ENDPOINT_PATH,
|
|
8
|
+
MCP_SERVER_CARD_MEDIA_TYPE,
|
|
9
|
+
MCP_SERVER_CARD_PATH,
|
|
10
|
+
MCP_SERVER_CARD_SCHEMA,
|
|
11
|
+
MCP_SERVER_NAME,
|
|
12
|
+
MCP_SERVER_VERSION
|
|
13
|
+
} from "./constants.js";
|
|
14
|
+
import {
|
|
15
|
+
buildAiCatalog,
|
|
16
|
+
buildMcpServerCard,
|
|
17
|
+
mcpBasePath,
|
|
18
|
+
mcpEndpointUrl,
|
|
19
|
+
mcpPublicOrigin,
|
|
20
|
+
mcpServerCardUrl,
|
|
21
|
+
respondWithDiscoveryDocument
|
|
22
|
+
} from "./discovery.js";
|
|
3
23
|
export {
|
|
24
|
+
AI_CATALOG_MEDIA_TYPE,
|
|
25
|
+
AI_CATALOG_SPEC_VERSION,
|
|
26
|
+
AI_CATALOG_WELL_KNOWN_PATH,
|
|
4
27
|
AgentCorpusLoader,
|
|
5
28
|
CorpusUnavailable,
|
|
6
|
-
|
|
29
|
+
MCP_ENDPOINT_PATH,
|
|
30
|
+
MCP_SERVER_CARD_MEDIA_TYPE,
|
|
31
|
+
MCP_SERVER_CARD_PATH,
|
|
32
|
+
MCP_SERVER_CARD_SCHEMA,
|
|
33
|
+
MCP_SERVER_NAME,
|
|
34
|
+
MCP_SERVER_VERSION,
|
|
35
|
+
buildAiCatalog,
|
|
36
|
+
buildMcpServerCard,
|
|
37
|
+
createMcpHandler,
|
|
38
|
+
mcpBasePath,
|
|
39
|
+
mcpEndpointUrl,
|
|
40
|
+
mcpPublicOrigin,
|
|
41
|
+
mcpServerCardUrl,
|
|
42
|
+
respondWithDiscoveryDocument
|
|
7
43
|
};
|
package/dist/md-utils/index.d.ts
CHANGED
|
@@ -62,10 +62,15 @@ export declare function collectMdFiles(dir: string): Array<{
|
|
|
62
62
|
* qualified URL is produced (matching the legacy llms-txt emitter's
|
|
63
63
|
* `slugToUrl(slug, locale, true)` call site exactly).
|
|
64
64
|
*
|
|
65
|
+
* `trailingSlash` mirrors the route layer's rule (`applyTrailingSlash` in
|
|
66
|
+
* `plugins/routes.ts`): when true, a slash is appended unless the path
|
|
67
|
+
* already ends with one, so the emitted URL is the served page rather than
|
|
68
|
+
* a redirect to it. Omitted means `false` (slash-less output).
|
|
69
|
+
*
|
|
65
70
|
* Callers must pass the EFFECTIVE slug (`data.slug ?? filesystem slug`) —
|
|
66
71
|
* the frontmatter override is resolved at the call site, not here.
|
|
67
72
|
*/
|
|
68
|
-
export declare function slugToUrl(slug: string, locale: string | null, base: string, siteUrl?: string): string;
|
|
73
|
+
export declare function slugToUrl(slug: string, locale: string | null, base: string, siteUrl?: string, trailingSlash?: boolean): string;
|
|
69
74
|
/**
|
|
70
75
|
* Parse a markdown file into frontmatter + body. Returns `null` when
|
|
71
76
|
* the file is unreadable so callers can simply skip it.
|
package/dist/md-utils/index.js
CHANGED
|
@@ -67,9 +67,10 @@ function collectMdFiles(dir) {
|
|
|
67
67
|
walk(dir, dir);
|
|
68
68
|
return results;
|
|
69
69
|
}
|
|
70
|
-
function slugToUrl(slug, locale, base, siteUrl) {
|
|
70
|
+
function slugToUrl(slug, locale, base, siteUrl, trailingSlash = false) {
|
|
71
71
|
const trimmedBase = base.replace(/\/$/, "");
|
|
72
|
-
const
|
|
72
|
+
const rawPath = locale ? `${trimmedBase}/${locale}/docs/${slug}` : `${trimmedBase}/docs/${slug}`;
|
|
73
|
+
const path = trailingSlash && !rawPath.endsWith("/") ? `${rawPath}/` : rawPath;
|
|
73
74
|
if (siteUrl) {
|
|
74
75
|
return `${siteUrl.replace(/\/$/, "")}${path}`;
|
|
75
76
|
}
|
|
@@ -3,6 +3,7 @@ import { defaultComponents } from "../content/index.js";
|
|
|
3
3
|
import { createContentLink } from "../content/content-link.js";
|
|
4
4
|
import { decodeAuthoredHref, assetViewerHref } from "../asset-path/index.js";
|
|
5
5
|
import { makeAdmonition } from "../content-admonition/index.js";
|
|
6
|
+
import { ADMONITION_COMPONENTS } from "./vocabulary.js";
|
|
6
7
|
import { CodeGroup } from "../code-group/index.js";
|
|
7
8
|
import { Tabs } from "../code-syntax/index.js";
|
|
8
9
|
import { TabItem } from "../tab-item/index.js";
|
|
@@ -149,13 +150,9 @@ function createMdxComponents(options) {
|
|
|
149
150
|
// targets. `:::note` directives emit <Note>; `<Note title="…">` JSX is
|
|
150
151
|
// also authored directly. github-alerts [!IMPORTANT]/[!CAUTION] map to
|
|
151
152
|
// Important/Caution — omitting those two 500s their SSR render.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Warning: makeAdmonition("warning"),
|
|
156
|
-
Danger: makeAdmonition("danger"),
|
|
157
|
-
Important: makeAdmonition("important"),
|
|
158
|
-
Caution: makeAdmonition("caution"),
|
|
153
|
+
...Object.fromEntries(
|
|
154
|
+
[...ADMONITION_COMPONENTS].map(([name, variant]) => [name, makeAdmonition(variant)])
|
|
155
|
+
),
|
|
159
156
|
// codeTabs Option A: zfb emits <CodeGroup tabs={[...]}> for :::code-group.
|
|
160
157
|
CodeGroup,
|
|
161
158
|
Tabs,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DirectiveSpec } from "@takazudo/zfb/config";
|
|
2
|
+
/** The JSX component a directive vocabulary entry resolves to. */
|
|
3
|
+
export declare function directiveComponentName(spec: DirectiveSpec): string;
|
|
4
|
+
/** Admonition variants, in registration order. */
|
|
5
|
+
export declare const ADMONITION_VARIANTS: readonly ["note", "tip", "info", "warning", "danger", "important", "caution"];
|
|
6
|
+
export type AdmonitionVariant = (typeof ADMONITION_VARIANTS)[number];
|
|
7
|
+
/** `"note"` → `"Note"`: both the MDX tag name and the default visible title. */
|
|
8
|
+
export declare function admonitionComponentName(variant: AdmonitionVariant): string;
|
|
9
|
+
/** MDX tag name → admonition variant. */
|
|
10
|
+
export declare const ADMONITION_COMPONENTS: ReadonlyMap<string, AdmonitionVariant>;
|
|
11
|
+
/** The collapsible the `:::details` directive resolves to. Its default title is "Details". */
|
|
12
|
+
export declare const DETAILS_COMPONENT: string;
|
|
13
|
+
/** Tab containers whose body is ordinary Markdown. */
|
|
14
|
+
export declare const TAB_GROUP_COMPONENTS: readonly ["Tabs", "CodeGroup"];
|
|
15
|
+
/** One labelled tab inside a tab container (`label` prop). */
|
|
16
|
+
export declare const TAB_ITEM_COMPONENT = "TabItem";
|
|
17
|
+
/** Navigation tags that list documents from the docs collection. */
|
|
18
|
+
export declare const NAV_COMPONENTS: readonly ["CategoryNav", "CategoryTreeNav", "SiteTreeNav", "SiteTreeNavDemo", "DocCardNav", "NoteTrayIndex"];
|
|
19
|
+
export type NavComponentName = (typeof NAV_COMPONENTS)[number];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defaultDirectiveVocabulary } from "../directive-vocabulary-defaults/index.js";
|
|
2
|
+
function directiveComponentName(spec) {
|
|
3
|
+
return typeof spec === "string" ? spec : spec.component;
|
|
4
|
+
}
|
|
5
|
+
const ADMONITION_VARIANTS = ["note", "tip", "info", "warning", "danger", "important", "caution"];
|
|
6
|
+
function admonitionComponentName(variant) {
|
|
7
|
+
return variant.charAt(0).toUpperCase() + variant.slice(1);
|
|
8
|
+
}
|
|
9
|
+
const ADMONITION_COMPONENTS = new Map(
|
|
10
|
+
ADMONITION_VARIANTS.map((variant) => [admonitionComponentName(variant), variant])
|
|
11
|
+
);
|
|
12
|
+
const DETAILS_COMPONENT = defaultDirectiveVocabulary.details ? directiveComponentName(defaultDirectiveVocabulary.details) : "Details";
|
|
13
|
+
const TAB_GROUP_COMPONENTS = ["Tabs", "CodeGroup"];
|
|
14
|
+
const TAB_ITEM_COMPONENT = "TabItem";
|
|
15
|
+
const NAV_COMPONENTS = [
|
|
16
|
+
"CategoryNav",
|
|
17
|
+
"CategoryTreeNav",
|
|
18
|
+
"SiteTreeNav",
|
|
19
|
+
"SiteTreeNavDemo",
|
|
20
|
+
"DocCardNav",
|
|
21
|
+
"NoteTrayIndex"
|
|
22
|
+
];
|
|
23
|
+
export {
|
|
24
|
+
ADMONITION_COMPONENTS,
|
|
25
|
+
ADMONITION_VARIANTS,
|
|
26
|
+
DETAILS_COMPONENT,
|
|
27
|
+
NAV_COMPONENTS,
|
|
28
|
+
TAB_GROUP_COMPONENTS,
|
|
29
|
+
TAB_ITEM_COMPONENT,
|
|
30
|
+
admonitionComponentName,
|
|
31
|
+
directiveComponentName
|
|
32
|
+
};
|
|
@@ -16,6 +16,12 @@ export interface DocCardGridProps {
|
|
|
16
16
|
ariaLabel?: string;
|
|
17
17
|
/** Optional extra CSS classes appended to the `<nav>` element. */
|
|
18
18
|
class?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Column layout. Omitted keeps the established one column, two from `sm`.
|
|
21
|
+
* `"auto"` fits as many ~18rem columns as the available width allows,
|
|
22
|
+
* capped at three: a lone card fills its section and further cards wrap.
|
|
23
|
+
*/
|
|
24
|
+
layout?: "auto";
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
27
|
* DocCardGrid — server renderer for a flat list of documentation cards.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
|
+
const AUTO_GRID_COLUMNS = "repeat(auto-fit, minmax(min(100%, max(18rem, calc((100% - 2 * var(--spacing-hsp-lg)) / 3))), 1fr))";
|
|
2
3
|
function ArrowIcon() {
|
|
3
4
|
return /* @__PURE__ */ jsx(
|
|
4
5
|
"svg",
|
|
@@ -12,27 +13,36 @@ function ArrowIcon() {
|
|
|
12
13
|
);
|
|
13
14
|
}
|
|
14
15
|
function DocCardGrid(props) {
|
|
15
|
-
const { items, ariaLabel = "Child pages", class: className } = props;
|
|
16
|
+
const { items, ariaLabel = "Child pages", class: className, layout } = props;
|
|
16
17
|
if (items.length === 0) return null;
|
|
18
|
+
const auto = layout === "auto";
|
|
17
19
|
const navClass = [
|
|
18
|
-
"grid grid-cols-1 gap-x-hsp-lg gap-y-vsp-md sm:grid-cols-2",
|
|
20
|
+
auto ? "grid gap-x-hsp-lg gap-y-vsp-md" : "grid grid-cols-1 gap-x-hsp-lg gap-y-vsp-md sm:grid-cols-2",
|
|
19
21
|
className
|
|
20
22
|
].filter(Boolean).join(" ");
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
"
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
"nav",
|
|
23
25
|
{
|
|
24
|
-
|
|
25
|
-
class:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
"aria-label": ariaLabel,
|
|
27
|
+
class: navClass,
|
|
28
|
+
...auto ? { "data-layout": "auto", style: { "grid-template-columns": AUTO_GRID_COLUMNS } } : {},
|
|
29
|
+
children: items.map((item, i) => /* @__PURE__ */ jsxs(
|
|
30
|
+
"a",
|
|
31
|
+
{
|
|
32
|
+
href: item.href,
|
|
33
|
+
class: "group block rounded border border-muted bg-surface px-hsp-lg py-vsp-md hover:border-accent",
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsxs("span", { class: "flex items-center gap-hsp-xs", children: [
|
|
36
|
+
/* @__PURE__ */ jsx(ArrowIcon, {}),
|
|
37
|
+
/* @__PURE__ */ jsx("span", { class: "font-medium text-fg group-hover:text-accent group-hover:underline group-focus-visible:text-accent group-focus-visible:underline", children: item.title })
|
|
38
|
+
] }),
|
|
39
|
+
item.description && /* @__PURE__ */ jsx("span", { class: "mt-vsp-2xs block text-small text-muted group-hover:text-accent group-focus-visible:text-accent", children: item.description })
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
`doc-card-${i}`
|
|
43
|
+
))
|
|
44
|
+
}
|
|
45
|
+
);
|
|
36
46
|
}
|
|
37
47
|
export {
|
|
38
48
|
DocCardGrid
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MdDocFrontmatter } from "../../../md-utils/index.js";
|
|
2
|
+
import type { CategoryMeta } from "../../../sidebar-tree/types.js";
|
|
3
|
+
import type { AgentComponentRenderer } from "./normalize.js";
|
|
4
|
+
/** One locale's docs as the export sees them, before export exclusions. */
|
|
5
|
+
export interface AgentNavLocale {
|
|
6
|
+
locale: string;
|
|
7
|
+
/** Every parsed file of the locale: `slug` is the filesystem route slug. */
|
|
8
|
+
entries: Array<{
|
|
9
|
+
slug: string;
|
|
10
|
+
data: MdDocFrontmatter;
|
|
11
|
+
}>;
|
|
12
|
+
categoryMeta?: Map<string, CategoryMeta>;
|
|
13
|
+
/** Effective route slug → published page URL, for documents in the export only. */
|
|
14
|
+
published: Map<string, {
|
|
15
|
+
url: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
}>;
|
|
19
|
+
siteTreeNavIgnore?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build the per-locale renderer for content wrappers and navigation tags. Nav
|
|
23
|
+
* output lists only documents in the published export, so draft, unlisted and
|
|
24
|
+
* search-excluded pages never appear; a group whose own page is excluded is
|
|
25
|
+
* dissolved and its published descendants move up a level.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createAgentComponentRenderer(source: AgentNavLocale): (currentSlug: string) => AgentComponentRenderer;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { isCanonicalDocSlug } from "../../../doc-card-nav/slug.js";
|
|
2
|
+
import {
|
|
3
|
+
ADMONITION_COMPONENTS,
|
|
4
|
+
admonitionComponentName,
|
|
5
|
+
DETAILS_COMPONENT,
|
|
6
|
+
TAB_GROUP_COMPONENTS,
|
|
7
|
+
TAB_ITEM_COMPONENT
|
|
8
|
+
} from "../../../mdx-components/vocabulary.js";
|
|
9
|
+
import { findContainingNoteTray, findNoteTray, getNoteTrayItems } from "../../../note-tray-model/index.js";
|
|
10
|
+
import { buildSidebarTree, findSidebarNode } from "../../../sidebar-tree/build-tree.js";
|
|
11
|
+
const isoDate = (value) => value instanceof Date ? value.toISOString().slice(0, 10) : value;
|
|
12
|
+
const linkLabel = (label) => label.replace(/[\\[\]]/g, (ch) => `\\${ch}`);
|
|
13
|
+
function line(node, depth, withDescription, suffix = "") {
|
|
14
|
+
const label = node.url === void 0 ? node.label : `[${linkLabel(node.label)}](${node.url})`;
|
|
15
|
+
const description = withDescription && node.description ? `: ${node.description}` : "";
|
|
16
|
+
return `${" ".repeat(depth)}- ${label}${suffix}${description}`;
|
|
17
|
+
}
|
|
18
|
+
function nestedList(nodes, withDescription, depth = 0) {
|
|
19
|
+
return nodes.flatMap((node) => [line(node, depth, withDescription), ...nestedList(node.children, withDescription, depth + 1)]);
|
|
20
|
+
}
|
|
21
|
+
const asString = (value) => typeof value === "string" ? value : void 0;
|
|
22
|
+
function wrapperLabel(kind, title, props) {
|
|
23
|
+
if (props === void 0 || title !== void 0 && typeof title !== "string") return { text: `**${kind}**`, unsupported: true };
|
|
24
|
+
return { text: title ? `**${kind}: ${title}**` : `**${kind}**` };
|
|
25
|
+
}
|
|
26
|
+
function createAgentComponentRenderer(source) {
|
|
27
|
+
const entries = source.entries.map(({ slug, data }) => ({
|
|
28
|
+
slug,
|
|
29
|
+
data: { ...data, date: isoDate(data.date), updated: isoDate(data.updated) }
|
|
30
|
+
}));
|
|
31
|
+
const hidden = new Set(entries.filter(({ data }) => data.search_exclude).map(({ slug, data }) => data.slug ?? slug));
|
|
32
|
+
const tree = buildSidebarTree(entries, source.locale, {
|
|
33
|
+
...source.categoryMeta ? { categoryMeta: source.categoryMeta } : {},
|
|
34
|
+
buildHref: (slug) => slug,
|
|
35
|
+
isNavVisible: ({ data }) => !data.draft && !data.unlisted && !data.standalone
|
|
36
|
+
});
|
|
37
|
+
const publish = (nodes) => nodes.flatMap((node) => {
|
|
38
|
+
const children = publish(node.children);
|
|
39
|
+
const page = source.published.get(node.id);
|
|
40
|
+
if (!page && (hidden.has(node.id) || children.length === 0)) return children;
|
|
41
|
+
return [{
|
|
42
|
+
slug: node.id,
|
|
43
|
+
label: node.label,
|
|
44
|
+
...node.description !== void 0 ? { description: node.description } : {},
|
|
45
|
+
...page ? { url: page.url } : {},
|
|
46
|
+
...node.date !== void 0 ? { date: node.date } : {},
|
|
47
|
+
...node.shape !== void 0 ? { shape: node.shape } : {},
|
|
48
|
+
hasPage: page !== void 0,
|
|
49
|
+
children
|
|
50
|
+
}];
|
|
51
|
+
});
|
|
52
|
+
const published = publish(tree);
|
|
53
|
+
const findPublished = (nodes, slug) => {
|
|
54
|
+
for (const node of nodes) {
|
|
55
|
+
if (node.slug === slug) return node;
|
|
56
|
+
const found = findPublished(node.children, slug);
|
|
57
|
+
if (found) return found;
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
60
|
+
};
|
|
61
|
+
const firstUrl = (node) => node.url ?? node.children.map(firstUrl).find((url) => url !== void 0);
|
|
62
|
+
const list = (lines) => lines.join("\n");
|
|
63
|
+
const nav = (name, props, currentSlug) => {
|
|
64
|
+
switch (name) {
|
|
65
|
+
case "CategoryNav": {
|
|
66
|
+
if (props.categories !== void 0) {
|
|
67
|
+
if (!Array.isArray(props.categories) || !props.categories.every((slug) => typeof slug === "string")) return void 0;
|
|
68
|
+
return list(props.categories.flatMap((slug) => {
|
|
69
|
+
const node = findSidebarNode(tree, slug);
|
|
70
|
+
const target = findPublished(published, slug);
|
|
71
|
+
const url = target && firstUrl(target);
|
|
72
|
+
if (!node || hidden.has(slug) || url === void 0) return [];
|
|
73
|
+
return [line({ label: node.label, url, ...node.description !== void 0 ? { description: node.description } : {} }, 0, true)];
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
if (props.category === void 0) return "";
|
|
77
|
+
const category = asString(props.category);
|
|
78
|
+
if (category === void 0) return void 0;
|
|
79
|
+
return list((findPublished(published, category)?.children ?? []).filter((node) => node.hasPage).map((node) => line(node, 0, true)));
|
|
80
|
+
}
|
|
81
|
+
case "CategoryTreeNav": {
|
|
82
|
+
const category = asString(props.category);
|
|
83
|
+
if (category === void 0) return void 0;
|
|
84
|
+
return list(nestedList(findPublished(published, category)?.children ?? [], false));
|
|
85
|
+
}
|
|
86
|
+
case "SiteTreeNav":
|
|
87
|
+
case "SiteTreeNavDemo": {
|
|
88
|
+
if (props.variant !== void 0 && props.variant !== "default" && props.variant !== "described") return void 0;
|
|
89
|
+
const ignore = new Set(source.siteTreeNavIgnore ?? []);
|
|
90
|
+
return list(nestedList(published.filter((node) => !ignore.has(node.slug)), props.variant === "described"));
|
|
91
|
+
}
|
|
92
|
+
case "NoteTrayIndex": {
|
|
93
|
+
if (props.category !== void 0 && typeof props.category !== "string") return void 0;
|
|
94
|
+
const tray = typeof props.category === "string" ? findNoteTray(published, props.category) : findContainingNoteTray(published, currentSlug);
|
|
95
|
+
if (!tray) return "";
|
|
96
|
+
return list(getNoteTrayItems(tray).filter((item) => item.url !== void 0).map((item) => line(item, 0, true, props.showDate === true && item.date ? ` (${item.date})` : "")));
|
|
97
|
+
}
|
|
98
|
+
case "DocCardNav": {
|
|
99
|
+
if (!Array.isArray(props.docs)) return void 0;
|
|
100
|
+
const seen = /* @__PURE__ */ new Set();
|
|
101
|
+
return list(props.docs.flatMap((slug) => {
|
|
102
|
+
if (!isCanonicalDocSlug(slug) || seen.has(slug)) return [];
|
|
103
|
+
seen.add(slug);
|
|
104
|
+
const page = source.published.get(slug);
|
|
105
|
+
return page ? [line({ label: page.title, url: page.url, ...page.description ? { description: page.description } : {} }, 0, true)] : [];
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
default:
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return (currentSlug) => (tag) => {
|
|
113
|
+
const variant = ADMONITION_COMPONENTS.get(tag.name);
|
|
114
|
+
if (variant) return wrapperLabel(admonitionComponentName(variant), tag.props?.title, tag.props);
|
|
115
|
+
if (tag.name === DETAILS_COMPONENT) return wrapperLabel(DETAILS_COMPONENT, tag.props?.title, tag.props);
|
|
116
|
+
if (tag.name === TAB_ITEM_COMPONENT) return wrapperLabel("Tab", tag.props?.label, tag.props);
|
|
117
|
+
if (TAB_GROUP_COMPONENTS.includes(tag.name)) return { text: "" };
|
|
118
|
+
if (!tag.props) return void 0;
|
|
119
|
+
const text = nav(tag.name, tag.props, currentSlug);
|
|
120
|
+
return text === void 0 ? void 0 : { text };
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
createAgentComponentRenderer
|
|
125
|
+
};
|
|
@@ -3,6 +3,8 @@ export interface AgentExportOptions {
|
|
|
3
3
|
outDir?: string;
|
|
4
4
|
base: string;
|
|
5
5
|
siteUrl?: string;
|
|
6
|
+
/** Append `/` to page URLs, matching the route layer's `trailingSlash` setting. Omitted means `false`. */
|
|
7
|
+
trailingSlash?: boolean;
|
|
6
8
|
siteName: string;
|
|
7
9
|
defaultLocale: string;
|
|
8
10
|
defaultLocaleDir: string;
|
|
@@ -10,6 +12,8 @@ export interface AgentExportOptions {
|
|
|
10
12
|
code: string;
|
|
11
13
|
dir: string;
|
|
12
14
|
}>;
|
|
15
|
+
/** Top-level category slugs left out of `<SiteTreeNav />` link lists, as in the rendered page. */
|
|
16
|
+
siteTreeNavIgnore?: string[];
|
|
13
17
|
}
|
|
14
18
|
export declare function projectAgentCorpus(options: AgentExportOptions): {
|
|
15
19
|
manifest: AgentManifest;
|
|
@@ -5,7 +5,9 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
5
5
|
import { agentItemKey, agentPageKey } from "../../../agent-docs/identity.js";
|
|
6
6
|
import { AGENT_MAX_ITEMS, AGENT_MAX_MANIFEST_BYTES, AGENT_MAX_SEARCH_INDEX_BYTES } from "../../../agent-docs/limits.js";
|
|
7
7
|
import { collectMdFiles, isExcluded, parseMarkdownFile, slugToUrl, stripMarkdown } from "../../../md-utils/index.js";
|
|
8
|
+
import { loadCategoryMeta } from "../../../sidebar-tree/category-meta.js";
|
|
8
9
|
import { chunkAgentText } from "./chunk.js";
|
|
10
|
+
import { createAgentComponentRenderer } from "./components.js";
|
|
9
11
|
import { normalizeAgentMarkdown } from "./normalize.js";
|
|
10
12
|
const hash = (value) => createHash("sha256").update(value).digest("hex");
|
|
11
13
|
const json = (value) => JSON.stringify(value);
|
|
@@ -25,19 +27,38 @@ function artifactUrl(options, path) {
|
|
|
25
27
|
function projectAgentCorpus(options) {
|
|
26
28
|
const roots = [{ code: options.defaultLocale, dir: options.defaultLocaleDir, default: true }, ...(options.locales ?? []).map(({ code, dir }) => ({ code, dir, default: false }))];
|
|
27
29
|
const seen = /* @__PURE__ */ new Set();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const parsedRoots = roots.map((root) => ({
|
|
31
|
+
root,
|
|
32
|
+
files: collectMdFiles(resolve(root.dir)).flatMap(({ filePath, slug: fileSlug }) => {
|
|
33
|
+
const parsed = parseMarkdownFile(filePath);
|
|
34
|
+
return parsed ? [{ filePath, fileSlug, parsed }] : [];
|
|
35
|
+
})
|
|
36
|
+
}));
|
|
37
|
+
const sources = parsedRoots.flatMap(({ root, files }) => files.flatMap(({ filePath, fileSlug, parsed }) => {
|
|
38
|
+
if (isExcluded(parsed.data)) return [];
|
|
31
39
|
const slug = parsed.data.slug ?? fileSlug;
|
|
32
|
-
const
|
|
33
|
-
|
|
40
|
+
const locale = root.default ? null : root.code;
|
|
41
|
+
const url = slugToUrl(slug, locale, options.base, options.siteUrl, options.trailingSlash === true);
|
|
42
|
+
const linkBase = slugToUrl(slug, locale, options.base, options.siteUrl);
|
|
43
|
+
return [{ root, filePath, parsed, slug, url, linkBase }];
|
|
34
44
|
}));
|
|
45
|
+
const renderers = new Map(parsedRoots.map(({ root, files }) => [root.code, createAgentComponentRenderer({
|
|
46
|
+
locale: root.code,
|
|
47
|
+
entries: files.map(({ fileSlug, parsed }) => ({ slug: fileSlug, data: parsed.data })),
|
|
48
|
+
categoryMeta: loadCategoryMeta(resolve(root.dir)),
|
|
49
|
+
published: new Map(sources.filter((source) => source.root === root).map(({ slug, url, parsed }) => [slug, {
|
|
50
|
+
url,
|
|
51
|
+
title: parsed.data.title ?? slug,
|
|
52
|
+
...typeof parsed.data.description === "string" ? { description: parsed.data.description } : {}
|
|
53
|
+
}])),
|
|
54
|
+
...options.siteTreeNavIgnore ? { siteTreeNavIgnore: options.siteTreeNavIgnore } : {}
|
|
55
|
+
})]));
|
|
35
56
|
const sourceUrls = new Map(sources.map((source) => [source.filePath, source.url]));
|
|
36
|
-
const documents = sources.map(({ root, filePath, parsed, slug, url }) => {
|
|
57
|
+
const documents = sources.map(({ root, filePath, parsed, slug, url, linkBase }) => {
|
|
37
58
|
const id = agentPageKey(root.code, slug);
|
|
38
59
|
if (seen.has(id)) throw new Error(`Duplicate agent page ID: ${id}`);
|
|
39
60
|
seen.add(id);
|
|
40
|
-
const normalized = normalizeAgentMarkdown(parsed.content,
|
|
61
|
+
const normalized = normalizeAgentMarkdown(parsed.content, linkBase, (target) => {
|
|
41
62
|
try {
|
|
42
63
|
const source = new URL(target, pathToFileURL(filePath));
|
|
43
64
|
if (!/\.mdx?$/.test(source.pathname)) return void 0;
|
|
@@ -46,7 +67,7 @@ function projectAgentCorpus(options) {
|
|
|
46
67
|
} catch {
|
|
47
68
|
return void 0;
|
|
48
69
|
}
|
|
49
|
-
});
|
|
70
|
+
}, renderers.get(root.code)(slug));
|
|
50
71
|
const title = parsed.data.title ?? slug;
|
|
51
72
|
const description = parsed.data.description ?? stripMarkdown(parsed.content).split("\n").find(Boolean) ?? "";
|
|
52
73
|
const metadata = {
|