@farming-labs/theme 0.2.70 → 0.2.72
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/dist/docs-api.mjs +61 -13
- package/package.json +2 -2
package/dist/docs-api.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { BoundedRouteCache } from "./bounded-route-cache.mjs";
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import matter from "gray-matter";
|
|
7
|
-
import { DEFAULT_A2A_AGENT_CARD_ROUTE, DEFAULT_AGENT_SKILLS_ARCHIVE_ROUTE_PATTERN, DEFAULT_AGENT_SKILLS_INDEX_ROUTE, DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, DEFAULT_API_CATALOG_ROUTE, DEFAULT_LEGACY_SKILLS_INDEX_ROUTE, DEFAULT_SITEMAP_MD_DOCS_ROUTE, DOCS_AGENT_MANIFEST_FORMAT, DOCS_AGENT_MANIFEST_SCHEMA_URI, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsDiagnosticsRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsSearchAudience, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
|
|
7
|
+
import { DEFAULT_A2A_AGENT_CARD_ROUTE, DEFAULT_AGENT_SKILLS_ARCHIVE_ROUTE_PATTERN, DEFAULT_AGENT_SKILLS_INDEX_ROUTE, DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, DEFAULT_API_CATALOG_ROUTE, DEFAULT_LEGACY_SKILLS_INDEX_ROUTE, DEFAULT_SITEMAP_MD_DOCS_ROUTE, DOCS_AGENT_MANIFEST_FORMAT, DOCS_AGENT_MANIFEST_SCHEMA_URI, DOCS_MARKDOWN_SECTION_INDEX_FORMAT, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsDiagnosticsRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, performDocsSearchWithMetadata, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsSearchAudience, resolveDocsSearchFilters, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
|
|
8
8
|
import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/server";
|
|
9
9
|
|
|
10
10
|
//#region src/docs-api.ts
|
|
@@ -241,6 +241,7 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
|
|
|
241
241
|
},
|
|
242
242
|
capabilities: {
|
|
243
243
|
markdownRoutes: true,
|
|
244
|
+
markdownSectionDiscovery: true,
|
|
244
245
|
agentMdOverrides: true,
|
|
245
246
|
agentBlocks: true,
|
|
246
247
|
structuredAgentContracts: true,
|
|
@@ -296,6 +297,14 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
|
|
|
296
297
|
pagePattern: `/${normalizedEntry}/{slug}.md`,
|
|
297
298
|
rootPage: `/${normalizedEntry}.md`,
|
|
298
299
|
apiPattern: `${apiRoute}?format=markdown&path={slug}`,
|
|
300
|
+
sectionDiscovery: {
|
|
301
|
+
enabled: true,
|
|
302
|
+
format: DOCS_MARKDOWN_SECTION_INDEX_FORMAT,
|
|
303
|
+
indexParam: "sections",
|
|
304
|
+
sectionParam: "section",
|
|
305
|
+
tokenBudgetParam: "tokenBudget",
|
|
306
|
+
byteBudgetParam: "byteBudget"
|
|
307
|
+
},
|
|
299
308
|
resolutionOrder: [
|
|
300
309
|
"agent.md",
|
|
301
310
|
"agent audience projection",
|
|
@@ -396,10 +405,27 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
|
|
|
396
405
|
enabled: searchEnabled,
|
|
397
406
|
endpoint: `${apiRoute}?query={query}`,
|
|
398
407
|
agentEndpoint: `${apiRoute}?query={query}&audience=agent`,
|
|
408
|
+
structuredAgentEndpoint: `${apiRoute}?query={query}&audience=agent&response=structured`,
|
|
399
409
|
method: "GET",
|
|
400
410
|
queryParam: "query",
|
|
401
411
|
localeParam: "lang",
|
|
402
412
|
audienceParam: "audience",
|
|
413
|
+
responseParam: "response",
|
|
414
|
+
structuredResponseValue: "structured",
|
|
415
|
+
responseFormat: "docs-search.v1",
|
|
416
|
+
filterParams: {
|
|
417
|
+
framework: "framework",
|
|
418
|
+
version: "version",
|
|
419
|
+
package: "package",
|
|
420
|
+
tags: "tags"
|
|
421
|
+
},
|
|
422
|
+
repeatedFilterParams: [
|
|
423
|
+
"framework",
|
|
424
|
+
"version",
|
|
425
|
+
"package",
|
|
426
|
+
"tags"
|
|
427
|
+
],
|
|
428
|
+
warningsField: "warnings",
|
|
403
429
|
defaultAudience: "human",
|
|
404
430
|
supportedAudiences: ["human", "agent"]
|
|
405
431
|
},
|
|
@@ -969,6 +995,9 @@ function scanDocsDir(docsDir, entry, locale, excludedDirs = [], publicPath = `/$
|
|
|
969
995
|
if (resolvePageSidebarFolderIndexBehavior(data.sidebar) === "hidden" && hasVisibleDescendantDocsSearchPage(dir)) {} else {
|
|
970
996
|
const title = data.title || slugParts[slugParts.length - 1]?.replace(/-/g, " ") || "Documentation";
|
|
971
997
|
const description = data.description;
|
|
998
|
+
const framework = typeof data.framework === "string" ? data.framework : void 0;
|
|
999
|
+
const version = typeof data.version === "string" ? data.version : void 0;
|
|
1000
|
+
const tags = Array.isArray(data.tags) ? data.tags.filter((value) => typeof value === "string") : void 0;
|
|
972
1001
|
const { content: fileContent } = matter(raw);
|
|
973
1002
|
const rawContent = resolveDocsAudienceMdxContent(fileContent, "human");
|
|
974
1003
|
const agentRawContent = resolveDocsAudienceMdxContent(fileContent, "agent");
|
|
@@ -987,6 +1016,9 @@ function scanDocsDir(docsDir, entry, locale, excludedDirs = [], publicPath = `/$
|
|
|
987
1016
|
sourcePath: pageSource.replace(/\\/g, "/"),
|
|
988
1017
|
lastModified: fs.statSync(pageSource).mtime.toISOString(),
|
|
989
1018
|
locale,
|
|
1019
|
+
framework,
|
|
1020
|
+
version,
|
|
1021
|
+
tags,
|
|
990
1022
|
...agentDoc
|
|
991
1023
|
});
|
|
992
1024
|
}
|
|
@@ -1283,8 +1315,8 @@ function renderSkillDocument({ origin, entry, apiRoute, apiCatalog, search, mcp,
|
|
|
1283
1315
|
if (siteDescription) lines.push(`Description: ${siteDescription}`);
|
|
1284
1316
|
lines.push("", "## When To Use", "Use this skill when you need to read or implement against this documentation site.", "", "## Start Here", `- Fetch ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}; fall back to ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE} or ${agentSpecRoute}.`);
|
|
1285
1317
|
if (apiCatalog) lines.push(`- Fetch ${DEFAULT_API_CATALOG_ROUTE} for the standards-based API catalog.`);
|
|
1286
|
-
lines.push(`- Fetch ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE} to discover the published site skill and verify its SHA-256 digest.`, `- Fetch /${normalizedEntry}.md for the root docs page.`, `- Fetch /${normalizedEntry}/{slug}.md for page-specific context.`, "- You can also request text/markdown from normal page URLs.");
|
|
1287
|
-
if (searchEnabled) lines.push(`- Search with ${apiRoute}?query={query}&audience=agent when you do not know the page.`);
|
|
1318
|
+
lines.push(`- Fetch ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE} to discover the published site skill and verify its SHA-256 digest.`, `- Fetch /${normalizedEntry}.md for the root docs page.`, `- Fetch /${normalizedEntry}/{slug}.md for page-specific context.`, `- Fetch /${normalizedEntry}/{slug}.md?sections to list section IDs and size estimates before requesting ?section={id}.`, "- You can also request text/markdown from normal page URLs.");
|
|
1319
|
+
if (searchEnabled) lines.push(`- Search with ${apiRoute}?query={query}&audience=agent&response=structured when you do not know the page; add framework, version, package, or repeated tags filters when scope matters.`);
|
|
1288
1320
|
if (openapi.enabled && openapiUrl) lines.push(`- Fetch ${openapiUrl} for the machine-readable OpenAPI schema before scraping API reference pages.`);
|
|
1289
1321
|
if (llms.enabled) {
|
|
1290
1322
|
lines.push(`- Use ${DEFAULT_LLMS_TXT_ROUTE} for a compact docs index.`, `- Use ${DEFAULT_LLMS_FULL_TXT_ROUTE} for full markdown context.`);
|
|
@@ -1299,7 +1331,7 @@ function renderSkillDocument({ origin, entry, apiRoute, apiCatalog, search, mcp,
|
|
|
1299
1331
|
if (feedback.enabled) lines.push(`- Read ${feedback.schemaRoute} before posting agent feedback to ${feedback.route}.`);
|
|
1300
1332
|
lines.push("", "## Routes", `- Agent instructions: ${DEFAULT_AGENTS_MD_ROUTE}`, `- Agent instructions well-known alias: ${DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE}`, `- Agent instructions API format: ${apiRoute}?format=agents`, `- Skill document: ${DEFAULT_SKILL_MD_ROUTE}`, `- Skill well-known alias: ${DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE}`, `- Skill API format: ${apiRoute}?format=skill`, `- Agent discovery: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}`, `- Agent discovery fallback: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE}`);
|
|
1301
1333
|
if (apiCatalog) lines.push(`- API catalog: ${DEFAULT_API_CATALOG_ROUTE}`);
|
|
1302
|
-
lines.push(`- Agent Skills index: ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE}`, `- Agent Skills artifacts: ${DEFAULT_AGENT_SKILLS_ROUTE_PREFIX}/{name}/SKILL.md`, `- Markdown root: /${normalizedEntry}.md`, `- Markdown pages: /${normalizedEntry}/{slug}.md`);
|
|
1334
|
+
lines.push(`- Agent Skills index: ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE}`, `- Agent Skills artifacts: ${DEFAULT_AGENT_SKILLS_ROUTE_PREFIX}/{name}/SKILL.md`, `- Markdown root: /${normalizedEntry}.md`, `- Markdown pages: /${normalizedEntry}/{slug}.md`, `- Markdown section index: /${normalizedEntry}/{slug}.md?sections`, `- Markdown section fetch: /${normalizedEntry}/{slug}.md?section={id}&tokenBudget={tokens}`);
|
|
1303
1335
|
if (robotsEnabled) lines.push(`- Robots policy: ${DEFAULT_ROBOTS_TXT_ROUTE}`);
|
|
1304
1336
|
if (llms.enabled) {
|
|
1305
1337
|
lines.push(`- llms.txt: ${DEFAULT_LLMS_TXT_ROUTE}`, `- llms-full.txt: ${DEFAULT_LLMS_FULL_TXT_ROUTE}`, `- llms well-known aliases: ${DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE}, ${DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE}`);
|
|
@@ -1339,7 +1371,7 @@ function renderAgentsDocument({ origin, entry, apiRoute, apiCatalog, search, mcp
|
|
|
1339
1371
|
if (siteDescription) lines.push(`Description: ${siteDescription}`);
|
|
1340
1372
|
lines.push("", "## Start Here", `- Read ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE} first; fall back to ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE} or ${agentSpecRoute}.`);
|
|
1341
1373
|
if (apiCatalog) lines.push(`- Read ${DEFAULT_API_CATALOG_ROUTE} for the standards-based API catalog.`);
|
|
1342
|
-
lines.push(`- Read ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE} to discover the published site skill and verify its SHA-256 digest.`, `- Read /${normalizedEntry}.md for the root docs page.`, `- Read /${normalizedEntry}/{slug}.md for page-specific context.`);
|
|
1374
|
+
lines.push(`- Read ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE} to discover the published site skill and verify its SHA-256 digest.`, `- Read /${normalizedEntry}.md for the root docs page.`, `- Read /${normalizedEntry}/{slug}.md for page-specific context.`, `- Read /${normalizedEntry}/{slug}.md?sections before fetching ?section={id} when a full page is larger than needed.`);
|
|
1343
1375
|
if (llms.enabled) {
|
|
1344
1376
|
lines.push(`- Use ${DEFAULT_LLMS_TXT_ROUTE} as the compact docs map.`, `- Use ${DEFAULT_LLMS_FULL_TXT_ROUTE} when you need the full markdown bundle.`);
|
|
1345
1377
|
for (const section of llmsSections) lines.push(`- Use ${section.route} for the ${section.title} section map.`);
|
|
@@ -1349,11 +1381,11 @@ function renderAgentsDocument({ origin, entry, apiRoute, apiCatalog, search, mcp
|
|
|
1349
1381
|
if (sitemapConfig.xml.enabled) lines.push(`- Use ${sitemapConfig.xml.route} for canonical URLs and freshness metadata.`);
|
|
1350
1382
|
}
|
|
1351
1383
|
if (robotsEnabled) lines.push(`- Check ${DEFAULT_ROBOTS_TXT_ROUTE} before crawling broadly.`);
|
|
1352
|
-
if (searchEnabled) lines.push(`- Search with ${apiRoute}?query={query}&audience=agent when the route is unknown.`);
|
|
1384
|
+
if (searchEnabled) lines.push(`- Search with ${apiRoute}?query={query}&audience=agent&response=structured when the route is unknown; add framework, version, package, or repeated tags filters when scope matters.`);
|
|
1353
1385
|
if (openapi.enabled && openapiUrl) lines.push(`- Fetch ${openapiUrl} before scraping API reference pages; prefer schemas over prose.`);
|
|
1354
1386
|
if (mcp.enabled) lines.push(`- Use MCP at ${DEFAULT_MCP_PUBLIC_ROUTE} or ${DEFAULT_MCP_WELL_KNOWN_ROUTE} when your environment supports MCP tools.`);
|
|
1355
1387
|
if (feedback.enabled) lines.push(`- Read ${feedback.schemaRoute} before posting feedback to ${feedback.route}.`);
|
|
1356
|
-
lines.push("", "## Working Rules", "- Prefer markdown routes, llms.txt, sitemap.md, OpenAPI schemas, and MCP tools over scraping rendered HTML.", "- Treat generated context files as discovery aids, then fetch the smallest page or section that answers the task.", "- Preserve canonical docs URLs when citing pages back to humans.", "- If a route returns a markdown 404, use the sitemap and discovery spec before guessing a slug.", "", "## Public Routes", `- Agent instructions: ${DEFAULT_AGENTS_MD_ROUTE}`, `- Agent instructions well-known alias: ${DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE}`, `- Agent instructions API format: ${apiRoute}?format=agents`, `- Agent instructions aliases: ${DEFAULT_AGENT_MD_ROUTE}, ${DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE}`, `- Site skill: ${DEFAULT_SKILL_MD_ROUTE}`, `- Site skill well-known alias: ${DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE}`, `- Site skill API format: ${apiRoute}?format=skill`, `- Markdown root: /${normalizedEntry}.md`, `- Markdown pages: /${normalizedEntry}/{slug}.md`, `- Agent discovery: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}`, `- Agent discovery fallback: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE}`);
|
|
1388
|
+
lines.push("", "## Working Rules", "- Prefer markdown routes, llms.txt, sitemap.md, OpenAPI schemas, and MCP tools over scraping rendered HTML.", "- Treat generated context files as discovery aids, then fetch the smallest page or section that answers the task.", "- Preserve canonical docs URLs when citing pages back to humans.", "- If a route returns a markdown 404, use the sitemap and discovery spec before guessing a slug.", "", "## Public Routes", `- Agent instructions: ${DEFAULT_AGENTS_MD_ROUTE}`, `- Agent instructions well-known alias: ${DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE}`, `- Agent instructions API format: ${apiRoute}?format=agents`, `- Agent instructions aliases: ${DEFAULT_AGENT_MD_ROUTE}, ${DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE}`, `- Site skill: ${DEFAULT_SKILL_MD_ROUTE}`, `- Site skill well-known alias: ${DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE}`, `- Site skill API format: ${apiRoute}?format=skill`, `- Markdown root: /${normalizedEntry}.md`, `- Markdown pages: /${normalizedEntry}/{slug}.md`, `- Markdown section index: /${normalizedEntry}/{slug}.md?sections`, `- Markdown section fetch: /${normalizedEntry}/{slug}.md?section={id}&tokenBudget={tokens}`, `- Agent discovery: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}`, `- Agent discovery fallback: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE}`);
|
|
1357
1389
|
if (apiCatalog) lines.push(`- API catalog: ${DEFAULT_API_CATALOG_ROUTE}`);
|
|
1358
1390
|
lines.push(`- Agent Skills index: ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE}`, `- Agent Skills artifacts: ${DEFAULT_AGENT_SKILLS_ROUTE_PREFIX}/{name}/SKILL.md`);
|
|
1359
1391
|
if (llms.enabled) {
|
|
@@ -3122,19 +3154,35 @@ function createDocsAPI(options) {
|
|
|
3122
3154
|
} });
|
|
3123
3155
|
}
|
|
3124
3156
|
const query = url.searchParams.get("query")?.trim();
|
|
3125
|
-
if (!query) return new Response(JSON.stringify([]), { headers: { "Content-Type": "application/json" } });
|
|
3126
|
-
const searchStartedAt = Date.now();
|
|
3127
3157
|
const audience = resolveDocsSearchAudience(url.searchParams.get("audience"));
|
|
3128
|
-
const
|
|
3158
|
+
const filters = resolveDocsSearchFilters(url.searchParams);
|
|
3159
|
+
const structured = url.searchParams.get("response") === "structured";
|
|
3160
|
+
if (!query) {
|
|
3161
|
+
const searchResponse = structured ? {
|
|
3162
|
+
format: "docs-search.v1",
|
|
3163
|
+
query: "",
|
|
3164
|
+
audience,
|
|
3165
|
+
filters,
|
|
3166
|
+
resultCount: 0,
|
|
3167
|
+
results: [],
|
|
3168
|
+
warnings: []
|
|
3169
|
+
} : [];
|
|
3170
|
+
return new Response(JSON.stringify(searchResponse), { headers: { "Content-Type": "application/json" } });
|
|
3171
|
+
}
|
|
3172
|
+
const searchStartedAt = Date.now();
|
|
3173
|
+
const searchOptions = {
|
|
3129
3174
|
pages: getIndexes(ctx),
|
|
3130
3175
|
query,
|
|
3131
3176
|
search: resolveSearchRequestConfig(searchConfig, request.url),
|
|
3132
3177
|
audience,
|
|
3178
|
+
filters,
|
|
3133
3179
|
locale: ctx.locale,
|
|
3134
3180
|
pathname: url.searchParams.get("pathname") ?? void 0,
|
|
3135
3181
|
siteTitle: llmsConfig.siteTitle ?? "Documentation",
|
|
3136
3182
|
baseUrl: markdownMetadataBaseUrl || url.origin
|
|
3137
|
-
}
|
|
3183
|
+
};
|
|
3184
|
+
const searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : await performDocsSearch(searchOptions);
|
|
3185
|
+
const resultCount = Array.isArray(searchResponse) ? searchResponse.length : searchResponse.resultCount;
|
|
3138
3186
|
await emitDocsAnalyticsEvent(analytics, {
|
|
3139
3187
|
type: "api_search",
|
|
3140
3188
|
source: "server",
|
|
@@ -3146,12 +3194,12 @@ function createDocsAPI(options) {
|
|
|
3146
3194
|
...requestAnalyticsProperties,
|
|
3147
3195
|
queryLength: query.length,
|
|
3148
3196
|
audience,
|
|
3149
|
-
resultCount
|
|
3197
|
+
resultCount,
|
|
3150
3198
|
pathname: url.searchParams.get("pathname") ?? void 0,
|
|
3151
3199
|
durationMs: Math.max(0, Date.now() - searchStartedAt)
|
|
3152
3200
|
}
|
|
3153
3201
|
});
|
|
3154
|
-
return new Response(JSON.stringify(
|
|
3202
|
+
return new Response(JSON.stringify(searchResponse), { headers: { "Content-Type": "application/json" } });
|
|
3155
3203
|
},
|
|
3156
3204
|
async POST(request) {
|
|
3157
3205
|
trackTelemetryRequest(request);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.72",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"tsdown": "^0.20.3",
|
|
149
149
|
"typescript": "^5.9.3",
|
|
150
150
|
"vitest": "^4.1.8",
|
|
151
|
-
"@farming-labs/docs": "0.2.
|
|
151
|
+
"@farming-labs/docs": "0.2.72"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@farming-labs/docs": ">=0.0.1",
|