@farming-labs/theme 0.1.90 → 0.1.93

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 CHANGED
@@ -935,10 +935,11 @@ function resolveMarkdownRequest(entry, url, request) {
935
935
  }
936
936
  return null;
937
937
  }
938
- function renderMarkdownDocument(page) {
938
+ function renderMarkdownDocument(page, options = {}) {
939
939
  if ("agentRawContent" in page && page.agentRawContent !== void 0) return page.agentRawContent;
940
940
  const relatedLines = renderDocsRelatedMarkdownLines(page.related);
941
941
  const lines = [`# ${page.title}`, `URL: ${page.url}`];
942
+ if (options.llmsEnabled !== false) lines.push("LLM index: /llms.txt");
942
943
  if (page.description) lines.push(`Description: ${page.description}`);
943
944
  lines.push(...relatedLines);
944
945
  lines.push("", page.agentFallbackRawContent ?? page.rawContent ?? page.content);
@@ -1735,11 +1736,11 @@ function createDocsAPI(options) {
1735
1736
  for (const docsDir of ctx.docsDirs) if (isHiddenFolderIndexPageDir(relativeSlug ? path.join(docsDir, ...relativeSlug.split("/")) : docsDir)) return null;
1736
1737
  for (const source of getMarkdownSources(ctx)) {
1737
1738
  const page = findDocsMcpPage(ctx.entryPath, await source.getPages(), requestedPath);
1738
- if (page) return renderMarkdownDocument(page);
1739
+ if (page) return renderMarkdownDocument(page, { llmsEnabled: llmsConfig.enabled });
1739
1740
  }
1740
1741
  const fallbackPage = getIndexes(ctx).find((page) => normalizeUrlPath(page.url) === normalizedRequest);
1741
- if (fallbackPage) return renderMarkdownDocument(fallbackPage);
1742
- for (const page of getIndexes(ctx)) if (normalizePathSegment(page.url.replace(/^\/+/, "").replace(`${ctx.entryPath}/`, "")) === normalizePathSegment(requestedPath.replace(/^\/+/, "").replace(/\.md$/i, ""))) return renderMarkdownDocument(page);
1742
+ if (fallbackPage) return renderMarkdownDocument(fallbackPage, { llmsEnabled: llmsConfig.enabled });
1743
+ for (const page of getIndexes(ctx)) if (normalizePathSegment(page.url.replace(/^\/+/, "").replace(`${ctx.entryPath}/`, "")) === normalizePathSegment(requestedPath.replace(/^\/+/, "").replace(/\.md$/i, ""))) return renderMarkdownDocument(page, { llmsEnabled: llmsConfig.enabled });
1743
1744
  return null;
1744
1745
  }
1745
1746
  function getLlmsContent(ctx) {
@@ -13,6 +13,17 @@ import { usePathname, useRouter } from "fumadocs-core/framework";
13
13
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
14
 
15
15
  //#region src/docs-page-client.tsx
16
+ const agentLlmsDirectiveStyle = {
17
+ position: "absolute",
18
+ width: 1,
19
+ height: 1,
20
+ padding: 0,
21
+ margin: -1,
22
+ overflow: "hidden",
23
+ clip: "rect(0, 0, 0, 0)",
24
+ whiteSpace: "nowrap",
25
+ border: 0
26
+ };
16
27
  /**
17
28
  * Path-based breadcrumb that shows only parent / current folder.
18
29
  * Skips the entry segment (e.g. "docs"). Parent is clickable.
@@ -343,97 +354,108 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
343
354
  belowTitle: belowTitleBlock
344
355
  }), titlePortalHost) : null;
345
356
  const renderedChildren = Children.toArray(decoratedChildren);
346
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [structuredDataJson && /* @__PURE__ */ jsx("script", {
347
- type: "application/ld+json",
348
- dangerouslySetInnerHTML: { __html: escapeJsonLdForScript(structuredDataJson) }
349
- }), /* @__PURE__ */ jsxs(DocsPage, {
350
- full: false,
351
- toc,
352
- tableOfContent: {
353
- enabled: effectiveTocEnabled,
354
- style: fdTocStyle
355
- },
356
- tableOfContentPopover: {
357
- enabled: effectiveTocEnabled,
358
- style: fdTocStyle
359
- },
360
- breadcrumb: { enabled: false },
361
- footer: { enabled: !isChangelogRoute },
362
- children: [
363
- effectiveBreadcrumbEnabled && /* @__PURE__ */ jsx(PathBreadcrumb, {
364
- pathname,
365
- entry,
366
- locale: activeLocale
367
- }),
368
- showActionsAboveTitle && /* @__PURE__ */ jsxs("div", {
369
- className: "fd-below-title-block not-prose",
370
- children: [/* @__PURE__ */ jsx("div", {
371
- className: "fd-actions-portal",
372
- "data-actions-alignment": pageActionsAlignment,
373
- children: /* @__PURE__ */ jsx(PageActions, {
374
- copyMarkdown,
375
- openDocs,
376
- providers: openDocsProviders,
377
- alignment: pageActionsAlignment,
378
- githubFileUrl,
379
- analytics
380
- })
381
- }), readingTimeBlock]
382
- }),
383
- !showReadingTimeAboveTitle && !showReadingTimeBelowTitle ? readingTimeBlock : null,
384
- /* @__PURE__ */ jsxs(DocsBody, {
385
- style: {
386
- display: "flex",
387
- flexDirection: "column"
388
- },
389
- children: [
390
- /* @__PURE__ */ jsx("div", {
391
- style: { flex: 1 },
392
- children: renderedChildren
393
- }),
394
- titleDecorationsPortal,
395
- !isChangelogRoute && feedbackEnabled && /* @__PURE__ */ jsx(DocsFeedback, {
396
- pathname: normalizedPath,
397
- entry,
398
- locale: activeLocale,
399
- question: feedbackQuestion,
400
- placeholder: feedbackPlaceholder,
401
- positiveLabel: feedbackPositiveLabel,
402
- negativeLabel: feedbackNegativeLabel,
403
- submitLabel: feedbackSubmitLabel,
404
- onFeedback: feedbackOnFeedback,
405
- analytics
406
- }),
407
- showFooter && /* @__PURE__ */ jsxs("div", {
408
- className: "not-prose fd-page-footer",
409
- children: [
410
- githubFileUrl && /* @__PURE__ */ jsx(EditOnGitHub, { href: githubFileUrl }),
411
- llmsTxtEnabled && /* @__PURE__ */ jsxs("span", {
412
- className: "fd-llms-txt-links",
413
- children: [/* @__PURE__ */ jsx("a", {
414
- href: `/llms.txt${llmsLangQuery}`,
415
- target: "_blank",
416
- rel: "noopener noreferrer",
417
- className: "fd-llms-txt-link",
418
- children: "llms.txt"
419
- }), /* @__PURE__ */ jsx("a", {
420
- href: `/llms-full.txt${llmsLangQuery}`,
421
- target: "_blank",
422
- rel: "noopener noreferrer",
423
- className: "fd-llms-txt-link",
424
- children: "llms-full.txt"
425
- })]
426
- }),
427
- showLastUpdatedInFooter && lastModified && /* @__PURE__ */ jsxs("span", {
428
- className: "fd-last-updated-footer",
429
- children: ["Last updated ", lastModified]
430
- })
431
- ]
432
- })
433
- ]
434
- })
435
- ]
436
- })] });
357
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
358
+ structuredDataJson && /* @__PURE__ */ jsx("script", {
359
+ type: "application/ld+json",
360
+ dangerouslySetInnerHTML: { __html: escapeJsonLdForScript(structuredDataJson) }
361
+ }),
362
+ llmsTxtEnabled && /* @__PURE__ */ jsx("a", {
363
+ href: `/llms.txt${llmsLangQuery}`,
364
+ className: "fd-agent-llms-directive",
365
+ style: agentLlmsDirectiveStyle,
366
+ tabIndex: -1,
367
+ "aria-hidden": "true",
368
+ children: "llms.txt"
369
+ }),
370
+ /* @__PURE__ */ jsxs(DocsPage, {
371
+ full: false,
372
+ toc,
373
+ tableOfContent: {
374
+ enabled: effectiveTocEnabled,
375
+ style: fdTocStyle
376
+ },
377
+ tableOfContentPopover: {
378
+ enabled: effectiveTocEnabled,
379
+ style: fdTocStyle
380
+ },
381
+ breadcrumb: { enabled: false },
382
+ footer: { enabled: !isChangelogRoute },
383
+ children: [
384
+ effectiveBreadcrumbEnabled && /* @__PURE__ */ jsx(PathBreadcrumb, {
385
+ pathname,
386
+ entry,
387
+ locale: activeLocale
388
+ }),
389
+ showActionsAboveTitle && /* @__PURE__ */ jsxs("div", {
390
+ className: "fd-below-title-block not-prose",
391
+ children: [/* @__PURE__ */ jsx("div", {
392
+ className: "fd-actions-portal",
393
+ "data-actions-alignment": pageActionsAlignment,
394
+ children: /* @__PURE__ */ jsx(PageActions, {
395
+ copyMarkdown,
396
+ openDocs,
397
+ providers: openDocsProviders,
398
+ alignment: pageActionsAlignment,
399
+ githubFileUrl,
400
+ analytics
401
+ })
402
+ }), readingTimeBlock]
403
+ }),
404
+ !showReadingTimeAboveTitle && !showReadingTimeBelowTitle ? readingTimeBlock : null,
405
+ /* @__PURE__ */ jsxs(DocsBody, {
406
+ style: {
407
+ display: "flex",
408
+ flexDirection: "column"
409
+ },
410
+ children: [
411
+ /* @__PURE__ */ jsx("div", {
412
+ style: { flex: 1 },
413
+ children: renderedChildren
414
+ }),
415
+ titleDecorationsPortal,
416
+ !isChangelogRoute && feedbackEnabled && /* @__PURE__ */ jsx(DocsFeedback, {
417
+ pathname: normalizedPath,
418
+ entry,
419
+ locale: activeLocale,
420
+ question: feedbackQuestion,
421
+ placeholder: feedbackPlaceholder,
422
+ positiveLabel: feedbackPositiveLabel,
423
+ negativeLabel: feedbackNegativeLabel,
424
+ submitLabel: feedbackSubmitLabel,
425
+ onFeedback: feedbackOnFeedback,
426
+ analytics
427
+ }),
428
+ showFooter && /* @__PURE__ */ jsxs("div", {
429
+ className: "not-prose fd-page-footer",
430
+ children: [
431
+ githubFileUrl && /* @__PURE__ */ jsx(EditOnGitHub, { href: githubFileUrl }),
432
+ llmsTxtEnabled && /* @__PURE__ */ jsxs("span", {
433
+ className: "fd-llms-txt-links",
434
+ children: [/* @__PURE__ */ jsx("a", {
435
+ href: `/llms.txt${llmsLangQuery}`,
436
+ target: "_blank",
437
+ rel: "noopener noreferrer",
438
+ className: "fd-llms-txt-link",
439
+ children: "llms.txt"
440
+ }), /* @__PURE__ */ jsx("a", {
441
+ href: `/llms-full.txt${llmsLangQuery}`,
442
+ target: "_blank",
443
+ rel: "noopener noreferrer",
444
+ className: "fd-llms-txt-link",
445
+ children: "llms-full.txt"
446
+ })]
447
+ }),
448
+ showLastUpdatedInFooter && lastModified && /* @__PURE__ */ jsxs("span", {
449
+ className: "fd-last-updated-footer",
450
+ children: ["Last updated ", lastModified]
451
+ })
452
+ ]
453
+ })
454
+ ]
455
+ })
456
+ ]
457
+ })
458
+ ] });
437
459
  }
438
460
 
439
461
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.1.90",
3
+ "version": "0.1.93",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -139,7 +139,7 @@
139
139
  "tsdown": "^0.20.3",
140
140
  "typescript": "^5.9.3",
141
141
  "vitest": "^3.2.4",
142
- "@farming-labs/docs": "0.1.90"
142
+ "@farming-labs/docs": "0.1.93"
143
143
  },
144
144
  "peerDependencies": {
145
145
  "@farming-labs/docs": ">=0.0.1",