doccupine 0.0.157 → 0.0.159
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 +52 -2
- package/dist/generator/app-scaffolder.js +11 -3
- package/dist/generator/generated-page-publisher.d.ts +6 -6
- package/dist/generator/generated-page-publisher.js +7 -5
- package/dist/generator/icon-registry-generator.d.ts +8 -5
- package/dist/generator/icon-registry-generator.js +19 -11
- package/dist/generator/mdx-pass-builder.d.ts +4 -4
- package/dist/generator/mdx-pass-builder.js +8 -1
- package/dist/generator/mdx-reconciliation-coordinator.d.ts +23 -9
- package/dist/generator/mdx-reconciliation-coordinator.js +63 -9
- package/dist/generator/page-catalog.d.ts +2 -4
- package/dist/generator/page-catalog.js +7 -2
- package/dist/generator/page-renderer.d.ts +15 -5
- package/dist/generator/page-renderer.js +38 -11
- package/dist/generator/project-config-repository.d.ts +4 -1
- package/dist/generator/project-config-repository.js +26 -0
- package/dist/generator/public-asset-manager.d.ts +10 -0
- package/dist/generator/public-asset-manager.js +63 -3
- package/dist/generator/section-index-generator.d.ts +10 -1
- package/dist/generator/section-index-generator.js +43 -15
- package/dist/generator/section-resolver.d.ts +8 -0
- package/dist/generator/site-artifacts.d.ts +4 -3
- package/dist/generator/site-artifacts.js +94 -9
- package/dist/generator/watch-coordinator.js +6 -1
- package/dist/lib/generated-artifacts.d.ts +3 -0
- package/dist/lib/generated-artifacts.js +36 -0
- package/dist/lib/icon-registry.d.ts +10 -4
- package/dist/lib/icon-registry.js +13 -4
- package/dist/lib/layout.d.ts +6 -3
- package/dist/lib/layout.js +107 -4
- package/dist/lib/metadata.d.ts +7 -0
- package/dist/lib/metadata.js +33 -10
- package/dist/lib/structures.js +20 -0
- package/dist/lib/types.d.ts +28 -0
- package/dist/lib/ui-strings.d.ts +44 -0
- package/dist/lib/ui-strings.js +48 -0
- package/dist/lib/variants.d.ts +91 -0
- package/dist/lib/variants.js +411 -0
- package/dist/mdx-to-nextjs-generator.d.ts +22 -5
- package/dist/mdx-to-nextjs-generator.js +92 -12
- package/dist/templates/app/api/mcp/route.d.ts +1 -1
- package/dist/templates/app/api/mcp/route.js +14 -1
- package/dist/templates/app/api/rag/route.d.ts +1 -1
- package/dist/templates/app/api/rag/route.js +13 -2
- package/dist/templates/app/api/search/route.d.ts +1 -1
- package/dist/templates/app/api/search/route.js +16 -1
- package/dist/templates/app/sitemap.d.ts +2 -0
- package/dist/templates/app/sitemap.js +48 -3
- package/dist/templates/components/Chat.d.ts +1 -1
- package/dist/templates/components/Chat.js +40 -12
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +5 -2
- package/dist/templates/components/DocsSideBar.d.ts +1 -1
- package/dist/templates/components/DocsSideBar.js +3 -1
- package/dist/templates/components/SearchDocs.d.ts +1 -1
- package/dist/templates/components/SearchDocs.js +17 -3
- package/dist/templates/components/SearchModalContent.d.ts +1 -1
- package/dist/templates/components/SearchModalContent.js +22 -14
- package/dist/templates/components/SectionNavProvider.d.ts +1 -1
- package/dist/templates/components/SectionNavProvider.js +32 -20
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +26 -12
- package/dist/templates/components/layout/ActionBar.d.ts +1 -1
- package/dist/templates/components/layout/ActionBar.js +9 -7
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +6 -3
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +38 -5
- package/dist/templates/components/layout/DocsNavigation.d.ts +1 -1
- package/dist/templates/components/layout/DocsNavigation.js +4 -2
- package/dist/templates/components/layout/Dropdown.d.ts +1 -0
- package/dist/templates/components/layout/Dropdown.js +308 -0
- package/dist/templates/components/layout/FocusModeToggle.d.ts +1 -1
- package/dist/templates/components/layout/FocusModeToggle.js +7 -4
- package/dist/templates/components/layout/Footer.d.ts +1 -1
- package/dist/templates/components/layout/Footer.js +4 -2
- package/dist/templates/components/layout/Header.d.ts +1 -1
- package/dist/templates/components/layout/Header.js +18 -8
- package/dist/templates/components/layout/SectionBar.d.ts +1 -1
- package/dist/templates/components/layout/SectionBar.js +16 -10
- package/dist/templates/components/layout/VariantSwitchers.d.ts +1 -0
- package/dist/templates/components/layout/VariantSwitchers.js +313 -0
- package/dist/templates/components/useStrings.d.ts +1 -0
- package/dist/templates/components/useStrings.js +10 -0
- package/dist/templates/components/useVariant.d.ts +1 -0
- package/dist/templates/components/useVariant.js +13 -0
- package/dist/templates/llms/llmsIndex.d.ts +13 -0
- package/dist/templates/llms/llmsIndex.js +18 -3
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +2 -0
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/api-playground.mdx.js +2 -0
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +1 -1
- package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
- package/dist/templates/mdx/fonts.mdx.js +1 -1
- package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
- package/dist/templates/mdx/footer-links.mdx.js +1 -1
- package/dist/templates/mdx/index.mdx.d.ts +1 -1
- package/dist/templates/mdx/index.mdx.js +2 -0
- package/dist/templates/mdx/languages.mdx.d.ts +1 -0
- package/dist/templates/mdx/languages.mdx.js +94 -0
- package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.js +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +6 -0
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
- package/dist/templates/mdx/navigation.mdx.js +2 -0
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +2 -0
- package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/api-playground.mdx.js +2 -0
- package/dist/templates/mdx/platform/file-editor.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/file-editor.mdx.js +2 -0
- package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/index.mdx.js +1 -1
- package/dist/templates/mdx/platform/languages.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/languages.mdx.js +50 -0
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +2 -0
- package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.js +2 -0
- package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/publishing.mdx.js +4 -0
- package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/self-updating-docs.mdx.js +2 -0
- package/dist/templates/mdx/platform/versions.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/versions.mdx.js +33 -0
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +1 -1
- package/dist/templates/mdx/theme.mdx.d.ts +1 -1
- package/dist/templates/mdx/theme.mdx.js +1 -1
- package/dist/templates/mdx/versions.mdx.d.ts +1 -0
- package/dist/templates/mdx/versions.mdx.js +78 -0
- package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
- package/dist/templates/prettierignore.d.ts +1 -1
- package/dist/templates/prettierignore.js +2 -0
- package/dist/templates/services/mcp/server.d.ts +1 -1
- package/dist/templates/services/mcp/server.js +54 -10
- package/dist/templates/services/mcp/tools.d.ts +1 -1
- package/dist/templates/services/mcp/tools.js +81 -6
- package/dist/templates/services/mcp/types.d.ts +1 -1
- package/dist/templates/services/mcp/types.js +10 -0
- package/dist/templates/services/search.d.ts +1 -1
- package/dist/templates/services/search.js +34 -4
- package/dist/templates/utils/orderNavItems.d.ts +1 -1
- package/dist/templates/utils/orderNavItems.js +2 -0
- package/dist/templates/utils/strings.d.ts +1 -0
- package/dist/templates/utils/strings.js +27 -0
- package/dist/templates/utils/variants.d.ts +1 -0
- package/dist/templates/utils/variants.js +170 -0
- package/package.json +1 -1
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { generateJsonLdScript, generateMetadataBlock, generateRuntimeOnlyMetadataBlock, } from "../lib/metadata.js";
|
|
2
2
|
import { parseUpdateBlocks } from "../lib/rss.js";
|
|
3
3
|
import { escapeTemplateContent, toJsStringLiteral } from "../lib/utils.js";
|
|
4
|
+
import { toOgLocale } from "../lib/variants.js";
|
|
4
5
|
import { rssRouteTemplate } from "../templates/app/rssRoute.js";
|
|
6
|
+
/** `<Docs>` attributes and metadata fields a page's language contributes. */
|
|
7
|
+
function languageAttributes(locale) {
|
|
8
|
+
return {
|
|
9
|
+
docsAttr: locale ? [`lang=${JSON.stringify(locale)}`] : [],
|
|
10
|
+
ogLocale: locale ? toOgLocale(locale) : undefined,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
5
13
|
/**
|
|
6
14
|
* The `const operation = JSON.parse(...)` declaration that carries an endpoint
|
|
7
15
|
* descriptor into a generated page. `toJsStringLiteral` picks the quote
|
|
@@ -25,6 +33,7 @@ export function renderMdxPage(mdxFile, options) {
|
|
|
25
33
|
const updates = isSynthetic ? [] : parseUpdateBlocks(mdxFile.content);
|
|
26
34
|
const hasFeed = updates.length > 0;
|
|
27
35
|
const feedPath = `/${mdxFile.slug}/rss.xml`;
|
|
36
|
+
const language = languageAttributes(mdxFile.locale);
|
|
28
37
|
const metadataBlock = generateMetadataBlock({
|
|
29
38
|
title: fm.title,
|
|
30
39
|
titleFallback: "Generated with Doccupine",
|
|
@@ -35,6 +44,8 @@ export function renderMdxPage(mdxFile, options) {
|
|
|
35
44
|
image: fm.image,
|
|
36
45
|
canonicalPath: mdxFile.slug,
|
|
37
46
|
rssPath: hasFeed ? feedPath : undefined,
|
|
47
|
+
alternateLanguages: options?.alternateLanguages,
|
|
48
|
+
ogLocale: language.ogLocale,
|
|
38
49
|
});
|
|
39
50
|
const jsonLd = generateJsonLdScript({
|
|
40
51
|
kind: "article",
|
|
@@ -58,11 +69,12 @@ export function renderMdxPage(mdxFile, options) {
|
|
|
58
69
|
const docsAttrs = [
|
|
59
70
|
`content={content}`,
|
|
60
71
|
`sourcePath={${sourcePathLiteral}}`,
|
|
72
|
+
...language.docsAttr,
|
|
61
73
|
...(showRssButton ? [`rssHref={${JSON.stringify(feedPath)}}`] : []),
|
|
62
74
|
];
|
|
63
75
|
const inlineDocs = `<Docs ${docsAttrs.join(" ")} />`;
|
|
64
76
|
const docsElement = apiOperation
|
|
65
|
-
? `<Docs content={content}>
|
|
77
|
+
? `<Docs ${["content={content}", ...language.docsAttr].join(" ")}>
|
|
66
78
|
<ApiPlayground operation={operation} />
|
|
67
79
|
</Docs>`
|
|
68
80
|
: inlineDocs.length + 6 <= 80
|
|
@@ -121,10 +133,11 @@ function iconsImportLine(...codeBlocks) {
|
|
|
121
133
|
? `\nimport { ${names.join(", ")} } from "@/utils/icons";`
|
|
122
134
|
: "";
|
|
123
135
|
}
|
|
124
|
-
export function renderHomepage(indexMDX, apiOperation) {
|
|
136
|
+
export function renderHomepage(indexMDX, apiOperation, options = {}) {
|
|
125
137
|
const updates = indexMDX ? parseUpdateBlocks(indexMDX.content) : [];
|
|
126
138
|
const hasFeed = updates.length > 0;
|
|
127
139
|
const feedPath = "/rss.xml";
|
|
140
|
+
const language = languageAttributes(options.locale);
|
|
128
141
|
const metadataBlock = indexMDX
|
|
129
142
|
? generateMetadataBlock({
|
|
130
143
|
title: indexMDX.title,
|
|
@@ -136,6 +149,8 @@ export function renderHomepage(indexMDX, apiOperation) {
|
|
|
136
149
|
image: indexMDX.image,
|
|
137
150
|
canonicalPath: "",
|
|
138
151
|
rssPath: hasFeed ? feedPath : undefined,
|
|
152
|
+
alternateLanguages: options.alternateLanguages,
|
|
153
|
+
ogLocale: language.ogLocale,
|
|
139
154
|
})
|
|
140
155
|
: generateRuntimeOnlyMetadataBlock();
|
|
141
156
|
const homeJsonLd = generateJsonLdScript({
|
|
@@ -152,13 +167,19 @@ export function renderHomepage(indexMDX, apiOperation) {
|
|
|
152
167
|
: "";
|
|
153
168
|
const apiConst = apiOperationDeclaration(apiOperation);
|
|
154
169
|
const showRssButton = hasFeed && indexMDX?.rss === true && !apiOperation;
|
|
170
|
+
const homeAttrs = [
|
|
171
|
+
`content={content}`,
|
|
172
|
+
`sourcePath="index.mdx"`,
|
|
173
|
+
...language.docsAttr,
|
|
174
|
+
];
|
|
175
|
+
const inlineDocs = `<Docs ${[...homeAttrs, ...(showRssButton ? [`rssHref={"/rss.xml"}`] : [])].join(" ")} />`;
|
|
155
176
|
const docsElement = apiOperation
|
|
156
|
-
? `<Docs
|
|
177
|
+
? `<Docs ${homeAttrs.join(" ")}>
|
|
157
178
|
<ApiPlayground operation={operation} />
|
|
158
179
|
</Docs>`
|
|
159
|
-
:
|
|
160
|
-
?
|
|
161
|
-
: `<Docs
|
|
180
|
+
: inlineDocs.length + 6 <= 80
|
|
181
|
+
? inlineDocs
|
|
182
|
+
: `<Docs\n${[...homeAttrs, ...(showRssButton ? [`rssHref={"/rss.xml"}`] : [])].map((attr) => ` ${attr}`).join("\n")}\n />`;
|
|
162
183
|
const iconsImport = iconsImportLine(metadataBlock, homeJsonLd.declarations);
|
|
163
184
|
const pageContent = `import { Metadata } from "next";
|
|
164
185
|
import { Docs } from "@/components/Docs";
|
|
@@ -199,11 +220,14 @@ export default function Home() {
|
|
|
199
220
|
: { action: "remove" };
|
|
200
221
|
return { pageContent, rssRoute };
|
|
201
222
|
}
|
|
202
|
-
|
|
223
|
+
/** `routeSlug` is the full route of the section index (`api`, or `de/api`
|
|
224
|
+
* inside a language folder). */
|
|
225
|
+
export function renderSectionPage(routeSlug, frontmatter, mdxContent, sourcePath, options = {}) {
|
|
203
226
|
const updates = parseUpdateBlocks(mdxContent);
|
|
204
227
|
const hasFeed = updates.length > 0;
|
|
205
|
-
const feedPath = `/${
|
|
228
|
+
const feedPath = `/${routeSlug}/rss.xml`;
|
|
206
229
|
const showRssButton = hasFeed && frontmatter.rss === true;
|
|
230
|
+
const language = languageAttributes(options.locale);
|
|
207
231
|
const metadataBlock = generateMetadataBlock({
|
|
208
232
|
title: frontmatter.title,
|
|
209
233
|
titleFallback: "Section",
|
|
@@ -212,12 +236,14 @@ export function renderSectionPage(sectionSlug, frontmatter, mdxContent, sourcePa
|
|
|
212
236
|
description: frontmatter.description || undefined,
|
|
213
237
|
icon: frontmatter.icon,
|
|
214
238
|
image: frontmatter.image,
|
|
215
|
-
canonicalPath:
|
|
239
|
+
canonicalPath: routeSlug,
|
|
216
240
|
rssPath: hasFeed ? feedPath : undefined,
|
|
241
|
+
alternateLanguages: options.alternateLanguages,
|
|
242
|
+
ogLocale: language.ogLocale,
|
|
217
243
|
});
|
|
218
244
|
const sectionJsonLd = generateJsonLdScript({
|
|
219
245
|
kind: "article",
|
|
220
|
-
canonicalPath:
|
|
246
|
+
canonicalPath: routeSlug,
|
|
221
247
|
title: frontmatter.title,
|
|
222
248
|
description: frontmatter.description,
|
|
223
249
|
date: typeof frontmatter.date === "string" ? frontmatter.date : undefined,
|
|
@@ -230,7 +256,8 @@ export function renderSectionPage(sectionSlug, frontmatter, mdxContent, sourcePa
|
|
|
230
256
|
});
|
|
231
257
|
const docsAttrs = [
|
|
232
258
|
`content={content}`,
|
|
233
|
-
`sourcePath={${JSON.stringify(sourcePath ?? `${
|
|
259
|
+
`sourcePath={${JSON.stringify(sourcePath ?? `${routeSlug}/index.mdx`)}}`,
|
|
260
|
+
...language.docsAttr,
|
|
234
261
|
...(showRssButton ? [`rssHref={${JSON.stringify(feedPath)}}`] : []),
|
|
235
262
|
];
|
|
236
263
|
const inlineDocs = `<Docs ${docsAttrs.join(" ")} />`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnalyticsConfig, FontConfig, SectionConfig } from "../lib/types.js";
|
|
1
|
+
import type { AnalyticsConfig, FontConfig, LanguageConfig, SectionConfig, VersionConfig } from "../lib/types.js";
|
|
2
2
|
import { SecureSourceFs } from "./secure-source-fs.js";
|
|
3
3
|
export declare class ProjectConfigRepository {
|
|
4
4
|
private readonly rootDir;
|
|
@@ -32,4 +32,7 @@ export declare class ProjectConfigRepository {
|
|
|
32
32
|
copyAnalyticsConfig(loadConfig: () => Promise<AnalyticsConfig | null>): Promise<void>;
|
|
33
33
|
resetAnalyticsConfig(): Promise<void>;
|
|
34
34
|
loadSectionsConfig(): Promise<SectionConfig[] | null>;
|
|
35
|
+
private loadVariantConfig;
|
|
36
|
+
loadLanguagesConfig(): Promise<LanguageConfig[] | null>;
|
|
37
|
+
loadVersionsConfig(): Promise<VersionConfig[] | null>;
|
|
35
38
|
}
|
|
@@ -5,11 +5,14 @@ import path from "node:path";
|
|
|
5
5
|
import { resolveOutputPath } from "../lib/output-safety.js";
|
|
6
6
|
import { validateAnalyticsConfig, validateFontConfig, } from "../lib/project-config.js";
|
|
7
7
|
import { writeFileAtomic } from "../lib/utils.js";
|
|
8
|
+
import { validateLanguagesConfig, validateVersionsConfig, } from "../lib/variants.js";
|
|
8
9
|
import { validateSectionsConfig } from "./section-resolver.js";
|
|
9
10
|
const ARRAY_CONFIG_DEFAULTS = new Set([
|
|
11
|
+
"languages.json",
|
|
10
12
|
"links.json",
|
|
11
13
|
"navigation.json",
|
|
12
14
|
"sections.json",
|
|
15
|
+
"versions.json",
|
|
13
16
|
]);
|
|
14
17
|
export class ProjectConfigRepository {
|
|
15
18
|
rootDir;
|
|
@@ -196,4 +199,27 @@ export class ProjectConfigRepository {
|
|
|
196
199
|
}
|
|
197
200
|
return null;
|
|
198
201
|
}
|
|
202
|
+
// Unlike sections.json, an invalid languages.json or versions.json is an
|
|
203
|
+
// error rather than a warning: silently ignoring it would publish every
|
|
204
|
+
// variant folder as ordinary pages at the same URLs, without the switchers,
|
|
205
|
+
// scoping, or hreflang the author expects.
|
|
206
|
+
async loadVariantConfig(fileName, validate) {
|
|
207
|
+
const content = await this.readOptionalRootSourceFile(fileName, "variant source");
|
|
208
|
+
if (content === null)
|
|
209
|
+
return null;
|
|
210
|
+
let parsed;
|
|
211
|
+
try {
|
|
212
|
+
parsed = JSON.parse(content);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
throw new Error(`${fileName} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
216
|
+
}
|
|
217
|
+
return validate(parsed);
|
|
218
|
+
}
|
|
219
|
+
async loadLanguagesConfig() {
|
|
220
|
+
return this.loadVariantConfig("languages.json", validateLanguagesConfig);
|
|
221
|
+
}
|
|
222
|
+
async loadVersionsConfig() {
|
|
223
|
+
return this.loadVariantConfig("versions.json", validateVersionsConfig);
|
|
224
|
+
}
|
|
199
225
|
}
|
|
@@ -16,6 +16,16 @@ export declare class PublicAssetManager {
|
|
|
16
16
|
handlePublicFileDelete(filePath: string, copyCurrentSource: () => Promise<void>, restoreGeneratedArtifacts: () => Promise<void>): Promise<void>;
|
|
17
17
|
findSourcePublicAsset(relativePath: string): Promise<string | null>;
|
|
18
18
|
writePublicAggregate(relativePath: string, content: string): Promise<void>;
|
|
19
|
+
hasVariantAggregates(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Writes the per-language/version `llms.txt` and `llms-full.txt` files and
|
|
22
|
+
* removes the ones a previous run wrote for a variant that no longer
|
|
23
|
+
* exists. A project asset that owns one of the paths wins, as for every
|
|
24
|
+
* generated public file.
|
|
25
|
+
*/
|
|
26
|
+
syncVariantAggregates(files: ReadonlyMap<string, string>): Promise<void>;
|
|
27
|
+
/** Removes now-empty directories under public/ left by a stale aggregate. */
|
|
28
|
+
private removeEmptyPublicDirs;
|
|
19
29
|
syncMcpManifest(baseUrl: string | null, siteName: string): Promise<void>;
|
|
20
30
|
syncLlmsPageFiles(pages: PageWithBody[], baseUrl: string | null): Promise<void>;
|
|
21
31
|
}
|
|
@@ -11,15 +11,20 @@ const PUBLIC_AGGREGATE_PATHS = new Set([
|
|
|
11
11
|
"skill.md",
|
|
12
12
|
".well-known/mcp.json",
|
|
13
13
|
]);
|
|
14
|
+
// `llms.txt` / `llms-full.txt` under a language or version prefix
|
|
15
|
+
// (`de/llms.txt`, `de/v1/llms-full.txt`).
|
|
16
|
+
const VARIANT_AGGREGATE_PATTERN = /^(?:[a-z0-9-]+\/)+llms(?:-full)?\.txt$/;
|
|
14
17
|
function normalizePublicArtifactPath(relativePath) {
|
|
15
18
|
return relativePath.replace(/\\/g, "/").toLowerCase();
|
|
16
19
|
}
|
|
17
20
|
function isPublicAggregate(relativePath) {
|
|
18
|
-
|
|
21
|
+
const normalized = normalizePublicArtifactPath(relativePath);
|
|
22
|
+
return (PUBLIC_AGGREGATE_PATHS.has(normalized) ||
|
|
23
|
+
VARIANT_AGGREGATE_PATTERN.test(normalized));
|
|
19
24
|
}
|
|
20
25
|
function isManagedPublicArtifact(relativePath) {
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
return (isPublicAggregate(relativePath) ||
|
|
27
|
+
normalizePublicArtifactPath(relativePath).endsWith(".md"));
|
|
23
28
|
}
|
|
24
29
|
function publicDestinationRelativePath(relativePath) {
|
|
25
30
|
return isPublicAggregate(relativePath)
|
|
@@ -169,6 +174,61 @@ export class PublicAssetManager {
|
|
|
169
174
|
await fs.ensureDir(path.dirname(targetPath));
|
|
170
175
|
await writeFileAtomic(targetPath, content);
|
|
171
176
|
}
|
|
177
|
+
hasVariantAggregates() {
|
|
178
|
+
return this.artifacts.llmsVariantFiles().size > 0;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Writes the per-language/version `llms.txt` and `llms-full.txt` files and
|
|
182
|
+
* removes the ones a previous run wrote for a variant that no longer
|
|
183
|
+
* exists. A project asset that owns one of the paths wins, as for every
|
|
184
|
+
* generated public file.
|
|
185
|
+
*/
|
|
186
|
+
async syncVariantAggregates(files) {
|
|
187
|
+
const publicDir = this.outputPath("public");
|
|
188
|
+
const nextRelativePaths = new Set();
|
|
189
|
+
for (const [relativePath, content] of files) {
|
|
190
|
+
const sourcePath = await this.findSourcePublicAsset(relativePath);
|
|
191
|
+
if (sourcePath) {
|
|
192
|
+
console.warn(chalk.yellow(`⚠️ Skipping generated public/${relativePath}; a project public asset owns that path`));
|
|
193
|
+
await this.copyRegularPublicFile(sourcePath, this.publicOutputFilePath(relativePath));
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const targetPath = this.publicOutputFilePath(relativePath);
|
|
197
|
+
await fs.ensureDir(path.dirname(targetPath));
|
|
198
|
+
await writeFileAtomic(targetPath, content);
|
|
199
|
+
nextRelativePaths.add(relativePath);
|
|
200
|
+
}
|
|
201
|
+
for (const stale of this.artifacts.llmsVariantFiles()) {
|
|
202
|
+
if (nextRelativePaths.has(stale))
|
|
203
|
+
continue;
|
|
204
|
+
try {
|
|
205
|
+
if (await this.findSourcePublicAsset(stale))
|
|
206
|
+
continue;
|
|
207
|
+
const stalePath = resolveOutputPath(publicDir, stale);
|
|
208
|
+
if (await fs.pathExists(stalePath)) {
|
|
209
|
+
await fs.remove(stalePath);
|
|
210
|
+
await this.removeEmptyPublicDirs(path.dirname(stalePath));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// ignore
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this.artifacts.replaceLlmsVariantFiles(nextRelativePaths);
|
|
218
|
+
await this.artifacts.save();
|
|
219
|
+
}
|
|
220
|
+
/** Removes now-empty directories under public/ left by a stale aggregate. */
|
|
221
|
+
async removeEmptyPublicDirs(dir) {
|
|
222
|
+
const publicDir = this.outputPath("public");
|
|
223
|
+
let current = dir;
|
|
224
|
+
while (current !== publicDir && current.startsWith(publicDir)) {
|
|
225
|
+
const entries = await fs.readdir(current).catch(() => null);
|
|
226
|
+
if (entries === null || entries.length > 0)
|
|
227
|
+
return;
|
|
228
|
+
await fs.remove(current);
|
|
229
|
+
current = path.dirname(current);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
172
232
|
async syncMcpManifest(baseUrl, siteName) {
|
|
173
233
|
const relativePath = ".well-known/mcp.json";
|
|
174
234
|
const outputPath = this.publicOutputFilePath(relativePath);
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { PageMeta, SectionConfig } from "../lib/types.js";
|
|
2
|
+
import { type VariantSet } from "../lib/variants.js";
|
|
2
3
|
import { GeneratedRouteManager } from "./generated-route-manager.js";
|
|
3
4
|
type WriteRedirect = (slug: string, target: string) => Promise<void>;
|
|
4
5
|
export declare class SectionIndexGenerator {
|
|
5
6
|
private readonly outputDir;
|
|
6
7
|
private readonly routeManager;
|
|
7
8
|
constructor(outputDir: string, routeManager: GeneratedRouteManager);
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Redirect pages for every route that has pages beneath it but no page of
|
|
11
|
+
* its own: each section's index (`/api` -> its first page) and, when
|
|
12
|
+
* languages or versions are configured, each variant's home (`/de`,
|
|
13
|
+
* `/v1`, `/de/v1`) and the section indexes inside it (`/de/api`). A real
|
|
14
|
+
* page at that route (`docs/de/index.mdx`, `docs/api/index.mdx`) always
|
|
15
|
+
* wins. Without variants this reproduces the single-tree behaviour exactly.
|
|
16
|
+
*/
|
|
17
|
+
generate(pages: PageMeta[], sections: SectionConfig[] | null, declaredSlugs: Set<string> | undefined, writeRedirect: WriteRedirect, variants?: VariantSet | null): Promise<void>;
|
|
9
18
|
}
|
|
10
19
|
export {};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
import { readOutputFileIfPresent, resolveOutputPath, } from "../lib/output-safety.js";
|
|
3
3
|
import { writeFileAtomic } from "../lib/utils.js";
|
|
4
|
+
import { joinVariantSlug, listVariantPrefixes, pageVariantPrefix, } from "../lib/variants.js";
|
|
5
|
+
function byNavOrder(a, b) {
|
|
6
|
+
if (a.categoryOrder !== b.categoryOrder) {
|
|
7
|
+
return a.categoryOrder - b.categoryOrder;
|
|
8
|
+
}
|
|
9
|
+
return a.order - b.order;
|
|
10
|
+
}
|
|
4
11
|
export class SectionIndexGenerator {
|
|
5
12
|
outputDir;
|
|
6
13
|
routeManager;
|
|
@@ -8,27 +15,48 @@ export class SectionIndexGenerator {
|
|
|
8
15
|
this.outputDir = outputDir;
|
|
9
16
|
this.routeManager = routeManager;
|
|
10
17
|
}
|
|
11
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Redirect pages for every route that has pages beneath it but no page of
|
|
20
|
+
* its own: each section's index (`/api` -> its first page) and, when
|
|
21
|
+
* languages or versions are configured, each variant's home (`/de`,
|
|
22
|
+
* `/v1`, `/de/v1`) and the section indexes inside it (`/de/api`). A real
|
|
23
|
+
* page at that route (`docs/de/index.mdx`, `docs/api/index.mdx`) always
|
|
24
|
+
* wins. Without variants this reproduces the single-tree behaviour exactly.
|
|
25
|
+
*/
|
|
26
|
+
async generate(pages, sections, declaredSlugs, writeRedirect, variants = null) {
|
|
12
27
|
const occupiedSlugs = new Set(pages.map((page) => page.slug));
|
|
13
28
|
const resolvedDeclaredSlugs = new Set(occupiedSlugs);
|
|
14
29
|
for (const slug of declaredSlugs ?? [])
|
|
15
30
|
resolvedDeclaredSlugs.add(slug);
|
|
16
31
|
const redirects = new Map();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
const languages = variants?.languages ?? null;
|
|
33
|
+
const versions = variants?.versions ?? null;
|
|
34
|
+
const sectionOrder = new Map((sections ?? []).map((section, index) => [section.slug, index]));
|
|
35
|
+
for (const prefix of listVariantPrefixes(languages, versions)) {
|
|
36
|
+
const variantPages = variants
|
|
37
|
+
? pages.filter((page) => pageVariantPrefix(page, languages, versions) === prefix)
|
|
38
|
+
: pages;
|
|
39
|
+
if (prefix !== "" && !resolvedDeclaredSlugs.has(prefix)) {
|
|
40
|
+
const firstPage = [...variantPages].sort((a, b) => {
|
|
41
|
+
const sectionDelta = (sectionOrder.get(a.section) ?? Number.MAX_SAFE_INTEGER) -
|
|
42
|
+
(sectionOrder.get(b.section) ?? Number.MAX_SAFE_INTEGER);
|
|
43
|
+
return sectionDelta !== 0 ? sectionDelta : byNavOrder(a, b);
|
|
44
|
+
})[0];
|
|
45
|
+
if (firstPage)
|
|
46
|
+
redirects.set(prefix, firstPage.slug);
|
|
47
|
+
}
|
|
48
|
+
for (const section of sections ?? []) {
|
|
49
|
+
if (section.slug === "")
|
|
50
|
+
continue;
|
|
51
|
+
const route = joinVariantSlug(prefix, section.slug);
|
|
52
|
+
if (resolvedDeclaredSlugs.has(route))
|
|
53
|
+
continue;
|
|
54
|
+
const firstPage = variantPages
|
|
55
|
+
.filter((page) => page.section === section.slug)
|
|
56
|
+
.sort(byNavOrder)[0];
|
|
57
|
+
if (firstPage)
|
|
58
|
+
redirects.set(route, firstPage.slug);
|
|
20
59
|
}
|
|
21
|
-
const sectionPages = pages
|
|
22
|
-
.filter((page) => page.section === section.slug)
|
|
23
|
-
.sort((a, b) => {
|
|
24
|
-
if (a.categoryOrder !== b.categoryOrder) {
|
|
25
|
-
return a.categoryOrder - b.categoryOrder;
|
|
26
|
-
}
|
|
27
|
-
return a.order - b.order;
|
|
28
|
-
});
|
|
29
|
-
const firstPage = sectionPages[0];
|
|
30
|
-
if (firstPage)
|
|
31
|
-
redirects.set(section.slug, firstPage.slug);
|
|
32
60
|
}
|
|
33
61
|
const previousSlugs = this.routeManager.sectionIndexSlugs();
|
|
34
62
|
const touchedSlugs = new Set([...previousSlugs, ...redirects.keys()]);
|
|
@@ -7,6 +7,14 @@ export interface SectionRoute {
|
|
|
7
7
|
sectionSlug: string;
|
|
8
8
|
pageSlug: string;
|
|
9
9
|
}
|
|
10
|
+
/** A section route plus the variant (language/version) folder it was
|
|
11
|
+
* resolved under. `prefix` is the URL prefix of that variant ("" at the
|
|
12
|
+
* docs root); `locale`/`version` are present only when configured. */
|
|
13
|
+
export interface ResolvedPageRoute extends SectionRoute {
|
|
14
|
+
prefix?: string;
|
|
15
|
+
locale?: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
}
|
|
10
18
|
export declare function validateSectionsConfig(parsed: unknown): SectionConfig[] | null;
|
|
11
19
|
export declare function discoverSections(documents: SectionDocument[]): SectionConfig[] | null;
|
|
12
20
|
export declare function addApiReferenceSection(sections: SectionConfig[] | null, hasApiReference: boolean, apiBaseSlug: string): SectionConfig[] | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PageMeta, SectionConfig } from "../lib/types.js";
|
|
2
|
+
import { type VariantSet } from "../lib/variants.js";
|
|
2
3
|
import { type SitemapEntry } from "../templates/app/sitemap.js";
|
|
3
4
|
import { type PageWithBody } from "../templates/llms/llmsFull.js";
|
|
4
5
|
import type { PublicAssetManager } from "./public-asset-manager.js";
|
|
@@ -15,9 +16,9 @@ type ReadOpenApiBody = (slug: string) => string | undefined;
|
|
|
15
16
|
type ReadConfigSource = () => Promise<string | null>;
|
|
16
17
|
export declare function loadSiteUrl(readConfigSource: ReadConfigSource): Promise<string | null>;
|
|
17
18
|
export declare function loadSiteMetadata(readConfigSource: ReadConfigSource): Promise<SiteMetadata>;
|
|
18
|
-
export declare function buildSitemapEntries(pages: PageMeta[], sectionsConfig: SectionConfig[] | null): SitemapEntry[];
|
|
19
|
-
export declare function writeSitemap(outputDir: string, sectionsConfig: SectionConfig[] | null, resolvePages: ResolvePages, resolveSiteUrl: () => Promise<string | null
|
|
19
|
+
export declare function buildSitemapEntries(pages: PageMeta[], sectionsConfig: SectionConfig[] | null, variants?: VariantSet | null): SitemapEntry[];
|
|
20
|
+
export declare function writeSitemap(outputDir: string, sectionsConfig: SectionConfig[] | null, resolvePages: ResolvePages, resolveSiteUrl: () => Promise<string | null>, variants?: VariantSet | null): Promise<void>;
|
|
20
21
|
export declare function writeRobots(outputDir: string, resolveSiteUrl: () => Promise<string | null>): Promise<void>;
|
|
21
22
|
export declare function collectPageBodies(pages: PageMeta[], readMdxSource: ReadMdxSource, readOpenApiBody: ReadOpenApiBody): Promise<PageWithBody[]>;
|
|
22
|
-
export declare function writeLlmsFiles(outputDir: string, sectionsConfig: SectionConfig[] | null, resolvePages: ResolvePages, readMdxSource: ReadMdxSource, readOpenApiBody: ReadOpenApiBody, resolveSiteMetadata: () => Promise<SiteMetadata>, publicAssetManager: PublicAssetManager): Promise<void>;
|
|
23
|
+
export declare function writeLlmsFiles(outputDir: string, sectionsConfig: SectionConfig[] | null, resolvePages: ResolvePages, readMdxSource: ReadMdxSource, readOpenApiBody: ReadOpenApiBody, resolveSiteMetadata: () => Promise<SiteMetadata>, publicAssetManager: PublicAssetManager, variants?: VariantSet | null): Promise<void>;
|
|
23
24
|
export {};
|
|
@@ -2,10 +2,11 @@ import chalk from "chalk";
|
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import { resolveOutputPath } from "../lib/output-safety.js";
|
|
4
4
|
import { isMdxPath, safeMatter, writeFileAtomic } from "../lib/utils.js";
|
|
5
|
+
import { buildLanguageAlternates, joinVariantSlug, listVariantPrefixes, pageVariantPrefix, resolveVariantFromSlug, } from "../lib/variants.js";
|
|
5
6
|
import { robotsTemplate } from "../templates/app/robots.js";
|
|
6
7
|
import { sitemapTemplate, } from "../templates/app/sitemap.js";
|
|
7
8
|
import { llmsFullTemplate, } from "../templates/llms/llmsFull.js";
|
|
8
|
-
import { llmsIndexTemplate } from "../templates/llms/llmsIndex.js";
|
|
9
|
+
import { llmsIndexTemplate, } from "../templates/llms/llmsIndex.js";
|
|
9
10
|
import { skillMdTemplate } from "../templates/llms/skillMd.js";
|
|
10
11
|
export async function loadSiteUrl(readConfigSource) {
|
|
11
12
|
const fromEnv = process.env.NEXT_PUBLIC_SITE_URL?.trim();
|
|
@@ -57,23 +58,43 @@ export async function loadSiteMetadata(readConfigSource) {
|
|
|
57
58
|
}
|
|
58
59
|
return { url, name, description };
|
|
59
60
|
}
|
|
60
|
-
export function buildSitemapEntries(pages, sectionsConfig) {
|
|
61
|
+
export function buildSitemapEntries(pages, sectionsConfig, variants = null) {
|
|
61
62
|
const sectionSlugs = new Set((sectionsConfig || [])
|
|
62
63
|
.map((section) => section.slug)
|
|
63
64
|
.filter((slug) => typeof slug === "string" && slug !== ""));
|
|
65
|
+
// Section indexes rank 0.8 in every language/version, as do the variant
|
|
66
|
+
// homes themselves (`de`, `v1`).
|
|
67
|
+
const prominentSlugs = new Set();
|
|
68
|
+
for (const prefix of listVariantPrefixes(variants?.languages ?? null, variants?.versions ?? null)) {
|
|
69
|
+
if (prefix !== "")
|
|
70
|
+
prominentSlugs.add(prefix);
|
|
71
|
+
for (const slug of sectionSlugs) {
|
|
72
|
+
prominentSlugs.add(joinVariantSlug(prefix, slug));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const alternates = buildLanguageAlternates(pages, variants?.languages ?? null);
|
|
64
76
|
const entries = pages.map((page) => {
|
|
65
77
|
let priority = 0.5;
|
|
66
78
|
if (page.slug === "") {
|
|
67
79
|
priority = 1.0;
|
|
68
80
|
}
|
|
69
|
-
else if (
|
|
81
|
+
else if (prominentSlugs.has(page.slug)) {
|
|
70
82
|
priority = 0.8;
|
|
71
83
|
}
|
|
84
|
+
const pageAlternates = alternates.get(page.slug);
|
|
72
85
|
return {
|
|
73
86
|
slug: page.slug,
|
|
74
87
|
lastModified: page.lastModified,
|
|
75
88
|
changeFrequency: "weekly",
|
|
76
89
|
priority,
|
|
90
|
+
...(pageAlternates
|
|
91
|
+
? {
|
|
92
|
+
alternates: Object.fromEntries(Object.entries(pageAlternates).map(([lang, href]) => [
|
|
93
|
+
lang,
|
|
94
|
+
href.replace(/^\/+/, ""),
|
|
95
|
+
])),
|
|
96
|
+
}
|
|
97
|
+
: {}),
|
|
77
98
|
};
|
|
78
99
|
});
|
|
79
100
|
if (!entries.some((entry) => entry.slug === "")) {
|
|
@@ -85,9 +106,9 @@ export function buildSitemapEntries(pages, sectionsConfig) {
|
|
|
85
106
|
}
|
|
86
107
|
return entries;
|
|
87
108
|
}
|
|
88
|
-
export async function writeSitemap(outputDir, sectionsConfig, resolvePages, resolveSiteUrl) {
|
|
109
|
+
export async function writeSitemap(outputDir, sectionsConfig, resolvePages, resolveSiteUrl, variants = null) {
|
|
89
110
|
const siteUrl = await resolveSiteUrl();
|
|
90
|
-
const entries = buildSitemapEntries(await resolvePages(), sectionsConfig);
|
|
111
|
+
const entries = buildSitemapEntries(await resolvePages(), sectionsConfig, variants);
|
|
91
112
|
await writeFileAtomic(resolveOutputPath(outputDir, "app", "sitemap.ts"), sitemapTemplate(entries));
|
|
92
113
|
console.log(chalk.green(`🗺️ Generated sitemap.ts with ${entries.length} page(s)${siteUrl ? ` using ${siteUrl}` : " (waiting for a deployment URL)"}`));
|
|
93
114
|
}
|
|
@@ -108,7 +129,16 @@ export async function collectPageBodies(pages, readMdxSource, readOpenApiBody) {
|
|
|
108
129
|
return { ...page, body };
|
|
109
130
|
}));
|
|
110
131
|
}
|
|
111
|
-
|
|
132
|
+
/** "Deutsch", "v1.0", or "Deutsch (v1.0)": the label of a variant prefix. */
|
|
133
|
+
function variantLabel(prefix, languages, versions) {
|
|
134
|
+
const { locale, version } = resolveVariantFromSlug(prefix, languages, versions);
|
|
135
|
+
const language = languages?.find((entry) => entry.code === locale)?.label;
|
|
136
|
+
const versionLabel = versions?.find((entry) => entry.slug === version)?.label;
|
|
137
|
+
if (language && versionLabel)
|
|
138
|
+
return `${language} (${versionLabel})`;
|
|
139
|
+
return language ?? versionLabel ?? prefix;
|
|
140
|
+
}
|
|
141
|
+
export async function writeLlmsFiles(outputDir, sectionsConfig, resolvePages, readMdxSource, readOpenApiBody, resolveSiteMetadata, publicAssetManager, variants = null) {
|
|
112
142
|
await fs.ensureDir(resolveOutputPath(outputDir, "public"));
|
|
113
143
|
const { url: baseUrl, name, description } = await resolveSiteMetadata();
|
|
114
144
|
const resolvedPages = await resolvePages();
|
|
@@ -123,30 +153,85 @@ export async function writeLlmsFiles(outputDir, sectionsConfig, resolvePages, re
|
|
|
123
153
|
name: page.title,
|
|
124
154
|
path: pagePath,
|
|
125
155
|
content: page.body,
|
|
156
|
+
// Present only on sites that configure languages.json / versions.json.
|
|
157
|
+
...(page.locale !== undefined ? { locale: page.locale } : {}),
|
|
158
|
+
...(page.version !== undefined ? { version: page.version } : {}),
|
|
126
159
|
};
|
|
127
160
|
});
|
|
128
161
|
await writeFileAtomic(resolveOutputPath(outputDir, "services", "mcp", "docs-content.json"), JSON.stringify(docsContent, null, 2) + "\n");
|
|
162
|
+
// Each language/version gets its own llms.txt and llms-full.txt under its
|
|
163
|
+
// URL prefix; the root files describe the default variant and link to the
|
|
164
|
+
// others. Without variants there is exactly one group, the root.
|
|
165
|
+
const languages = variants?.languages ?? null;
|
|
166
|
+
const versions = variants?.versions ?? null;
|
|
167
|
+
const prefixes = listVariantPrefixes(languages, versions);
|
|
168
|
+
const pagesByPrefix = new Map(prefixes.map((prefix) => [prefix, []]));
|
|
169
|
+
for (const page of pagesWithBodies) {
|
|
170
|
+
const prefix = variants ? pageVariantPrefix(page, languages, versions) : "";
|
|
171
|
+
pagesByPrefix.get(prefix)?.push(page);
|
|
172
|
+
}
|
|
173
|
+
const urlPrefix = baseUrl ?? "";
|
|
174
|
+
const linksFor = (current) => prefixes.length > 1
|
|
175
|
+
? {
|
|
176
|
+
heading: "Other languages and versions",
|
|
177
|
+
links: prefixes
|
|
178
|
+
.filter((prefix) => prefix !== current)
|
|
179
|
+
.map((prefix) => ({
|
|
180
|
+
label: variantLabel(prefix, languages, versions),
|
|
181
|
+
url: `${urlPrefix}/${joinVariantSlug(prefix, "llms.txt")}`,
|
|
182
|
+
})),
|
|
183
|
+
}
|
|
184
|
+
: undefined;
|
|
185
|
+
const rootPages = pagesByPrefix.get("") ?? [];
|
|
129
186
|
const indexContent = llmsIndexTemplate({
|
|
130
187
|
siteName: name,
|
|
131
188
|
siteDescription: description,
|
|
132
189
|
baseUrl,
|
|
133
|
-
pages:
|
|
190
|
+
pages: rootPages,
|
|
134
191
|
sectionsConfig,
|
|
192
|
+
variantLinks: linksFor(""),
|
|
135
193
|
});
|
|
136
194
|
const fullContent = llmsFullTemplate({
|
|
137
195
|
siteName: name,
|
|
138
196
|
siteDescription: description,
|
|
139
197
|
baseUrl,
|
|
140
|
-
pages:
|
|
198
|
+
pages: rootPages,
|
|
141
199
|
sectionsConfig,
|
|
142
200
|
});
|
|
143
201
|
await publicAssetManager.writePublicAggregate("llms.txt", indexContent);
|
|
144
202
|
await publicAssetManager.writePublicAggregate("llms-full.txt", fullContent);
|
|
203
|
+
const variantAggregates = new Map();
|
|
204
|
+
for (const prefix of prefixes) {
|
|
205
|
+
if (prefix === "")
|
|
206
|
+
continue;
|
|
207
|
+
const variantPages = pagesByPrefix.get(prefix) ?? [];
|
|
208
|
+
variantAggregates.set(`${prefix}/llms.txt`, llmsIndexTemplate({
|
|
209
|
+
siteName: name,
|
|
210
|
+
siteDescription: description,
|
|
211
|
+
baseUrl,
|
|
212
|
+
pages: variantPages,
|
|
213
|
+
sectionsConfig,
|
|
214
|
+
variantLinks: linksFor(prefix),
|
|
215
|
+
variantPrefix: prefix,
|
|
216
|
+
}));
|
|
217
|
+
variantAggregates.set(`${prefix}/llms-full.txt`, llmsFullTemplate({
|
|
218
|
+
siteName: name,
|
|
219
|
+
siteDescription: description,
|
|
220
|
+
baseUrl,
|
|
221
|
+
pages: variantPages,
|
|
222
|
+
sectionsConfig,
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
// Also runs when the variant files were just removed, so the aggregates of
|
|
226
|
+
// a previous run are cleaned up; a site that never had any skips it.
|
|
227
|
+
if (variantAggregates.size > 0 || publicAssetManager.hasVariantAggregates()) {
|
|
228
|
+
await publicAssetManager.syncVariantAggregates(variantAggregates);
|
|
229
|
+
}
|
|
145
230
|
const skillContent = skillMdTemplate({
|
|
146
231
|
siteName: name,
|
|
147
232
|
siteDescription: description,
|
|
148
233
|
baseUrl,
|
|
149
|
-
pages:
|
|
234
|
+
pages: rootPages,
|
|
150
235
|
sectionsConfig,
|
|
151
236
|
});
|
|
152
237
|
await publicAssetManager.writePublicAggregate("skill.md", skillContent);
|
|
@@ -4,6 +4,7 @@ import fs from "fs-extra";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { isPathInside } from "../lib/output-safety.js";
|
|
6
6
|
import { isMdxPath } from "../lib/utils.js";
|
|
7
|
+
import { VARIANT_CONFIG_FILES } from "../lib/variants.js";
|
|
7
8
|
export class WatchCoordinator {
|
|
8
9
|
options;
|
|
9
10
|
watcher = null;
|
|
@@ -159,8 +160,12 @@ export class WatchCoordinator {
|
|
|
159
160
|
else {
|
|
160
161
|
await callbacks.handleConfigFileDelete(sourcePath);
|
|
161
162
|
}
|
|
162
|
-
|
|
163
|
+
// These handlers already run a full MDX pass, so the mdx check below
|
|
164
|
+
// must not schedule a second one.
|
|
165
|
+
if (configFile === "sections.json" ||
|
|
166
|
+
VARIANT_CONFIG_FILES.includes(configFile)) {
|
|
163
167
|
sectionsChanged = true;
|
|
168
|
+
}
|
|
164
169
|
}
|
|
165
170
|
const fontPath = path.join(rootDir, fontConfigFile);
|
|
166
171
|
if (previous === null || previous.font !== current.font) {
|
|
@@ -8,6 +8,7 @@ export declare class GeneratedArtifacts {
|
|
|
8
8
|
private readonly outputDir;
|
|
9
9
|
private routes;
|
|
10
10
|
private llmsFiles;
|
|
11
|
+
private llmsVariantFilePaths;
|
|
11
12
|
private publicFilePaths;
|
|
12
13
|
private iconFilePaths;
|
|
13
14
|
constructor(outputDir: string);
|
|
@@ -29,6 +30,8 @@ export declare class GeneratedArtifacts {
|
|
|
29
30
|
removeRouteAndSave(kind: RouteOwnerKind, source: string): Promise<void>;
|
|
30
31
|
llmsPageFiles(): Set<string>;
|
|
31
32
|
replaceLlmsPageFiles(files: Iterable<string>): void;
|
|
33
|
+
llmsVariantFiles(): Set<string>;
|
|
34
|
+
replaceLlmsVariantFiles(files: Iterable<string>): void;
|
|
32
35
|
publicFiles(): Set<string>;
|
|
33
36
|
replacePublicFiles(files: Iterable<string>): void;
|
|
34
37
|
iconFiles(): Set<string>;
|