@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
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/** Literal JSX attribute values; `true` stands for a bare boolean attribute. */
|
|
2
|
+
export type AgentTagProps = Record<string, string | number | boolean | null | unknown[] | Record<string, unknown>>;
|
|
3
|
+
export interface AgentComponentTag {
|
|
4
|
+
name: string;
|
|
5
|
+
/** Undefined when any attribute is a non-literal expression or a spread. */
|
|
6
|
+
props: AgentTagProps | undefined;
|
|
7
|
+
selfClosing: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Text that replaces a capitalised JSX opening tag, or undefined to keep the
|
|
11
|
+
* named placeholder. `unsupported` flags the page even when text is returned.
|
|
12
|
+
*/
|
|
13
|
+
export type AgentComponentRenderer = (tag: AgentComponentTag) => {
|
|
14
|
+
text: string;
|
|
15
|
+
unsupported?: boolean;
|
|
16
|
+
} | undefined;
|
|
17
|
+
export declare function dynamicContentPlaceholder(name: string): string;
|
|
1
18
|
/** Normalize MDX for a published text corpus without evaluating its modules. */
|
|
2
|
-
export declare function normalizeAgentMarkdown(source: string, pageUrl: string, resolveSourceLink?: (target: string) => string | undefined): {
|
|
19
|
+
export declare function normalizeAgentMarkdown(source: string, pageUrl: string, resolveSourceLink?: (target: string) => string | undefined, renderComponent?: AgentComponentRenderer): {
|
|
3
20
|
text: string;
|
|
4
21
|
unsupportedDynamicContent: boolean;
|
|
5
22
|
};
|
|
@@ -1,4 +1,92 @@
|
|
|
1
|
-
function
|
|
1
|
+
function dynamicContentPlaceholder(name) {
|
|
2
|
+
return `[Dynamic content unavailable in text export: ${name}]`;
|
|
3
|
+
}
|
|
4
|
+
function skipBraces(text, start) {
|
|
5
|
+
let depth = 0;
|
|
6
|
+
for (let i = start; i < text.length; i++) {
|
|
7
|
+
const ch = text[i];
|
|
8
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
9
|
+
for (i++; i < text.length && text[i] !== ch; i++) if (text[i] === "\\") i++;
|
|
10
|
+
} else if (ch === "{") depth++;
|
|
11
|
+
else if (ch === "}" && --depth === 0) return i + 1;
|
|
12
|
+
}
|
|
13
|
+
return -1;
|
|
14
|
+
}
|
|
15
|
+
function literalExpression(expression) {
|
|
16
|
+
const trimmed = expression.trim();
|
|
17
|
+
const template = trimmed.match(/^`([^`$\\]*)`$/);
|
|
18
|
+
if (template) return { value: template[1] };
|
|
19
|
+
try {
|
|
20
|
+
return { value: JSON.parse(trimmed.replace(/,(\s*[\]}])/g, "$1")) };
|
|
21
|
+
} catch {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseOpeningTag(text, start) {
|
|
26
|
+
const name = text.slice(start + 1).match(/^[A-Z][\w.]*/)?.[0];
|
|
27
|
+
if (!name) return void 0;
|
|
28
|
+
let i = start + 1 + name.length;
|
|
29
|
+
if (i < text.length && !/[\s/>]/.test(text[i])) return void 0;
|
|
30
|
+
let props = {};
|
|
31
|
+
while (i < text.length) {
|
|
32
|
+
while (/\s/.test(text[i] ?? "")) i++;
|
|
33
|
+
if (text[i] === ">") return { name, props, selfClosing: false, end: i + 1 };
|
|
34
|
+
if (text.startsWith("/>", i)) return { name, props, selfClosing: true, end: i + 2 };
|
|
35
|
+
if (text[i] === "{") {
|
|
36
|
+
const end = skipBraces(text, i);
|
|
37
|
+
if (end < 0) return void 0;
|
|
38
|
+
props = void 0;
|
|
39
|
+
i = end;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const attr = text.slice(i).match(/^[A-Za-z_:][\w:.-]*/)?.[0];
|
|
43
|
+
if (!attr) return void 0;
|
|
44
|
+
i += attr.length;
|
|
45
|
+
while (/[ \t]/.test(text[i] ?? "")) i++;
|
|
46
|
+
if (text[i] !== "=") {
|
|
47
|
+
if (props) props[attr] = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
i++;
|
|
51
|
+
while (/\s/.test(text[i] ?? "")) i++;
|
|
52
|
+
const quote = text[i];
|
|
53
|
+
if (quote === '"' || quote === "'") {
|
|
54
|
+
const end = text.indexOf(quote, i + 1);
|
|
55
|
+
if (end < 0) return void 0;
|
|
56
|
+
if (props) props[attr] = text.slice(i + 1, end);
|
|
57
|
+
i = end + 1;
|
|
58
|
+
} else if (quote === "{") {
|
|
59
|
+
const end = skipBraces(text, i);
|
|
60
|
+
if (end < 0) return void 0;
|
|
61
|
+
const literal = literalExpression(text.slice(i + 1, end - 1));
|
|
62
|
+
if (!literal) props = void 0;
|
|
63
|
+
else if (props) props[attr] = literal.value;
|
|
64
|
+
i = end;
|
|
65
|
+
} else return void 0;
|
|
66
|
+
}
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
function replaceComponentTags(text, render) {
|
|
70
|
+
let unsupported = false;
|
|
71
|
+
let out = "";
|
|
72
|
+
let offset = 0;
|
|
73
|
+
for (let i = text.indexOf("<"); i >= 0; i = text.indexOf("<", i + 1)) {
|
|
74
|
+
if (i < offset || !/[A-Z]/.test(text[i + 1] ?? "")) continue;
|
|
75
|
+
let tag = parseOpeningTag(text, i);
|
|
76
|
+
if (!tag) {
|
|
77
|
+
const loose = text.slice(i).match(/^<([A-Z][\w.]*)\b[^>]*>/);
|
|
78
|
+
if (!loose) continue;
|
|
79
|
+
tag = { name: loose[1], props: void 0, selfClosing: loose[0].endsWith("/>"), end: i + loose[0].length };
|
|
80
|
+
}
|
|
81
|
+
const rendered = render?.(tag);
|
|
82
|
+
if (!rendered || rendered.unsupported) unsupported = true;
|
|
83
|
+
const gap = rendered?.text && /\S/.test(text[tag.end] ?? "") ? "\n\n" : "";
|
|
84
|
+
out += text.slice(offset, i) + (rendered ? rendered.text + gap : dynamicContentPlaceholder(tag.name));
|
|
85
|
+
offset = tag.end;
|
|
86
|
+
}
|
|
87
|
+
return { text: out + text.slice(offset), unsupported };
|
|
88
|
+
}
|
|
89
|
+
function normalizeAgentMarkdown(source, pageUrl, resolveSourceLink, renderComponent) {
|
|
2
90
|
let unsupportedDynamicContent = false;
|
|
3
91
|
const literals = [];
|
|
4
92
|
let marker = "\0agent-code:";
|
|
@@ -59,15 +147,13 @@ function normalizeAgentMarkdown(source, pageUrl, resolveSourceLink) {
|
|
|
59
147
|
/^( {0,3}\[[^\]]+\]:[ \t]*)(?:<([^>]+)>|([^\s]+))/gm,
|
|
60
148
|
(_all, before, angled, plain) => shield(before + (angled !== void 0 ? `<${resolveLink(angled)}>` : resolveLink(plain)))
|
|
61
149
|
);
|
|
62
|
-
text = text
|
|
63
|
-
unsupportedDynamicContent = true;
|
|
64
|
-
return "[Dynamic content unavailable in text export]";
|
|
65
|
-
});
|
|
150
|
+
({ text, unsupported: unsupportedDynamicContent } = replaceComponentTags(text, renderComponent));
|
|
66
151
|
text = text.replace(/<\/([A-Z][\w.]*)\s*>/g, "");
|
|
67
152
|
text = text.replace(/<\/?[a-z][\w-]*(?=[\s/>])[^>]*>/g, "");
|
|
68
153
|
for (let i = literals.length - 1; i >= 0; i--) text = text.replaceAll(`${marker}${i}\0`, () => literals[i]);
|
|
69
154
|
return { text: text.trim(), unsupportedDynamicContent };
|
|
70
155
|
}
|
|
71
156
|
export {
|
|
157
|
+
dynamicContentPlaceholder,
|
|
72
158
|
normalizeAgentMarkdown
|
|
73
159
|
};
|
|
@@ -19,6 +19,8 @@ export interface LlmsTxtDevMiddlewareOptions extends LlmsTxtSiteMeta {
|
|
|
19
19
|
base: string;
|
|
20
20
|
/** Optional absolute site URL; see `LlmsTxtLoadOptions.siteUrl`. */
|
|
21
21
|
siteUrl?: string;
|
|
22
|
+
/** Append `/` to page URLs, matching the route layer's `trailingSlash` setting. Omitted means `false`. */
|
|
23
|
+
trailingSlash?: boolean;
|
|
22
24
|
/** Actual default locale code; needed to match agent-export page IDs. */
|
|
23
25
|
defaultLocale?: string;
|
|
24
26
|
/** Link slim-index docs to agent-export Markdown artifacts when enabled. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { loadLlmsAssetEntries } from "./assets.js";
|
|
2
2
|
import { generateLlmsFullTxt, generateLlmsTxt } from "./generate.js";
|
|
3
3
|
import { loadDocEntries, withLlmsBase } from "./load.js";
|
|
4
|
+
import { MCP_ENDPOINT_PATH, MCP_SERVER_CARD_PATH } from "../../../mcp/constants.js";
|
|
4
5
|
const LLMS_KIND_PATTERN = /^(?:\/(.+?))?\/(llms|llms-full)\.txt$/;
|
|
5
6
|
function createLlmsTxtDevMiddleware(options, logger) {
|
|
6
7
|
const meta = {
|
|
@@ -15,7 +16,10 @@ function createLlmsTxtDevMiddleware(options, logger) {
|
|
|
15
16
|
const siteUrl = options.siteUrl || void 0;
|
|
16
17
|
const generationOptions = {
|
|
17
18
|
agentExport: options.agentExport === true,
|
|
18
|
-
...options.mcp === true ? {
|
|
19
|
+
...options.mcp === true ? {
|
|
20
|
+
mcpEndpointUrl: withLlmsBase(MCP_ENDPOINT_PATH, base, siteUrl),
|
|
21
|
+
mcpServerCardUrl: withLlmsBase(MCP_SERVER_CARD_PATH, base, siteUrl)
|
|
22
|
+
} : {}
|
|
19
23
|
};
|
|
20
24
|
return (req, res, next) => {
|
|
21
25
|
const url = req.url ?? "";
|
|
@@ -43,6 +47,7 @@ function createLlmsTxtDevMiddleware(options, logger) {
|
|
|
43
47
|
locale: match.locale,
|
|
44
48
|
base,
|
|
45
49
|
siteUrl,
|
|
50
|
+
trailingSlash: options.trailingSlash === true,
|
|
46
51
|
...options.agentExport === true ? { agentExportLocale: match.locale ?? options.defaultLocale ?? "en" } : {}
|
|
47
52
|
});
|
|
48
53
|
const assets = loadLlmsAssetEntries({
|
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { generateLlmsFullTxt, generateLlmsTxt } from "./generate.js";
|
|
4
4
|
import { loadLlmsAssetEntries } from "./assets.js";
|
|
5
5
|
import { loadDocEntries, withLlmsBase } from "./load.js";
|
|
6
|
+
import { MCP_ENDPOINT_PATH, MCP_SERVER_CARD_PATH } from "../../../mcp/constants.js";
|
|
6
7
|
function assetsForLocale(assets, locale) {
|
|
7
8
|
return assets.filter(
|
|
8
9
|
(asset) => locale === null ? asset.locale === void 0 : asset.locale === locale
|
|
@@ -13,6 +14,7 @@ function emitLlmsTxt(options) {
|
|
|
13
14
|
outDir,
|
|
14
15
|
base,
|
|
15
16
|
siteUrl,
|
|
17
|
+
trailingSlash,
|
|
16
18
|
siteName,
|
|
17
19
|
siteDescription,
|
|
18
20
|
defaultLocaleDir,
|
|
@@ -29,13 +31,17 @@ function emitLlmsTxt(options) {
|
|
|
29
31
|
const assetEntries = loadLlmsAssetEntries({ projectRoot, assetScan, siteUrl });
|
|
30
32
|
const generationOptions = {
|
|
31
33
|
agentExport: agentExport === true,
|
|
32
|
-
...mcp === true ? {
|
|
34
|
+
...mcp === true ? {
|
|
35
|
+
mcpEndpointUrl: withLlmsBase(MCP_ENDPOINT_PATH, base, siteUrl),
|
|
36
|
+
mcpServerCardUrl: withLlmsBase(MCP_SERVER_CARD_PATH, base, siteUrl)
|
|
37
|
+
} : {}
|
|
33
38
|
};
|
|
34
39
|
const defaultEntries = loadDocEntries({
|
|
35
40
|
contentDir: defaultLocaleDir,
|
|
36
41
|
locale: null,
|
|
37
42
|
base,
|
|
38
43
|
siteUrl,
|
|
44
|
+
trailingSlash: trailingSlash === true,
|
|
39
45
|
...agentExport === true ? { agentExportLocale: defaultLocale ?? "en" } : {}
|
|
40
46
|
});
|
|
41
47
|
mkdirSync(outDir, { recursive: true });
|
|
@@ -64,6 +70,7 @@ function emitLlmsTxt(options) {
|
|
|
64
70
|
locale: code,
|
|
65
71
|
base,
|
|
66
72
|
siteUrl,
|
|
73
|
+
trailingSlash: trailingSlash === true,
|
|
67
74
|
...agentExport === true ? { agentExportLocale: code } : {}
|
|
68
75
|
});
|
|
69
76
|
const localeDir = join(outDir, code);
|
|
@@ -15,6 +15,8 @@ export interface LlmsTxtGenerationOptions {
|
|
|
15
15
|
agentExport?: boolean;
|
|
16
16
|
/** Add an MCP discovery section with this base-aware endpoint URL. */
|
|
17
17
|
mcpEndpointUrl?: string;
|
|
18
|
+
/** List the endpoint's Server Card in the MCP section. */
|
|
19
|
+
mcpServerCardUrl?: string;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Slim index — site header followed by a markdown bullet per page with
|
|
@@ -58,6 +58,9 @@ function generateLlmsTxt(entries, meta, assets = [], options = {}) {
|
|
|
58
58
|
lines.push("## MCP");
|
|
59
59
|
lines.push("");
|
|
60
60
|
lines.push(`- [Read-only MCP endpoint](${options.mcpEndpointUrl})`);
|
|
61
|
+
if (options.mcpServerCardUrl !== void 0) {
|
|
62
|
+
lines.push(`- [MCP Server Card](${options.mcpServerCardUrl})`);
|
|
63
|
+
}
|
|
61
64
|
lines.push("");
|
|
62
65
|
}
|
|
63
66
|
return lines.join("\n");
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
slugToUrl as slugToUrl2
|
|
21
21
|
} from "../../../md-utils/index.js";
|
|
22
22
|
function loadDocEntries(options) {
|
|
23
|
-
const { contentDir, locale, base, siteUrl, agentExportLocale } = options;
|
|
23
|
+
const { contentDir, locale, base, siteUrl, trailingSlash, agentExportLocale } = options;
|
|
24
24
|
const absDir = resolve(contentDir);
|
|
25
25
|
const files = collectMdFiles(absDir);
|
|
26
26
|
const entries = [];
|
|
@@ -38,7 +38,7 @@ function loadDocEntries(options) {
|
|
|
38
38
|
const entry = {
|
|
39
39
|
title: data.title ?? slug,
|
|
40
40
|
description,
|
|
41
|
-
url: slugToUrl(slug, locale, base, siteUrl),
|
|
41
|
+
url: slugToUrl(slug, locale, base, siteUrl, trailingSlash === true),
|
|
42
42
|
content: stripImportsAndJsx(content),
|
|
43
43
|
sidebarPosition: data.sidebar_position
|
|
44
44
|
};
|
|
@@ -103,6 +103,8 @@ export interface LlmsTxtLoadOptions {
|
|
|
103
103
|
* empty, URLs are returned path-only for projects that omit `siteUrl`.
|
|
104
104
|
*/
|
|
105
105
|
siteUrl?: string;
|
|
106
|
+
/** Append `/` to page URLs, matching the route layer's `trailingSlash` setting. Omitted means `false`. */
|
|
107
|
+
trailingSlash?: boolean;
|
|
106
108
|
/** Actual locale code used by the agent export page identity, including for the default locale. */
|
|
107
109
|
agentExportLocale?: string;
|
|
108
110
|
}
|
|
@@ -117,6 +119,8 @@ export interface LlmsTxtEmitOptions extends LlmsTxtSiteMeta {
|
|
|
117
119
|
base: string;
|
|
118
120
|
/** Optional absolute site URL; see {@link LlmsTxtLoadOptions}. */
|
|
119
121
|
siteUrl?: string;
|
|
122
|
+
/** Append `/` to page URLs, matching the route layer's `trailingSlash` setting. Omitted means `false`. */
|
|
123
|
+
trailingSlash?: boolean;
|
|
120
124
|
/** Actual default locale code; needed to match agent-export page IDs. */
|
|
121
125
|
defaultLocale?: string;
|
|
122
126
|
/** Link slim-index docs to agent-export Markdown artifacts when enabled. */
|
|
@@ -36,7 +36,7 @@ function readAssetExcerpt(filePath, maxBodyLength) {
|
|
|
36
36
|
closeSync(fd);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function buildEntries(contentDir, locale, base, maxBodyLength) {
|
|
39
|
+
function buildEntries(contentDir, locale, base, maxBodyLength, trailingSlash) {
|
|
40
40
|
const absDir = resolve(contentDir);
|
|
41
41
|
const files = collectMdFiles(absDir);
|
|
42
42
|
const entries = [];
|
|
@@ -51,7 +51,7 @@ function buildEntries(contentDir, locale, base, maxBodyLength) {
|
|
|
51
51
|
id,
|
|
52
52
|
title: data.title ?? slug,
|
|
53
53
|
body: truncateBody(stripMarkdown(content), maxBodyLength),
|
|
54
|
-
url: slugToUrl(slug, locale, base),
|
|
54
|
+
url: slugToUrl(slug, locale, base, void 0, trailingSlash),
|
|
55
55
|
description: data.description ?? ""
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -82,11 +82,12 @@ function collectSearchEntries(config) {
|
|
|
82
82
|
assertValidSearchMaxBodyLength(config.maxBodyLength);
|
|
83
83
|
const maxBodyLength = config.maxBodyLength ?? MAX_BODY_LENGTH;
|
|
84
84
|
const base = config.base ?? "";
|
|
85
|
+
const trailingSlash = config.trailingSlash === true;
|
|
85
86
|
const entries = [];
|
|
86
|
-
entries.push(...buildEntries(config.docsDir, null, base, maxBodyLength));
|
|
87
|
+
entries.push(...buildEntries(config.docsDir, null, base, maxBodyLength, trailingSlash));
|
|
87
88
|
if (config.locales) {
|
|
88
89
|
for (const [code, locale] of Object.entries(config.locales)) {
|
|
89
|
-
entries.push(...buildEntries(locale.dir, code, base, maxBodyLength));
|
|
90
|
+
entries.push(...buildEntries(locale.dir, code, base, maxBodyLength, trailingSlash));
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
entries.push(...buildAssetEntries(config, maxBodyLength));
|
|
@@ -36,6 +36,8 @@ export interface SearchIndexConfig {
|
|
|
36
36
|
locales?: Record<string, SearchIndexLocaleConfig>;
|
|
37
37
|
/** Site base path (e.g. `""`, `"/docs"`); trailing slash is normalised away. */
|
|
38
38
|
base?: string;
|
|
39
|
+
/** Append `/` to page URLs, matching the route layer's `trailingSlash` setting. Omitted means `false`. */
|
|
40
|
+
trailingSlash?: boolean;
|
|
39
41
|
/** Runtime project root for asset scans; injected by the zfb plugin wrapper, never serialized in the preset. */
|
|
40
42
|
projectRoot?: string;
|
|
41
43
|
/** Shared asset-viewer projection; consumed by the asset indexing wave. */
|
package/dist/plugins/routes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { prepareHomeIntros } from "../home-intro/prepare.js";
|
|
2
|
+
import { MCP_ENDPOINT_PATH, MCP_SERVER_CARD_PATH } from "../mcp/constants.js";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import { existsSync, statSync, readFileSync, cpSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
4
5
|
import { dirname, basename, join } from "node:path";
|
|
@@ -29,7 +30,11 @@ function deriveRoutes(settings, options) {
|
|
|
29
30
|
const aiAssistant = settings.aiAssistant === true;
|
|
30
31
|
if (settings.mcp === true) {
|
|
31
32
|
const base = `/${String(settings.base ?? "").split("/").filter(Boolean).join("/")}`.replace(/\/$/, "");
|
|
32
|
-
routes.push({ pattern: `${base}
|
|
33
|
+
routes.push({ pattern: `${base}${MCP_ENDPOINT_PATH}`, entrypoint: "@takazudo/zudo-doc/routes/mcp", opts: { prerender: false }, includedInDtpShadowDiagnostic: false });
|
|
34
|
+
routes.push({ pattern: `${base}${MCP_SERVER_CARD_PATH}`, entrypoint: "@takazudo/zudo-doc/routes/mcp-server-card", opts: { prerender: false }, includedInDtpShadowDiagnostic: false });
|
|
35
|
+
if (base === "") {
|
|
36
|
+
routes.push({ pattern: "/[wellKnown]/ai-catalog.json", entrypoint: "@takazudo/zudo-doc/routes/ai-catalog", opts: { prerender: false }, includedInDtpShadowDiagnostic: false });
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
if (options.packageOwnedRoutes === false) {
|
|
35
40
|
if (options.assetViewer === true) {
|
package/dist/preset.d.ts
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
import { z } from "zod";
|
|
37
37
|
import type { DirectiveSpec, ZfbConfig } from "@takazudo/zfb/config";
|
|
38
38
|
import type { ColorScheme } from "./color-scheme-utils.js";
|
|
39
|
-
import type { AssetViewerIndexingConfig, TagVocabularyEntry, FaviconConfig, HeaderBrandConfig, HomeConfig } from "./settings.js";
|
|
39
|
+
import type { ContentSignalsConfig, AssetViewerIndexingConfig, TagVocabularyEntry, FaviconConfig, HeaderBrandConfig, HomeConfig } from "./settings.js";
|
|
40
40
|
/** A single locale's content directory (`settings.locales[code]`). */
|
|
41
41
|
export interface PresetLocaleConfig {
|
|
42
42
|
dir: string;
|
|
@@ -114,6 +114,9 @@ export interface PresetSettings {
|
|
|
114
114
|
headerBrand?: false | HeaderBrandConfig;
|
|
115
115
|
/** GitHub repository URL used by asset backlink metadata. */
|
|
116
116
|
githubUrl?: string | false;
|
|
117
|
+
/** robots.txt Content Signals. Carried only for `assertValidContentSignals`;
|
|
118
|
+
* the robots route renders it from the full `Settings`. */
|
|
119
|
+
contentSignals?: ContentSignalsConfig | false;
|
|
117
120
|
siteUrl: string;
|
|
118
121
|
trailingSlash: boolean;
|
|
119
122
|
minifyHtml?: boolean;
|
|
@@ -128,6 +131,8 @@ export interface PresetSettings {
|
|
|
128
131
|
agentExport?: boolean;
|
|
129
132
|
/** Enable the stateless read-only MCP endpoint; requires `agentExport: true`. */
|
|
130
133
|
mcp?: boolean;
|
|
134
|
+
/** Top-level categories left out of `<SiteTreeNav />`; the agent export mirrors it. */
|
|
135
|
+
siteTreeNavIgnore?: string[];
|
|
131
136
|
changelogs?: PresetChangelogConfig[] | false;
|
|
132
137
|
/** Metadata fields shown in the doc metadata area. */
|
|
133
138
|
docMetainfoFields?: Array<"created" | "updated" | "author">;
|
package/dist/preset.js
CHANGED
|
@@ -3,6 +3,10 @@ import { assertNoCommaInVersionSlugs } from "./version-availability/index.js";
|
|
|
3
3
|
import {
|
|
4
4
|
assertNoEmptyStringFaviconOrLogo,
|
|
5
5
|
assertValidHeaderBrand,
|
|
6
|
+
assertValidHomeImage,
|
|
7
|
+
assertValidContentSignals,
|
|
8
|
+
assertValidLocaleOgImages,
|
|
9
|
+
assertValidHomeSections,
|
|
6
10
|
assertZdtpBundlingConsistent,
|
|
7
11
|
assertValidSearchMaxBodyLength,
|
|
8
12
|
assertAgentDocsConsistent,
|
|
@@ -31,6 +35,10 @@ function zudoDocPreset({
|
|
|
31
35
|
assertNoCommaInVersionSlugs(settings.versions);
|
|
32
36
|
assertNoEmptyStringFaviconOrLogo(settings);
|
|
33
37
|
assertValidHeaderBrand(settings);
|
|
38
|
+
assertValidHomeImage(settings);
|
|
39
|
+
assertValidLocaleOgImages(settings);
|
|
40
|
+
assertValidHomeSections(settings);
|
|
41
|
+
assertValidContentSignals(settings);
|
|
34
42
|
assertZdtpBundlingConsistent(settings);
|
|
35
43
|
assertValidSearchMaxBodyLength(settings.searchMaxBodyLength);
|
|
36
44
|
assertAgentDocsConsistent(settings);
|
|
@@ -274,6 +282,7 @@ function buildPlugins(settings, routeContext) {
|
|
|
274
282
|
docsDir: settings.docsDir,
|
|
275
283
|
locales: localeRecord,
|
|
276
284
|
base: settings.base,
|
|
285
|
+
trailingSlash: settings.trailingSlash,
|
|
277
286
|
assetScan,
|
|
278
287
|
maxBodyLength: settings.searchMaxBodyLength
|
|
279
288
|
}
|
|
@@ -302,6 +311,7 @@ function buildPlugins(settings, routeContext) {
|
|
|
302
311
|
siteDescription: settings.siteDescription,
|
|
303
312
|
base: settings.base,
|
|
304
313
|
siteUrl: settings.siteUrl,
|
|
314
|
+
trailingSlash: settings.trailingSlash,
|
|
305
315
|
defaultLocale: settings.defaultLocale ?? "en",
|
|
306
316
|
agentExport: settings.agentExport === true,
|
|
307
317
|
mcp: settings.mcp === true,
|
|
@@ -317,9 +327,11 @@ function buildPlugins(settings, routeContext) {
|
|
|
317
327
|
siteName: settings.siteName,
|
|
318
328
|
siteUrl: settings.siteUrl,
|
|
319
329
|
base: settings.base,
|
|
330
|
+
trailingSlash: settings.trailingSlash,
|
|
320
331
|
defaultLocale: settings.defaultLocale ?? "en",
|
|
321
332
|
defaultLocaleDir: settings.docsDir,
|
|
322
|
-
locales: localeArray
|
|
333
|
+
locales: localeArray,
|
|
334
|
+
siteTreeNavIgnore: settings.siteTreeNavIgnore ?? []
|
|
323
335
|
}
|
|
324
336
|
}] : [],
|
|
325
337
|
...Array.isArray(settings.changelogs) && settings.changelogs.length > 0 ? [
|
package/dist/robots.d.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* export default () => renderRobots(settings);
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
+
import type { ContentSignalsConfig } from "./settings.js";
|
|
20
|
+
export type { ContentSignalsConfig } from "./settings.js";
|
|
19
21
|
/** Minimal settings shape consumed by renderRobots. */
|
|
20
22
|
export interface RobotsSettings {
|
|
21
23
|
/** When true, disallow all crawlers. */
|
|
@@ -26,7 +28,17 @@ export interface RobotsSettings {
|
|
|
26
28
|
base?: string;
|
|
27
29
|
/** When true (and siteUrl is set), append a Sitemap: line. */
|
|
28
30
|
sitemap?: boolean;
|
|
31
|
+
/** Content Signals for the `User-agent: *` group; `false` or absent publishes none. */
|
|
32
|
+
contentSignals?: ContentSignalsConfig | false;
|
|
29
33
|
}
|
|
34
|
+
/** The `ContentSignalsConfig` keys, in the order the signals are rendered. */
|
|
35
|
+
export declare const CONTENT_SIGNAL_KEYS: ReadonlyArray<keyof ContentSignalsConfig>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the `Content-Signal` value for the configured signals — for example
|
|
38
|
+
* `search=yes, ai-input=yes, ai-train=no` — or `undefined` when no signal is
|
|
39
|
+
* declared. The same value can be sent as a `Content-Signal` response header.
|
|
40
|
+
*/
|
|
41
|
+
export declare function renderContentSignal(signals: ContentSignalsConfig | false | undefined): string | undefined;
|
|
30
42
|
/**
|
|
31
43
|
* Returns the plain-text content for `robots.txt` based on settings.
|
|
32
44
|
*
|
|
@@ -34,5 +46,7 @@ export interface RobotsSettings {
|
|
|
34
46
|
* sitemap while disallowing all crawlers is contradictory).
|
|
35
47
|
* - Otherwise → `Allow: /` with an optional `Sitemap:` line when both
|
|
36
48
|
* `siteUrl` and `sitemap` are truthy.
|
|
49
|
+
* - Configured `contentSignals` add a `Content-Signal:` line to the
|
|
50
|
+
* `User-agent: *` group in both cases.
|
|
37
51
|
*/
|
|
38
52
|
export declare function renderRobots(settings: RobotsSettings): string;
|
package/dist/robots.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
const CONTENT_SIGNALS = [
|
|
2
|
+
["search", "search"],
|
|
3
|
+
["aiInput", "ai-input"],
|
|
4
|
+
["aiTrain", "ai-train"]
|
|
5
|
+
];
|
|
6
|
+
const CONTENT_SIGNAL_KEYS = CONTENT_SIGNALS.map(([key]) => key);
|
|
7
|
+
function renderContentSignal(signals) {
|
|
8
|
+
if (!signals) return void 0;
|
|
9
|
+
const parts = CONTENT_SIGNALS.flatMap(([key, name]) => {
|
|
10
|
+
const value = signals[key];
|
|
11
|
+
return typeof value === "boolean" ? [`${name}=${value ? "yes" : "no"}`] : [];
|
|
12
|
+
});
|
|
13
|
+
return parts.length > 0 ? parts.join(", ") : void 0;
|
|
14
|
+
}
|
|
1
15
|
function renderRobots(settings) {
|
|
16
|
+
const contentSignal = renderContentSignal(settings.contentSignals);
|
|
17
|
+
const group = `User-agent: *
|
|
18
|
+
${contentSignal ? `Content-Signal: ${contentSignal}
|
|
19
|
+
` : ""}`;
|
|
2
20
|
if (settings.noindex) {
|
|
3
|
-
return
|
|
4
|
-
Disallow: /
|
|
21
|
+
return `${group}Disallow: /
|
|
5
22
|
`;
|
|
6
23
|
}
|
|
7
24
|
const siteUrlBase = (settings.siteUrl ?? "").replace(/\/$/, "");
|
|
@@ -9,10 +26,11 @@ Disallow: /
|
|
|
9
26
|
const hasSitemapLine = siteUrlBase !== "" && settings.sitemap;
|
|
10
27
|
const sitemapLine = hasSitemapLine ? `Sitemap: ${siteUrlBase}${normalizedBase}/sitemap.xml
|
|
11
28
|
` : "";
|
|
12
|
-
return
|
|
13
|
-
Allow: /
|
|
29
|
+
return `${group}Allow: /
|
|
14
30
|
${sitemapLine}`;
|
|
15
31
|
}
|
|
16
32
|
export {
|
|
33
|
+
CONTENT_SIGNAL_KEYS,
|
|
34
|
+
renderContentSignal,
|
|
17
35
|
renderRobots
|
|
18
36
|
};
|
|
@@ -23,6 +23,44 @@ export interface TagInfoForEnum {
|
|
|
23
23
|
tag: string;
|
|
24
24
|
count: number;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Minimal doc-history manifest entry read by {@link RouteEnumeratorsAPI.enumerateSitemapEntries}
|
|
28
|
+
* — a structural subset of `.zfb/doc-history-meta.json` values.
|
|
29
|
+
*/
|
|
30
|
+
export interface DocHistoryDateEntry {
|
|
31
|
+
/** ISO date or git `%aI` timestamp of the page's most recent commit. */
|
|
32
|
+
updatedDate?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Doc-history manifest keyed like the visible Created/Updated block. */
|
|
35
|
+
export type DocHistoryDateManifest = Readonly<Record<string, unknown>>;
|
|
36
|
+
/** Options for {@link RouteEnumeratorsAPI.enumerateSitemapEntries}. */
|
|
37
|
+
export interface SitemapEntriesOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The build's doc-history manifest. Absent, `null`, or `{}` means no page
|
|
40
|
+
* has a known date, so every entry omits `lastmod`.
|
|
41
|
+
*/
|
|
42
|
+
docHistoryMeta?: DocHistoryDateManifest | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One locale variant of a page, for `hreflang` alternates. `url` is the
|
|
46
|
+
* base-prefixed path (callers make it absolute with `siteUrl`). `hreflang` is
|
|
47
|
+
* the locale code (the same value as the page's `<html lang>`) or `x-default`.
|
|
48
|
+
*/
|
|
49
|
+
export interface LocaleAlternate {
|
|
50
|
+
hreflang: string;
|
|
51
|
+
url: string;
|
|
52
|
+
}
|
|
53
|
+
/** One sitemap URL with its last-modified date, when one is known. */
|
|
54
|
+
export interface SitemapEntry {
|
|
55
|
+
url: string;
|
|
56
|
+
/** `YYYY-MM-DD` (UTC), or absent when the page has no known date. */
|
|
57
|
+
lastmod?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Locale variants of this page, including itself and `x-default`. Present
|
|
60
|
+
* only for pages that exist as real content in more than one locale.
|
|
61
|
+
*/
|
|
62
|
+
alternates?: LocaleAlternate[];
|
|
63
|
+
}
|
|
26
64
|
/**
|
|
27
65
|
* Context slice `createRouteEnumerators` derives its bag from (epic Collapse
|
|
28
66
|
* Wiring Shells #2420, FACTORIES #2424 — breaking signature). STRUCTURAL SUBSET
|
|
@@ -103,12 +141,35 @@ export interface RouteEnumeratorsAPI {
|
|
|
103
141
|
*/
|
|
104
142
|
enumerateVersionedRoutes: (version: VersionConfigForEnum, locale: string) => string[];
|
|
105
143
|
/**
|
|
106
|
-
* Compose all route enumerators into a deduped Map<url,
|
|
144
|
+
* Compose all route enumerators into a deduped Map<url, buildDate>.
|
|
107
145
|
*
|
|
108
146
|
* Covers site root, default-locale docs + tags, per-locale docs + tags,
|
|
109
|
-
* asset-viewer routes, versioned EN docs, and versioned locale docs.
|
|
147
|
+
* asset-viewer routes, versioned EN docs, and versioned locale docs. Every
|
|
148
|
+
* value is the current build date; the sitemap uses
|
|
149
|
+
* {@link RouteEnumeratorsAPI.enumerateSitemapEntries} instead.
|
|
110
150
|
*/
|
|
111
151
|
enumerateAllRoutes: () => Map<string, string>;
|
|
152
|
+
/**
|
|
153
|
+
* The same deduped route set as `enumerateAllRoutes()`, in the same order,
|
|
154
|
+
* with each latest (unversioned) doc page's `lastmod` taken from the
|
|
155
|
+
* doc-history manifest — the date the page's visible "Updated" label shows.
|
|
156
|
+
* Routes with no known date (site roots, tags, assets, versioned pages,
|
|
157
|
+
* pages missing from the manifest) carry no `lastmod`.
|
|
158
|
+
*/
|
|
159
|
+
enumerateSitemapEntries: (options?: SitemapEntriesOptions) => SitemapEntry[];
|
|
160
|
+
/**
|
|
161
|
+
* `hreflang` alternates for a latest (unversioned) doc page. Non-empty only
|
|
162
|
+
* when the page in `locale` is real content (its own locale file, not an
|
|
163
|
+
* EN fallback or auto-index) and at least one other locale also has real
|
|
164
|
+
* content at the same slug. Lists every such locale, then `x-default` (the
|
|
165
|
+
* default locale's URL) when the default locale is one of them.
|
|
166
|
+
*/
|
|
167
|
+
getDocLocaleAlternates: (slug: string, locale: string) => LocaleAlternate[];
|
|
168
|
+
/**
|
|
169
|
+
* `hreflang` alternates for the home pages: every configured locale's home,
|
|
170
|
+
* then `x-default`. Empty for single-locale sites.
|
|
171
|
+
*/
|
|
172
|
+
getHomeLocaleAlternates: () => LocaleAlternate[];
|
|
112
173
|
}
|
|
113
174
|
/**
|
|
114
175
|
* Create the route-enumeration functions bound to the host's injected context.
|