@farming-labs/theme 0.2.77 → 0.2.78

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.
Files changed (2) hide show
  1. package/dist/docs-api.mjs +70 -10
  2. 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, DOCS_AGENT_MANIFEST_VERSION, 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, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, 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_AGENT_MANIFEST_VERSION, DOCS_CONTENT_CHANGES_FORMAT, DOCS_CONTENT_CHANGES_RESPONSE_VALUE, DOCS_MARKDOWN_SECTION_INDEX_FORMAT, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, buildDocsSearchFacets, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsContentChangesRequest, isDocsDiagnosticsRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, performDocsSearchWithMetadata, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsContentChangesConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
8
8
  import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceOpenApiDiscovery, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/server";
9
9
 
10
10
  //#region src/docs-api.ts
@@ -197,10 +197,11 @@ function isRobotsDiscoveryEnabled(robots) {
197
197
  function isApiReferenceOpenApiRequest(url) {
198
198
  return url.searchParams.get("format")?.trim() === "openapi";
199
199
  }
200
- function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp, feedback, llms, sitemap, robots, openapi, publishedSkills = [], agentCard }) {
200
+ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, contentChanges, mcp, feedback, llms, sitemap, robots, openapi, publishedSkills = [], agentCard }) {
201
201
  const normalizedEntry = normalizePathSegment(entry) || "docs";
202
202
  const localesEnabled = i18n !== null;
203
203
  const searchEnabled = isSearchEnabled(search);
204
+ const contentChangesEnabled = resolveDocsContentChangesConfig(contentChanges).enabled;
204
205
  const sitemapConfig = resolveDocsSitemapConfig(sitemap, { baseUrl: llms.baseUrl });
205
206
  const robotsEnabled = isRobotsDiscoveryEnabled(robots);
206
207
  const llmsSections = resolveDocsLlmsTxtSections(llms);
@@ -238,6 +239,7 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
238
239
  skills: true,
239
240
  mcp: mcp.enabled,
240
241
  search: searchEnabled,
242
+ contentChanges: contentChangesEnabled,
241
243
  sitemap: sitemapConfig.enabled,
242
244
  robots: robotsEnabled,
243
245
  structuredData: true,
@@ -260,6 +262,7 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
260
262
  agentSpecQuery: `${apiRoute}?agent=spec`,
261
263
  agents: `${apiRoute}?format=agents`,
262
264
  openapi: `${apiRoute}?format=openapi`,
265
+ ...contentChangesEnabled ? { contentChanges: `${apiRoute}?audience=agent&response=${DOCS_CONTENT_CHANGES_RESPONSE_VALUE}` } : {},
263
266
  ...apiCatalog ? {
264
267
  apiCatalog: DEFAULT_API_CATALOG_ROUTE,
265
268
  apiCatalogQuery: `${apiRoute}?format=api-catalog`
@@ -394,13 +397,16 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
394
397
  endpoint: `${apiRoute}?query={query}`,
395
398
  agentEndpoint: `${apiRoute}?query={query}&audience=agent`,
396
399
  structuredAgentEndpoint: `${apiRoute}?query={query}&audience=agent&response=structured`,
400
+ facetsEndpoint: `${apiRoute}?audience=agent&response=facets`,
397
401
  method: "GET",
398
402
  queryParam: "query",
399
403
  localeParam: "lang",
400
404
  audienceParam: "audience",
401
405
  responseParam: "response",
402
406
  structuredResponseValue: "structured",
407
+ facetsResponseValue: "facets",
403
408
  responseFormat: "docs-search.v1",
409
+ facetsResponseFormat: "docs-search-facets.v1",
404
410
  filterParams: {
405
411
  framework: "framework",
406
412
  version: "version",
@@ -414,6 +420,8 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
414
420
  "tags"
415
421
  ],
416
422
  warningsField: "warnings",
423
+ facetParam: "facet",
424
+ limitParam: "limit",
417
425
  cursorParam: "cursor",
418
426
  nextCursorField: "nextCursor",
419
427
  hasMoreField: "hasMore",
@@ -421,6 +429,27 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
421
429
  defaultAudience: "human",
422
430
  supportedAudiences: ["human", "agent"]
423
431
  },
432
+ contentChanges: {
433
+ enabled: contentChangesEnabled,
434
+ endpoint: contentChangesEnabled ? `${apiRoute}?audience=agent&response=${DOCS_CONTENT_CHANGES_RESPONSE_VALUE}` : null,
435
+ method: "GET",
436
+ audienceParam: "audience",
437
+ defaultAudience: "agent",
438
+ supportedAudiences: ["human", "agent"],
439
+ responseParam: "response",
440
+ responseValue: DOCS_CONTENT_CHANGES_RESPONSE_VALUE,
441
+ sinceParam: "since",
442
+ format: DOCS_CONTENT_CHANGES_FORMAT,
443
+ generationField: "indexGeneration",
444
+ resetRequiredField: "resetRequired",
445
+ modes: [
446
+ "snapshot",
447
+ "delta",
448
+ "reset"
449
+ ],
450
+ bodyFree: true,
451
+ etag: true
452
+ },
424
453
  agents: {
425
454
  enabled: true,
426
455
  file: "AGENTS.md",
@@ -1294,7 +1323,7 @@ function renderMarkdownDocument(page, options = {}) {
1294
1323
  sitemap: options.sitemap
1295
1324
  });
1296
1325
  }
1297
- function renderSkillDocument({ origin, entry, apiRoute, apiCatalog, search, mcp, feedback, llms, sitemap, robots, openapi }) {
1326
+ function renderSkillDocument({ origin, entry, apiRoute, apiCatalog, search, contentChanges, mcp, feedback, llms, sitemap, robots, openapi }) {
1298
1327
  const normalizedEntry = normalizePathSegment(entry) || "docs";
1299
1328
  const siteTitle = compactSkillText(llms.siteTitle ?? "Documentation");
1300
1329
  const siteDescription = llms.siteDescription ? compactSkillText(llms.siteDescription) : void 0;
@@ -1318,7 +1347,8 @@ function renderSkillDocument({ origin, entry, apiRoute, apiCatalog, search, mcp,
1318
1347
  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}.`);
1319
1348
  if (apiCatalog) lines.push(`- Fetch ${DEFAULT_API_CATALOG_ROUTE} for the standards-based API catalog.`);
1320
1349
  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.");
1321
- 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.`);
1350
+ if (searchEnabled) lines.push(`- Discover valid search filters with ${apiRoute}?audience=agent&response=facets before choosing framework, version, package, or tag values; continue a large field with facet={field}, limit={limit}, and its nextCursor.`, `- 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.`);
1351
+ if (resolveDocsContentChangesConfig(contentChanges).enabled) lines.push(`- Synchronize changed documents with ${apiRoute}?audience=agent&response=${DOCS_CONTENT_CHANGES_RESPONSE_VALUE}; pass indexGeneration as since on the next request and clear stale state when resetRequired is true.`);
1322
1352
  if (openapi.enabled && openapiUrl) lines.push(`- Fetch ${openapiUrl} for the machine-readable OpenAPI schema before scraping API reference pages.`);
1323
1353
  if (llms.enabled) {
1324
1354
  lines.push(`- Use ${DEFAULT_LLMS_TXT_ROUTE} for a compact docs index.`, `- Use ${DEFAULT_LLMS_FULL_TXT_ROUTE} for full markdown context.`);
@@ -1354,7 +1384,7 @@ function renderSkillDocument({ origin, entry, apiRoute, apiCatalog, search, mcp,
1354
1384
  lines.push("", "## Reusable Framework Skills", "For framework setup, CLI, page actions, Ask AI, or configuration work, install the reusable Farming Labs skills:", "", "```sh", "npx skills add farming-labs/docs", "```");
1355
1385
  return lines.join("\n");
1356
1386
  }
1357
- function renderAgentsDocument({ origin, entry, apiRoute, apiCatalog, search, mcp, feedback, llms, sitemap, robots, openapi }) {
1387
+ function renderAgentsDocument({ origin, entry, apiRoute, apiCatalog, search, contentChanges, mcp, feedback, llms, sitemap, robots, openapi }) {
1358
1388
  const normalizedEntry = normalizePathSegment(entry) || "docs";
1359
1389
  const siteTitle = compactSkillText(llms.siteTitle ?? "Documentation");
1360
1390
  const siteDescription = llms.siteDescription ? compactSkillText(llms.siteDescription) : void 0;
@@ -1383,7 +1413,8 @@ function renderAgentsDocument({ origin, entry, apiRoute, apiCatalog, search, mcp
1383
1413
  if (sitemapConfig.xml.enabled) lines.push(`- Use ${sitemapConfig.xml.route} for canonical URLs and freshness metadata.`);
1384
1414
  }
1385
1415
  if (robotsEnabled) lines.push(`- Check ${DEFAULT_ROBOTS_TXT_ROUTE} before crawling broadly.`);
1386
- 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.`);
1416
+ if (searchEnabled) lines.push(`- Discover valid search filters with ${apiRoute}?audience=agent&response=facets before choosing framework, version, package, or tag values; continue a large field with facet={field}, limit={limit}, and its nextCursor.`, `- 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.`);
1417
+ if (resolveDocsContentChangesConfig(contentChanges).enabled) lines.push(`- Synchronize changed documents with ${apiRoute}?audience=agent&response=${DOCS_CONTENT_CHANGES_RESPONSE_VALUE}; pass indexGeneration as since on the next request and clear stale state when resetRequired is true.`);
1387
1418
  if (openapi.enabled && openapiUrl) lines.push(`- Fetch ${openapiUrl} before scraping API reference pages; prefer schemas over prose.`);
1388
1419
  if (mcp.enabled) lines.push(`- Use MCP at ${DEFAULT_MCP_PUBLIC_ROUTE} or ${DEFAULT_MCP_WELL_KNOWN_ROUTE} when your environment supports MCP tools.`);
1389
1420
  if (feedback.enabled) lines.push(`- Read ${feedback.schemaRoute} before posting feedback to ${feedback.route}.`);
@@ -2527,6 +2558,8 @@ function createDocsAPI(options) {
2527
2558
  apiRoute: configuredApiRoute
2528
2559
  } : cloudConfig;
2529
2560
  const searchConfig = options?.search;
2561
+ const contentChangesConfig = resolveDocsContentChangesConfig(options?.agent?.contentChanges, { staticExport: options?.staticExport === true });
2562
+ const contentChangeFeed = createDocsContentChangeFeed(options?.agent?.contentChanges);
2530
2563
  const llmsConfig = resolveLlmsTxtConfig(options?.llmsTxt, readLlmsTxtConfig(root));
2531
2564
  const apiCatalogEnabled = options?.apiCatalog ?? llmsConfig.apiCatalog ?? true;
2532
2565
  const sitemapConfig = options?.sitemap ?? readSitemapConfig(root);
@@ -2559,6 +2592,7 @@ function createDocsAPI(options) {
2559
2592
  contentDir,
2560
2593
  telemetry: options?.telemetry,
2561
2594
  search: searchConfig,
2595
+ agent: options?.agent,
2562
2596
  ai: aiConfig,
2563
2597
  cloud: effectiveCloudConfig,
2564
2598
  i18n: i18nConfig ?? void 0,
@@ -2580,6 +2614,7 @@ function createDocsAPI(options) {
2580
2614
  setConfigMapFallback("entry", entry);
2581
2615
  setConfigMapFallback("ai", Object.keys(aiConfig).length > 0 ? aiConfig : void 0);
2582
2616
  setConfigMapFallback("search", searchConfig);
2617
+ setConfigMapFallback("agent", options?.agent);
2583
2618
  setConfigMapFallback("i18n", i18nConfig ?? void 0);
2584
2619
  setConfigMapFallback("mcp", rawMcpConfig);
2585
2620
  setConfigMapFallback("apiReference", apiReferenceConfig);
@@ -2777,6 +2812,7 @@ function createDocsAPI(options) {
2777
2812
  apiCatalog: apiCatalogEnabled,
2778
2813
  i18n,
2779
2814
  search: searchConfig,
2815
+ contentChanges: contentChangesConfig.enabled,
2780
2816
  mcp: mcpConfig,
2781
2817
  feedback: agentFeedbackConfig,
2782
2818
  llms: llmsConfig,
@@ -2797,6 +2833,7 @@ function createDocsAPI(options) {
2797
2833
  apiRoute,
2798
2834
  i18n,
2799
2835
  search: searchConfig,
2836
+ contentChanges: contentChangesConfig.enabled,
2800
2837
  mcp: mcpConfig,
2801
2838
  feedback: agentFeedbackConfig,
2802
2839
  llms: llmsConfig,
@@ -2862,6 +2899,7 @@ function createDocsAPI(options) {
2862
2899
  apiCatalog: apiCatalogEnabled,
2863
2900
  i18n,
2864
2901
  search: searchConfig,
2902
+ contentChanges: contentChangesConfig.enabled,
2865
2903
  mcp: mcpConfig,
2866
2904
  feedback: agentFeedbackConfig,
2867
2905
  llms: llmsConfig,
@@ -2877,6 +2915,7 @@ function createDocsAPI(options) {
2877
2915
  apiCatalog: apiCatalogEnabled,
2878
2916
  i18n,
2879
2917
  search: searchConfig,
2918
+ contentChanges: contentChangesConfig.enabled,
2880
2919
  mcp: mcpConfig,
2881
2920
  feedback: agentFeedbackConfig,
2882
2921
  llms: llmsConfig,
@@ -2892,6 +2931,23 @@ function createDocsAPI(options) {
2892
2931
  "X-Robots-Tag": "noindex"
2893
2932
  } });
2894
2933
  }
2934
+ if (isDocsContentChangesRequest(url)) {
2935
+ if (!contentChangesConfig.enabled) return new Response("Not Found", {
2936
+ status: 404,
2937
+ headers: {
2938
+ "Content-Type": "text/plain; charset=utf-8",
2939
+ "X-Robots-Tag": "noindex"
2940
+ }
2941
+ });
2942
+ return createDocsContentChangesHttpResponse({
2943
+ request,
2944
+ feed: contentChangeFeed,
2945
+ pages: getIndexes(ctx),
2946
+ search: searchConfig,
2947
+ locale: ctx.locale,
2948
+ baseUrl: markdownMetadataBaseUrl || url.origin
2949
+ });
2950
+ }
2895
2951
  if (isApiReferenceOpenApiRequest(url)) {
2896
2952
  if (!openapiDiscovery.enabled) return new Response("Not Found", {
2897
2953
  status: 404,
@@ -2957,6 +3013,7 @@ function createDocsAPI(options) {
2957
3013
  apiRoute: requestApiRoute,
2958
3014
  apiCatalog: apiCatalogEnabled,
2959
3015
  search: searchConfig,
3016
+ contentChanges: contentChangesConfig.enabled,
2960
3017
  mcp: mcpConfig,
2961
3018
  feedback: agentFeedbackConfig,
2962
3019
  llms: llmsConfig,
@@ -2989,6 +3046,7 @@ function createDocsAPI(options) {
2989
3046
  apiCatalog: apiCatalogEnabled,
2990
3047
  i18n,
2991
3048
  search: searchConfig,
3049
+ contentChanges: contentChangesConfig.enabled,
2992
3050
  mcp: mcpConfig,
2993
3051
  feedback: agentFeedbackConfig,
2994
3052
  llms: llmsConfig,
@@ -3169,8 +3227,8 @@ function createDocsAPI(options) {
3169
3227
  if (!searchError) throw error;
3170
3228
  return Response.json({ error: searchError }, { status: 400 });
3171
3229
  }
3172
- const { filters, structured, cursor, limit } = searchRequest;
3173
- if (!query && !structured) return new Response("[]", { headers: { "Content-Type": "application/json" } });
3230
+ const { filters, structured, facets, facet, cursor, limit } = searchRequest;
3231
+ if (!query && !structured && !facets) return new Response("[]", { headers: { "Content-Type": "application/json" } });
3174
3232
  const searchOptions = {
3175
3233
  pages: getIndexes(ctx),
3176
3234
  query: query ?? "",
@@ -3182,20 +3240,22 @@ function createDocsAPI(options) {
3182
3240
  siteTitle: llmsConfig.siteTitle ?? "Documentation",
3183
3241
  baseUrl: markdownMetadataBaseUrl || url.origin,
3184
3242
  syncBaseUrl: markdownMetadataBaseUrl ?? null,
3243
+ facet,
3185
3244
  cursor,
3186
3245
  limit
3187
3246
  };
3188
3247
  const searchStartedAt = Date.now();
3189
3248
  let searchResponse;
3190
3249
  try {
3191
- searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : query ? await performDocsSearch(searchOptions) : [];
3250
+ searchResponse = facets ? await buildDocsSearchFacets(searchOptions) : structured ? await performDocsSearchWithMetadata(searchOptions) : query ? await performDocsSearch(searchOptions) : [];
3192
3251
  } catch (error) {
3193
3252
  const searchError = resolveDocsSearchError(error);
3194
3253
  if (!searchError) throw error;
3195
3254
  return Response.json({ error: searchError }, { status: 400 });
3196
3255
  }
3256
+ if (facets) return Response.json(searchResponse, { headers: { "Cache-Control": "public, max-age=60, stale-while-revalidate=300" } });
3197
3257
  if (!query) return Response.json(searchResponse);
3198
- const resultCount = Array.isArray(searchResponse) ? searchResponse.length : searchResponse.resultCount;
3258
+ const resultCount = Array.isArray(searchResponse) ? searchResponse.length : "resultCount" in searchResponse ? searchResponse.resultCount : searchResponse.matchedPageCount;
3199
3259
  await emitDocsAnalyticsEvent(analytics, {
3200
3260
  type: "api_search",
3201
3261
  source: "server",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.2.77",
3
+ "version": "0.2.78",
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.77"
151
+ "@farming-labs/docs": "0.2.78"
152
152
  },
153
153
  "peerDependencies": {
154
154
  "@farming-labs/docs": ">=0.0.1",