@farming-labs/theme 0.2.119 → 0.2.121
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 +6 -0
- package/dist/deferred-dialog.mjs +72 -0
- package/dist/docs-ai-features-lazy.mjs +13 -0
- package/dist/docs-ai-features.mjs +75 -57
- package/dist/docs-api.mjs +1 -1
- package/dist/docs-cloud-ai-client.mjs +2 -1
- package/dist/docs-content-reader.mjs +65 -0
- package/dist/docs-layout.mjs +105 -346
- package/dist/docs-page-client.d.mts +4 -0
- package/dist/docs-page-client.mjs +12 -3
- package/dist/page-structured-data.d.mts +13 -0
- package/dist/page-structured-data.mjs +30 -0
- package/dist/reading-time-options.mjs +1 -1
- package/dist/tanstack-layout.mjs +3 -3
- package/package.json +2 -2
- package/styles/framework.css +1 -0
package/README.md
CHANGED
|
@@ -69,6 +69,12 @@ Available preset subpaths include `default`, `darksharp`, `pixel-border`, `color
|
|
|
69
69
|
|
|
70
70
|
## Main entrypoints
|
|
71
71
|
|
|
72
|
+
`createDocsLayout()` prepares navigation and page metadata together, reading each page once per
|
|
73
|
+
preparation pass. In production, the layout reuses that data across page renders within the same
|
|
74
|
+
layout instance, including static generation during `next build`. Content changes are picked up
|
|
75
|
+
by a new build/process; development renders refresh the data to reflect edits, new pages, and
|
|
76
|
+
deleted pages. No additional configuration is required.
|
|
77
|
+
|
|
72
78
|
| Entrypoint | Purpose |
|
|
73
79
|
| --- | --- |
|
|
74
80
|
| `@farming-labs/theme` | Default theme, `RootProvider`, layout helpers, and React UI |
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Suspense, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/deferred-dialog.tsx
|
|
8
|
+
/** Mount on first use, then retain dialog state across closes. */
|
|
9
|
+
function DeferredDialog({ open, onOpenChange, children }) {
|
|
10
|
+
const [hasOpened, setHasOpened] = useState(open);
|
|
11
|
+
if (open && !hasOpened) setHasOpened(true);
|
|
12
|
+
if (!open && !hasOpened) return null;
|
|
13
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
14
|
+
fallback: open ? /* @__PURE__ */ jsx(LoadingDialog, { onOpenChange }) : null,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function LoadingDialog({ onOpenChange }) {
|
|
19
|
+
const closeButton = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const previousFocus = document.activeElement;
|
|
22
|
+
const previousOverflow = document.body.style.overflow;
|
|
23
|
+
document.body.style.overflow = "hidden";
|
|
24
|
+
closeButton.current?.focus();
|
|
25
|
+
const onKeyDown = (event) => {
|
|
26
|
+
if (event.key === "Escape") onOpenChange(false);
|
|
27
|
+
if (event.key === "Tab") {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
closeButton.current?.focus();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener("keydown", onKeyDown);
|
|
33
|
+
return () => {
|
|
34
|
+
document.body.style.overflow = previousOverflow;
|
|
35
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
36
|
+
if (previousFocus instanceof HTMLElement) previousFocus.focus();
|
|
37
|
+
};
|
|
38
|
+
}, [onOpenChange]);
|
|
39
|
+
return createPortal(/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
40
|
+
className: "fd-ai-overlay",
|
|
41
|
+
onClick: () => onOpenChange(false)
|
|
42
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
43
|
+
role: "dialog",
|
|
44
|
+
"aria-modal": "true",
|
|
45
|
+
"aria-label": "Loading dialog",
|
|
46
|
+
"aria-busy": "true",
|
|
47
|
+
className: "fd-ai-dialog",
|
|
48
|
+
style: {
|
|
49
|
+
left: "50%",
|
|
50
|
+
top: "50%",
|
|
51
|
+
transform: "translate(-50%, -50%)",
|
|
52
|
+
width: "min(680px, calc(100vw - 32px))"
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: "fd-ai-header",
|
|
56
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
57
|
+
role: "status",
|
|
58
|
+
className: "fd-ai-header-title",
|
|
59
|
+
children: "Loading…"
|
|
60
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
61
|
+
ref: closeButton,
|
|
62
|
+
className: "fd-ai-close-btn",
|
|
63
|
+
onClick: () => onOpenChange(false),
|
|
64
|
+
"aria-label": "Close dialog",
|
|
65
|
+
children: "×"
|
|
66
|
+
})]
|
|
67
|
+
})
|
|
68
|
+
})] }), document.body);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { DeferredDialog };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { lazy } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/docs-ai-features-lazy.tsx
|
|
7
|
+
const LazyDocsAIFeatures = lazy(() => import("./docs-ai-features.mjs").then((module) => ({ default: module.DocsAIFeatures })));
|
|
8
|
+
function DocsAIFeatures(props) {
|
|
9
|
+
return /* @__PURE__ */ jsx(LazyDocsAIFeatures, { ...props });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DocsAIFeatures };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { emitClientAnalyticsEvent } from "./client-analytics.mjs";
|
|
4
4
|
import { useWindowSearchParams } from "./client-location.mjs";
|
|
5
5
|
import { resolveClientLocale, withLangInUrl } from "./i18n.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
6
|
+
import { DeferredDialog } from "./deferred-dialog.mjs";
|
|
7
|
+
import { Suspense, lazy, useEffect, useState } from "react";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/docs-ai-features.tsx
|
|
@@ -22,6 +22,9 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
22
22
|
* This component is rendered inside the docs layout so the user's root layout
|
|
23
23
|
* never needs to be modified — AI features work purely from `docs.config.ts`.
|
|
24
24
|
*/
|
|
25
|
+
const DocsSearchDialog = lazy(() => import("./ai-search-dialog.mjs").then((module) => ({ default: module.DocsSearchDialog })));
|
|
26
|
+
const AIModalDialog = lazy(() => import("./ai-search-dialog.mjs").then((module) => ({ default: module.AIModalDialog })));
|
|
27
|
+
const FloatingAIChat = lazy(() => import("./ai-search-dialog.mjs").then((module) => ({ default: module.FloatingAIChat })));
|
|
25
28
|
function DocsAIFeatures({ mode, api = "/api/docs", requestMode, requestHeaders, requestStream, locale, position = "bottom-right", floatingStyle = "panel", triggerComponentHtml, suggestedQuestions, aiLabel, loaderVariant, loadingComponentHtml, models, defaultModelId, analytics = false, feedbackEnabled = true }) {
|
|
26
29
|
const localizedApi = withLangInUrl(api, resolveClientLocale(useWindowSearchParams(), locale));
|
|
27
30
|
if (mode === "search") return /* @__PURE__ */ jsx(SearchModeAI, {
|
|
@@ -52,22 +55,25 @@ function DocsAIFeatures({ mode, api = "/api/docs", requestMode, requestHeaders,
|
|
|
52
55
|
analytics,
|
|
53
56
|
feedbackEnabled
|
|
54
57
|
});
|
|
55
|
-
return /* @__PURE__ */ jsx(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
59
|
+
fallback: null,
|
|
60
|
+
children: /* @__PURE__ */ jsx(FloatingAIChat, {
|
|
61
|
+
api: localizedApi,
|
|
62
|
+
requestMode,
|
|
63
|
+
requestHeaders,
|
|
64
|
+
requestStream,
|
|
65
|
+
position,
|
|
66
|
+
floatingStyle,
|
|
67
|
+
triggerComponentHtml,
|
|
68
|
+
suggestedQuestions,
|
|
69
|
+
aiLabel,
|
|
70
|
+
loaderVariant,
|
|
71
|
+
loadingComponentHtml,
|
|
72
|
+
models,
|
|
73
|
+
defaultModelId,
|
|
74
|
+
analytics,
|
|
75
|
+
feedbackEnabled
|
|
76
|
+
})
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
79
|
function SearchModeAI({ api, requestMode, requestHeaders, requestStream, suggestedQuestions, aiLabel, loaderVariant, loadingComponentHtml, models, defaultModelId, analytics, feedbackEnabled }) {
|
|
@@ -113,21 +119,25 @@ function SearchModeAI({ api, requestMode, requestHeaders, requestStream, suggest
|
|
|
113
119
|
document.addEventListener("click", handler, true);
|
|
114
120
|
return () => document.removeEventListener("click", handler, true);
|
|
115
121
|
}, [analytics]);
|
|
116
|
-
return /* @__PURE__ */ jsx(
|
|
122
|
+
return /* @__PURE__ */ jsx(DeferredDialog, {
|
|
117
123
|
open,
|
|
118
124
|
onOpenChange: setOpen,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
children: /* @__PURE__ */ jsx(DocsSearchDialog, {
|
|
126
|
+
open,
|
|
127
|
+
onOpenChange: setOpen,
|
|
128
|
+
api,
|
|
129
|
+
requestMode,
|
|
130
|
+
requestHeaders,
|
|
131
|
+
requestStream,
|
|
132
|
+
suggestedQuestions,
|
|
133
|
+
aiLabel,
|
|
134
|
+
loaderVariant,
|
|
135
|
+
loadingComponentHtml,
|
|
136
|
+
models,
|
|
137
|
+
defaultModelId,
|
|
138
|
+
analytics,
|
|
139
|
+
feedbackEnabled
|
|
140
|
+
})
|
|
131
141
|
});
|
|
132
142
|
}
|
|
133
143
|
function SidebarIconModeAI({ api, requestMode, requestHeaders, requestStream, suggestedQuestions, aiLabel, loaderVariant, loadingComponentHtml, models, defaultModelId, analytics, feedbackEnabled }) {
|
|
@@ -173,36 +183,44 @@ function SidebarIconModeAI({ api, requestMode, requestHeaders, requestStream, su
|
|
|
173
183
|
window.removeEventListener("fd-open-ai", onAI);
|
|
174
184
|
};
|
|
175
185
|
}, [analytics]);
|
|
176
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(
|
|
186
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(DeferredDialog, {
|
|
177
187
|
open: searchOpen,
|
|
178
188
|
onOpenChange: setSearchOpen,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
children: /* @__PURE__ */ jsx(DocsSearchDialog, {
|
|
190
|
+
open: searchOpen,
|
|
191
|
+
onOpenChange: setSearchOpen,
|
|
192
|
+
api,
|
|
193
|
+
requestMode,
|
|
194
|
+
requestHeaders,
|
|
195
|
+
requestStream,
|
|
196
|
+
suggestedQuestions,
|
|
197
|
+
aiLabel,
|
|
198
|
+
loaderVariant,
|
|
199
|
+
loadingComponentHtml,
|
|
200
|
+
models,
|
|
201
|
+
defaultModelId,
|
|
202
|
+
analytics,
|
|
203
|
+
feedbackEnabled
|
|
204
|
+
})
|
|
205
|
+
}), /* @__PURE__ */ jsx(DeferredDialog, {
|
|
192
206
|
open: aiOpen,
|
|
193
207
|
onOpenChange: setAiOpen,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
children: /* @__PURE__ */ jsx(AIModalDialog, {
|
|
209
|
+
open: aiOpen,
|
|
210
|
+
onOpenChange: setAiOpen,
|
|
211
|
+
api,
|
|
212
|
+
requestMode,
|
|
213
|
+
requestHeaders,
|
|
214
|
+
requestStream,
|
|
215
|
+
suggestedQuestions,
|
|
216
|
+
aiLabel,
|
|
217
|
+
loaderVariant,
|
|
218
|
+
loadingComponentHtml,
|
|
219
|
+
models,
|
|
220
|
+
defaultModelId,
|
|
221
|
+
analytics,
|
|
222
|
+
feedbackEnabled
|
|
223
|
+
})
|
|
206
224
|
})] });
|
|
207
225
|
}
|
|
208
226
|
|
package/dist/docs-api.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { getNextAppDir } from "./get-app-dir.mjs";
|
|
|
3
3
|
import { BoundedRouteCache } from "./bounded-route-cache.mjs";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import matter from "gray-matter";
|
|
7
6
|
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, compactDocsAgentDiscoverySpec, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCacheableResponse, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsContentChangesRequest, isDocsDiagnosticsRequest, normalizeDocsOkfTrustMetadataInput, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, readDocsJsonBody, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsContentChangesConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance, withDocsOpenApiOperationCounts } from "@farming-labs/docs";
|
|
8
7
|
import { buildApiReferenceOpenApiDocumentAsync, buildApiReferenceOperationPagesAsync, createApiReferenceOperationMarkdownResponse, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/runtime";
|
|
8
|
+
import matter from "gray-matter";
|
|
9
9
|
|
|
10
10
|
//#region src/docs-api.ts
|
|
11
11
|
/**
|
|
@@ -6,7 +6,8 @@ const FALLBACK_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV = "NEXT_PUBLIC_DOCS_CLOUD_PROJEC
|
|
|
6
6
|
const DEFAULT_PUBLIC_DOCS_CLOUD_API_KEY_ENV = "PUBLIC_DOCS_CLOUD_API_KEY";
|
|
7
7
|
const FALLBACK_PUBLIC_DOCS_CLOUD_API_KEY_ENV = "NEXT_PUBLIC_DOCS_CLOUD_API_KEY";
|
|
8
8
|
function readRuntimeEnv(name) {
|
|
9
|
-
|
|
9
|
+
if (typeof process === "undefined") return void 0;
|
|
10
|
+
const value = process.env?.[name]?.trim();
|
|
10
11
|
return value ? value : void 0;
|
|
11
12
|
}
|
|
12
13
|
function resolveDocsCloudApiBaseUrl() {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import matter from "gray-matter";
|
|
4
|
+
|
|
5
|
+
//#region src/docs-content-reader.ts
|
|
6
|
+
/**
|
|
7
|
+
* Share filesystem reads between navigation and page metadata preparation.
|
|
8
|
+
* Keep the reader local to one preparation pass: development must see edits,
|
|
9
|
+
* and production only needs to retain the resulting tree and metadata maps.
|
|
10
|
+
*/
|
|
11
|
+
function createDocsContentReader() {
|
|
12
|
+
const directories = /* @__PURE__ */ new Map();
|
|
13
|
+
const pages = /* @__PURE__ */ new Map();
|
|
14
|
+
return {
|
|
15
|
+
directory(dir) {
|
|
16
|
+
const cached = directories.get(dir);
|
|
17
|
+
if (cached) return cached;
|
|
18
|
+
const result = {
|
|
19
|
+
directories: [],
|
|
20
|
+
files: /* @__PURE__ */ new Set()
|
|
21
|
+
};
|
|
22
|
+
if (fs.existsSync(
|
|
23
|
+
/* turbopackIgnore: true */
|
|
24
|
+
dir
|
|
25
|
+
)) for (const entry of fs.readdirSync(
|
|
26
|
+
/* turbopackIgnore: true */
|
|
27
|
+
dir,
|
|
28
|
+
{ withFileTypes: true }
|
|
29
|
+
)) if (entry.isSymbolicLink() ? fs.statSync(
|
|
30
|
+
/* turbopackIgnore: true */
|
|
31
|
+
path.join(
|
|
32
|
+
/* turbopackIgnore: true */
|
|
33
|
+
dir,
|
|
34
|
+
entry.name
|
|
35
|
+
)
|
|
36
|
+
).isDirectory() : entry.isDirectory()) result.directories.push(entry.name);
|
|
37
|
+
else result.files.add(entry.name);
|
|
38
|
+
result.directories.sort();
|
|
39
|
+
directories.set(dir, result);
|
|
40
|
+
return result;
|
|
41
|
+
},
|
|
42
|
+
page(filePath) {
|
|
43
|
+
const cached = pages.get(filePath);
|
|
44
|
+
if (cached) return cached;
|
|
45
|
+
const { data, content } = matter(fs.readFileSync(
|
|
46
|
+
/* turbopackIgnore: true */
|
|
47
|
+
filePath,
|
|
48
|
+
"utf8"
|
|
49
|
+
));
|
|
50
|
+
const page = {
|
|
51
|
+
data,
|
|
52
|
+
content,
|
|
53
|
+
modifiedAt: fs.statSync(
|
|
54
|
+
/* turbopackIgnore: true */
|
|
55
|
+
filePath
|
|
56
|
+
).mtime
|
|
57
|
+
};
|
|
58
|
+
pages.set(filePath, page);
|
|
59
|
+
return page;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { createDocsContentReader };
|
package/dist/docs-layout.mjs
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { serializeIcon } from "./serialize-icon.mjs";
|
|
2
2
|
import { resolveOpenDocsProviders } from "./open-docs-providers.mjs";
|
|
3
3
|
import { withLangInUrl } from "./i18n.mjs";
|
|
4
|
+
import { compactPageStructuredData } from "./page-structured-data.mjs";
|
|
4
5
|
import { DocsPageClient } from "./docs-page-client.mjs";
|
|
5
|
-
import { DocsAIFeatures } from "./docs-ai-features.mjs";
|
|
6
|
+
import { DocsAIFeatures } from "./docs-ai-features-lazy.mjs";
|
|
6
7
|
import { resolveDocsCloudAIClientRequest } from "./docs-cloud-ai-client.mjs";
|
|
7
8
|
import { DocsCommandSearch } from "./docs-command-search.mjs";
|
|
8
9
|
import { resolveReadingTimeOptions } from "./reading-time-options.mjs";
|
|
9
10
|
import { resolvePageReadingTime } from "./reading-time.mjs";
|
|
10
11
|
import { SidebarSearchWithAI } from "./sidebar-search-ai.mjs";
|
|
11
12
|
import { LocaleThemeControl } from "./locale-theme-control.mjs";
|
|
13
|
+
import { createDocsContentReader } from "./docs-content-reader.mjs";
|
|
12
14
|
import fs from "node:fs";
|
|
13
15
|
import path from "node:path";
|
|
14
|
-
import matter from "gray-matter";
|
|
15
16
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
16
17
|
import { Suspense, cloneElement, isValidElement } from "react";
|
|
17
|
-
import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, normalizePageAgentFrontmatter,
|
|
18
|
+
import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, normalizePageAgentFrontmatter, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolveDocsSitemapPageLastmod, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
|
|
18
19
|
import { readDocsSitemapManifest } from "@farming-labs/docs/runtime";
|
|
19
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
21
|
|
|
@@ -40,20 +41,14 @@ function resolveIcon(iconKey, registry) {
|
|
|
40
41
|
return withStableReactKey(registry[iconKey] ?? void 0, iconKey);
|
|
41
42
|
}
|
|
42
43
|
/** Read frontmatter from a page.mdx file. */
|
|
43
|
-
function readFrontmatter(filePath) {
|
|
44
|
+
function readFrontmatter(reader, filePath) {
|
|
44
45
|
try {
|
|
45
|
-
|
|
46
|
-
/* turbopackIgnore: true */
|
|
47
|
-
filePath,
|
|
48
|
-
"utf-8"
|
|
49
|
-
));
|
|
50
|
-
return data;
|
|
46
|
+
return reader.page(filePath).data;
|
|
51
47
|
} catch {
|
|
52
48
|
return {};
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
|
-
function hasAuthoredPageTitle(
|
|
56
|
-
const { content } = matter(source);
|
|
51
|
+
function hasAuthoredPageTitle(content) {
|
|
57
52
|
const lines = content.split(/\r?\n/);
|
|
58
53
|
let fence;
|
|
59
54
|
let previousTextLine = "";
|
|
@@ -88,32 +83,15 @@ function isExcludedDir(dir, excludedDirs) {
|
|
|
88
83
|
);
|
|
89
84
|
return excludedDirs.some((excluded) => isWithinDir(resolved, excluded));
|
|
90
85
|
}
|
|
91
|
-
function hasChildPages(dir, excludedDirs) {
|
|
92
|
-
|
|
93
|
-
/* turbopackIgnore: true */
|
|
94
|
-
dir
|
|
95
|
-
)) return false;
|
|
96
|
-
for (const name of fs.readdirSync(
|
|
97
|
-
/* turbopackIgnore: true */
|
|
98
|
-
dir
|
|
99
|
-
)) {
|
|
86
|
+
function hasChildPages(reader, dir, excludedDirs) {
|
|
87
|
+
for (const name of reader.directory(dir).directories) {
|
|
100
88
|
const full = path.join(
|
|
101
89
|
/* turbopackIgnore: true */
|
|
102
90
|
dir,
|
|
103
91
|
name
|
|
104
92
|
);
|
|
105
93
|
if (isExcludedDir(full, excludedDirs)) continue;
|
|
106
|
-
if (
|
|
107
|
-
/* turbopackIgnore: true */
|
|
108
|
-
full
|
|
109
|
-
).isDirectory() && fs.existsSync(
|
|
110
|
-
/* turbopackIgnore: true */
|
|
111
|
-
path.join(
|
|
112
|
-
/* turbopackIgnore: true */
|
|
113
|
-
full,
|
|
114
|
-
"page.mdx"
|
|
115
|
-
)
|
|
116
|
-
)) return true;
|
|
94
|
+
if (reader.directory(full).files.has("page.mdx")) return true;
|
|
117
95
|
}
|
|
118
96
|
return false;
|
|
119
97
|
}
|
|
@@ -201,7 +179,7 @@ function getExcludedDocsDirs(config, ctx) {
|
|
|
201
179
|
dir
|
|
202
180
|
)];
|
|
203
181
|
}
|
|
204
|
-
function readChangelogTreeEntries(config, ctx) {
|
|
182
|
+
function readChangelogTreeEntries(config, ctx, reader) {
|
|
205
183
|
const changelog = resolveChangelogConfig(config.changelog);
|
|
206
184
|
if (!changelog.enabled) return [];
|
|
207
185
|
const changelogDir = path.isAbsolute(changelog.contentDir) ? changelog.contentDir : path.join(
|
|
@@ -209,38 +187,21 @@ function readChangelogTreeEntries(config, ctx) {
|
|
|
209
187
|
ctx.docsDir,
|
|
210
188
|
changelog.contentDir
|
|
211
189
|
);
|
|
212
|
-
if (!fs.existsSync(
|
|
213
|
-
/* turbopackIgnore: true */
|
|
214
|
-
changelogDir
|
|
215
|
-
)) return [];
|
|
216
190
|
const entries = [];
|
|
217
|
-
for (const name of
|
|
218
|
-
/* turbopackIgnore: true */
|
|
219
|
-
changelogDir
|
|
220
|
-
)) {
|
|
191
|
+
for (const name of reader.directory(changelogDir).directories) {
|
|
221
192
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(name)) continue;
|
|
222
193
|
const entryDir = path.join(
|
|
223
194
|
/* turbopackIgnore: true */
|
|
224
195
|
changelogDir,
|
|
225
196
|
name
|
|
226
197
|
);
|
|
227
|
-
if (!fs.existsSync(
|
|
228
|
-
/* turbopackIgnore: true */
|
|
229
|
-
entryDir
|
|
230
|
-
) || !fs.statSync(
|
|
231
|
-
/* turbopackIgnore: true */
|
|
232
|
-
entryDir
|
|
233
|
-
).isDirectory()) continue;
|
|
234
198
|
const pagePath = path.join(
|
|
235
199
|
/* turbopackIgnore: true */
|
|
236
200
|
entryDir,
|
|
237
201
|
"page.mdx"
|
|
238
202
|
);
|
|
239
|
-
if (!
|
|
240
|
-
|
|
241
|
-
pagePath
|
|
242
|
-
)) continue;
|
|
243
|
-
const data = readFrontmatter(pagePath);
|
|
203
|
+
if (!reader.directory(entryDir).files.has("page.mdx")) continue;
|
|
204
|
+
const data = readFrontmatter(reader, pagePath);
|
|
244
205
|
if (data.draft === true) continue;
|
|
245
206
|
entries.push({
|
|
246
207
|
slug: name,
|
|
@@ -254,10 +215,10 @@ function readChangelogTreeEntries(config, ctx) {
|
|
|
254
215
|
return right.date.localeCompare(left.date);
|
|
255
216
|
});
|
|
256
217
|
}
|
|
257
|
-
function buildChangelogTree(config, ctx, flat = false) {
|
|
218
|
+
function buildChangelogTree(config, ctx, reader, flat = false) {
|
|
258
219
|
const changelog = resolveChangelogConfig(config.changelog);
|
|
259
220
|
if (!changelog.enabled) return null;
|
|
260
|
-
const entries = readChangelogTreeEntries(config, ctx);
|
|
221
|
+
const entries = readChangelogTreeEntries(config, ctx, reader);
|
|
261
222
|
if (entries.length === 0) return null;
|
|
262
223
|
const url = publicDocsRoute(ctx, [changelog.path]);
|
|
263
224
|
const children = entries.map((entry) => ({
|
|
@@ -280,21 +241,14 @@ function buildChangelogTree(config, ctx, flat = false) {
|
|
|
280
241
|
} : {}
|
|
281
242
|
};
|
|
282
243
|
}
|
|
283
|
-
function buildTree(config, ctx, flat = false) {
|
|
244
|
+
function buildTree(config, ctx, reader, flat = false) {
|
|
284
245
|
const docsDir = ctx.docsDir;
|
|
285
246
|
const icons = config.icons;
|
|
286
247
|
const ordering = config.ordering;
|
|
287
248
|
const rootChildren = [];
|
|
288
249
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
path.join(
|
|
292
|
-
/* turbopackIgnore: true */
|
|
293
|
-
docsDir,
|
|
294
|
-
"page.mdx"
|
|
295
|
-
)
|
|
296
|
-
)) {
|
|
297
|
-
const data = readFrontmatter(path.join(
|
|
250
|
+
if (reader.directory(docsDir).files.has("page.mdx")) {
|
|
251
|
+
const data = readFrontmatter(reader, path.join(
|
|
298
252
|
/* turbopackIgnore: true */
|
|
299
253
|
docsDir,
|
|
300
254
|
"page.mdx"
|
|
@@ -313,26 +267,19 @@ function buildTree(config, ctx, flat = false) {
|
|
|
313
267
|
name
|
|
314
268
|
);
|
|
315
269
|
if (isExcludedDir(full, excludedDirs)) return null;
|
|
316
|
-
if (!fs.statSync(
|
|
317
|
-
/* turbopackIgnore: true */
|
|
318
|
-
full
|
|
319
|
-
).isDirectory()) return null;
|
|
320
270
|
const pagePath = path.join(
|
|
321
271
|
/* turbopackIgnore: true */
|
|
322
272
|
full,
|
|
323
273
|
"page.mdx"
|
|
324
274
|
);
|
|
325
|
-
if (!
|
|
326
|
-
|
|
327
|
-
pagePath
|
|
328
|
-
)) return null;
|
|
329
|
-
const data = readFrontmatter(pagePath);
|
|
275
|
+
if (!reader.directory(full).files.has("page.mdx")) return null;
|
|
276
|
+
const data = readFrontmatter(reader, pagePath);
|
|
330
277
|
const slug = [...baseSlug, name];
|
|
331
278
|
const url = publicDocsRoute(ctx, slug);
|
|
332
279
|
const icon = resolveIcon(data.icon, icons);
|
|
333
280
|
const displayName = data.title ?? name.replace(/-/g, " ");
|
|
334
281
|
const folderName = resolveSidebarFolderName(config.theme?.name, name, displayName);
|
|
335
|
-
const hasChildren = hasChildPages(full, excludedDirs);
|
|
282
|
+
const hasChildren = hasChildPages(reader, full, excludedDirs);
|
|
336
283
|
if (data.hidden === true) {
|
|
337
284
|
if (!hasChildren) return null;
|
|
338
285
|
return {
|
|
@@ -374,14 +321,7 @@ function buildTree(config, ctx, flat = false) {
|
|
|
374
321
|
};
|
|
375
322
|
}
|
|
376
323
|
function scanDir(dir, baseSlug, slugOrder) {
|
|
377
|
-
|
|
378
|
-
/* turbopackIgnore: true */
|
|
379
|
-
dir
|
|
380
|
-
)) return [];
|
|
381
|
-
const entries = fs.readdirSync(
|
|
382
|
-
/* turbopackIgnore: true */
|
|
383
|
-
dir
|
|
384
|
-
).sort();
|
|
324
|
+
const entries = reader.directory(dir).directories;
|
|
385
325
|
if (slugOrder) {
|
|
386
326
|
const nodes = [];
|
|
387
327
|
const slugMap = /* @__PURE__ */ new Map();
|
|
@@ -417,20 +357,13 @@ function buildTree(config, ctx, flat = false) {
|
|
|
417
357
|
name
|
|
418
358
|
);
|
|
419
359
|
if (isExcludedDir(full, excludedDirs)) continue;
|
|
420
|
-
if (!fs.statSync(
|
|
421
|
-
/* turbopackIgnore: true */
|
|
422
|
-
full
|
|
423
|
-
).isDirectory()) continue;
|
|
424
360
|
const pagePath = path.join(
|
|
425
361
|
/* turbopackIgnore: true */
|
|
426
362
|
full,
|
|
427
363
|
"page.mdx"
|
|
428
364
|
);
|
|
429
|
-
if (!
|
|
430
|
-
|
|
431
|
-
pagePath
|
|
432
|
-
)) continue;
|
|
433
|
-
const data = readFrontmatter(pagePath);
|
|
365
|
+
if (!reader.directory(full).files.has("page.mdx")) continue;
|
|
366
|
+
const data = readFrontmatter(reader, pagePath);
|
|
434
367
|
const order = typeof data.order === "number" ? data.order : Infinity;
|
|
435
368
|
const node = buildNode(dir, name, baseSlug);
|
|
436
369
|
if (node) nodes.push({
|
|
@@ -458,7 +391,7 @@ function buildTree(config, ctx, flat = false) {
|
|
|
458
391
|
}
|
|
459
392
|
const rootSlugOrder = Array.isArray(ordering) ? ordering : void 0;
|
|
460
393
|
rootChildren.push(...scanDir(docsDir, [], rootSlugOrder));
|
|
461
|
-
const changelogTree = buildChangelogTree(config, ctx, flat);
|
|
394
|
+
const changelogTree = buildChangelogTree(config, ctx, reader, flat);
|
|
462
395
|
if (changelogTree) {
|
|
463
396
|
if (rootChildren.length > 0) rootChildren.push({
|
|
464
397
|
type: "separator",
|
|
@@ -492,264 +425,84 @@ function localizeTreeUrls(tree, locale) {
|
|
|
492
425
|
children: tree.children.map(mapNode)
|
|
493
426
|
};
|
|
494
427
|
}
|
|
495
|
-
/**
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const map = {};
|
|
505
|
-
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
506
|
-
function formatDate(date) {
|
|
507
|
-
return date.toLocaleDateString("en-US", {
|
|
508
|
-
year: "numeric",
|
|
509
|
-
month: "long",
|
|
510
|
-
day: "numeric"
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
function scan(dir, slugParts) {
|
|
514
|
-
if (!fs.existsSync(
|
|
515
|
-
/* turbopackIgnore: true */
|
|
516
|
-
dir
|
|
517
|
-
)) return;
|
|
518
|
-
if (isExcludedDir(dir, excludedDirs)) return;
|
|
519
|
-
const pagePath = path.join(
|
|
520
|
-
/* turbopackIgnore: true */
|
|
521
|
-
dir,
|
|
522
|
-
"page.mdx"
|
|
523
|
-
);
|
|
524
|
-
if (fs.existsSync(
|
|
525
|
-
/* turbopackIgnore: true */
|
|
526
|
-
pagePath
|
|
527
|
-
)) {
|
|
528
|
-
const url = publicDocsRoute(ctx, slugParts);
|
|
529
|
-
const manifestLastmod = resolveManifestLastmod(manifest, ctx, url);
|
|
530
|
-
map[url] = formatDate(manifestLastmod ? /* @__PURE__ */ new Date(`${manifestLastmod}T00:00:00`) : fs.statSync(
|
|
531
|
-
/* turbopackIgnore: true */
|
|
532
|
-
pagePath
|
|
533
|
-
).mtime);
|
|
534
|
-
}
|
|
535
|
-
for (const name of fs.readdirSync(
|
|
536
|
-
/* turbopackIgnore: true */
|
|
537
|
-
dir
|
|
538
|
-
)) {
|
|
539
|
-
const full = path.join(
|
|
540
|
-
/* turbopackIgnore: true */
|
|
541
|
-
dir,
|
|
542
|
-
name
|
|
543
|
-
);
|
|
544
|
-
if (fs.statSync(
|
|
545
|
-
/* turbopackIgnore: true */
|
|
546
|
-
full
|
|
547
|
-
).isDirectory()) scan(full, [...slugParts, name]);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
scan(docsDir, []);
|
|
551
|
-
return map;
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Scan all page.mdx files and build a map of URL pathname → description
|
|
555
|
-
* from the frontmatter `description` field.
|
|
556
|
-
*/
|
|
557
|
-
function buildDescriptionMap(config, ctx) {
|
|
558
|
-
const docsDir = ctx.docsDir;
|
|
559
|
-
const map = {};
|
|
560
|
-
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
561
|
-
function scan(dir, slugParts) {
|
|
562
|
-
if (!fs.existsSync(
|
|
563
|
-
/* turbopackIgnore: true */
|
|
564
|
-
dir
|
|
565
|
-
)) return;
|
|
566
|
-
if (isExcludedDir(dir, excludedDirs)) return;
|
|
567
|
-
const pagePath = path.join(
|
|
568
|
-
/* turbopackIgnore: true */
|
|
569
|
-
dir,
|
|
570
|
-
"page.mdx"
|
|
571
|
-
);
|
|
572
|
-
if (fs.existsSync(
|
|
573
|
-
/* turbopackIgnore: true */
|
|
574
|
-
pagePath
|
|
575
|
-
)) {
|
|
576
|
-
const desc = readFrontmatter(pagePath).description;
|
|
577
|
-
if (desc) {
|
|
578
|
-
const url = publicDocsRoute(ctx, slugParts);
|
|
579
|
-
map[url] = desc;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
for (const name of fs.readdirSync(
|
|
583
|
-
/* turbopackIgnore: true */
|
|
584
|
-
dir
|
|
585
|
-
)) {
|
|
586
|
-
const full = path.join(
|
|
587
|
-
/* turbopackIgnore: true */
|
|
588
|
-
dir,
|
|
589
|
-
name
|
|
590
|
-
);
|
|
591
|
-
if (fs.statSync(
|
|
592
|
-
/* turbopackIgnore: true */
|
|
593
|
-
full
|
|
594
|
-
).isDirectory()) scan(full, [...slugParts, name]);
|
|
595
|
-
}
|
|
428
|
+
/** Keep consumer sidebar mutations local to the current render. */
|
|
429
|
+
function cloneTree(tree) {
|
|
430
|
+
function cloneNode(node) {
|
|
431
|
+
if (node.type !== "folder") return { ...node };
|
|
432
|
+
return {
|
|
433
|
+
...node,
|
|
434
|
+
index: node.index ? { ...node.index } : void 0,
|
|
435
|
+
children: node.children.map(cloneNode)
|
|
436
|
+
};
|
|
596
437
|
}
|
|
597
|
-
|
|
598
|
-
|
|
438
|
+
return {
|
|
439
|
+
...tree,
|
|
440
|
+
children: tree.children.map(cloneNode)
|
|
441
|
+
};
|
|
599
442
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
* This lets the page frame render the frontmatter title exactly once.
|
|
603
|
-
*/
|
|
604
|
-
function buildGeneratedTitleMap(config, ctx) {
|
|
605
|
-
const docsDir = ctx.docsDir;
|
|
606
|
-
const map = {};
|
|
607
|
-
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
608
|
-
function scan(dir, slugParts) {
|
|
609
|
-
if (!fs.existsSync(
|
|
610
|
-
/* turbopackIgnore: true */
|
|
611
|
-
dir
|
|
612
|
-
)) return;
|
|
613
|
-
if (isExcludedDir(dir, excludedDirs)) return;
|
|
614
|
-
const pagePath = findDocsPageFile(dir);
|
|
615
|
-
if (pagePath) {
|
|
616
|
-
const source = fs.readFileSync(
|
|
617
|
-
/* turbopackIgnore: true */
|
|
618
|
-
pagePath,
|
|
619
|
-
"utf-8"
|
|
620
|
-
);
|
|
621
|
-
const { data } = matter(source);
|
|
622
|
-
if (typeof data.title === "string" && !hasAuthoredPageTitle(source)) map[publicDocsRoute(ctx, slugParts)] = data.title;
|
|
623
|
-
}
|
|
624
|
-
for (const name of fs.readdirSync(
|
|
625
|
-
/* turbopackIgnore: true */
|
|
626
|
-
dir
|
|
627
|
-
)) {
|
|
628
|
-
const full = path.join(
|
|
629
|
-
/* turbopackIgnore: true */
|
|
630
|
-
dir,
|
|
631
|
-
name
|
|
632
|
-
);
|
|
633
|
-
if (fs.statSync(
|
|
634
|
-
/* turbopackIgnore: true */
|
|
635
|
-
full
|
|
636
|
-
).isDirectory()) scan(full, [...slugParts, name]);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
scan(docsDir, []);
|
|
640
|
-
return map;
|
|
443
|
+
function resolveManifestLastmod(manifest, ctx, url) {
|
|
444
|
+
return (ctx.locale ? resolveDocsSitemapPageLastmod(manifest, `${url}?lang=${encodeURIComponent(ctx.locale)}`) : void 0) ?? resolveDocsSitemapPageLastmod(manifest, url);
|
|
641
445
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const
|
|
446
|
+
/** Read each page once for all metadata, sharing the reader with navigation. */
|
|
447
|
+
function buildPageMaps(config, ctx, reader, manifest, options) {
|
|
448
|
+
const lastModifiedMap = {};
|
|
449
|
+
const descriptionMap = {};
|
|
450
|
+
const generatedTitleMap = {};
|
|
451
|
+
const readingTimeMap = {};
|
|
645
452
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
453
|
+
const structuredDataPages = {
|
|
454
|
+
baseUrl: resolveDocsMetadataBaseUrl(config),
|
|
455
|
+
entry: ctx.entryPath,
|
|
456
|
+
pages: {}
|
|
457
|
+
};
|
|
458
|
+
const dateFormatter = options.lastUpdated ? new Intl.DateTimeFormat("en-US", {
|
|
459
|
+
year: "numeric",
|
|
460
|
+
month: "long",
|
|
461
|
+
day: "numeric"
|
|
462
|
+
}) : void 0;
|
|
646
463
|
function scan(dir, slugParts) {
|
|
647
|
-
if (!fs.existsSync(
|
|
648
|
-
/* turbopackIgnore: true */
|
|
649
|
-
dir
|
|
650
|
-
)) return;
|
|
651
464
|
if (isExcludedDir(dir, excludedDirs)) return;
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
);
|
|
657
|
-
if (fs.existsSync(
|
|
658
|
-
/* turbopackIgnore: true */
|
|
659
|
-
pagePath
|
|
660
|
-
)) {
|
|
661
|
-
const { data, content } = matter(fs.readFileSync(
|
|
662
|
-
/* turbopackIgnore: true */
|
|
663
|
-
pagePath,
|
|
664
|
-
"utf-8"
|
|
665
|
-
));
|
|
666
|
-
const minutes = resolvePageReadingTime(data, resolveDocsAudienceMdxContent(content, "human"), options);
|
|
667
|
-
if (typeof minutes === "number") {
|
|
668
|
-
const url = publicDocsRoute(ctx, slugParts);
|
|
669
|
-
map[url] = minutes;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
for (const name of fs.readdirSync(
|
|
673
|
-
/* turbopackIgnore: true */
|
|
674
|
-
dir
|
|
675
|
-
)) {
|
|
676
|
-
const full = path.join(
|
|
465
|
+
const { directories, files } = reader.directory(dir);
|
|
466
|
+
const fileName = files.has("page.mdx") ? "page.mdx" : files.has("page.md") ? "page.md" : void 0;
|
|
467
|
+
if (fileName) {
|
|
468
|
+
const { data, content, modifiedAt } = reader.page(path.join(
|
|
677
469
|
/* turbopackIgnore: true */
|
|
678
470
|
dir,
|
|
679
|
-
|
|
680
|
-
);
|
|
681
|
-
if (fs.statSync(
|
|
682
|
-
/* turbopackIgnore: true */
|
|
683
|
-
full
|
|
684
|
-
).isDirectory()) scan(full, [...slugParts, name]);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
scan(docsDir, []);
|
|
688
|
-
return map;
|
|
689
|
-
}
|
|
690
|
-
function findDocsPageFile(dir) {
|
|
691
|
-
return ["page.mdx", "page.md"].map((fileName) => path.join(
|
|
692
|
-
/* turbopackIgnore: true */
|
|
693
|
-
dir,
|
|
694
|
-
fileName
|
|
695
|
-
)).find((candidate) => fs.existsSync(
|
|
696
|
-
/* turbopackIgnore: true */
|
|
697
|
-
candidate
|
|
698
|
-
));
|
|
699
|
-
}
|
|
700
|
-
function buildStructuredDataMap(config, ctx, manifest) {
|
|
701
|
-
const docsDir = ctx.docsDir;
|
|
702
|
-
const map = {};
|
|
703
|
-
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
704
|
-
const baseUrl = resolveDocsMetadataBaseUrl(config);
|
|
705
|
-
function scan(dir, slugParts) {
|
|
706
|
-
if (!fs.existsSync(
|
|
707
|
-
/* turbopackIgnore: true */
|
|
708
|
-
dir
|
|
709
|
-
)) return;
|
|
710
|
-
if (isExcludedDir(dir, excludedDirs)) return;
|
|
711
|
-
const pagePath = findDocsPageFile(dir);
|
|
712
|
-
if (pagePath) {
|
|
713
|
-
const { data } = matter(fs.readFileSync(
|
|
714
|
-
/* turbopackIgnore: true */
|
|
715
|
-
pagePath,
|
|
716
|
-
"utf-8"
|
|
471
|
+
fileName
|
|
717
472
|
));
|
|
718
473
|
const route = publicDocsRoute(ctx, slugParts);
|
|
719
474
|
const title = typeof data.title === "string" ? data.title : slugParts.at(-1)?.replace(/-/g, " ") || "Documentation";
|
|
720
475
|
const description = typeof data.description === "string" ? data.description : void 0;
|
|
721
476
|
const manifestLastmod = resolveManifestLastmod(manifest, ctx, route);
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
477
|
+
if (config.theme?.name === "shadcn" && typeof data.title === "string" && !hasAuthoredPageTitle(content)) generatedTitleMap[route] = data.title;
|
|
478
|
+
if (fileName === "page.mdx") {
|
|
479
|
+
if (dateFormatter) lastModifiedMap[route] = dateFormatter.format(manifestLastmod ? /* @__PURE__ */ new Date(`${manifestLastmod}T00:00:00`) : modifiedAt);
|
|
480
|
+
if (description) descriptionMap[route] = description;
|
|
481
|
+
const minutes = resolvePageReadingTime(data, (options.enabledByDefault || Object.hasOwn(data, "readingTime")) && data.readingTime !== false && !(typeof data.readingTime === "number" && Number.isFinite(data.readingTime)) ? resolveDocsAudienceMdxContent(content, "human") : "", options);
|
|
482
|
+
if (typeof minutes === "number") readingTimeMap[route] = minutes;
|
|
483
|
+
}
|
|
484
|
+
structuredDataPages.pages[route] = compactPageStructuredData({
|
|
727
485
|
title,
|
|
728
486
|
description,
|
|
729
487
|
url: withLangInUrl(route, ctx.locale),
|
|
730
|
-
|
|
731
|
-
entry: ctx.entryPath,
|
|
732
|
-
dateModified,
|
|
488
|
+
dateModified: manifestLastmod ? `${manifestLastmod}T00:00:00.000Z` : modifiedAt.toISOString(),
|
|
733
489
|
agent: normalizePageAgentFrontmatter(data.agent)
|
|
734
490
|
});
|
|
735
491
|
}
|
|
736
|
-
for (const name of
|
|
492
|
+
for (const name of directories) scan(path.join(
|
|
737
493
|
/* turbopackIgnore: true */
|
|
738
|
-
dir
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
/* turbopackIgnore: true */
|
|
742
|
-
dir,
|
|
743
|
-
name
|
|
744
|
-
);
|
|
745
|
-
if (fs.statSync(
|
|
746
|
-
/* turbopackIgnore: true */
|
|
747
|
-
full
|
|
748
|
-
).isDirectory()) scan(full, [...slugParts, name]);
|
|
749
|
-
}
|
|
494
|
+
dir,
|
|
495
|
+
name
|
|
496
|
+
), [...slugParts, name]);
|
|
750
497
|
}
|
|
751
|
-
scan(docsDir, []);
|
|
752
|
-
return
|
|
498
|
+
scan(ctx.docsDir, []);
|
|
499
|
+
return {
|
|
500
|
+
lastModifiedMap,
|
|
501
|
+
descriptionMap,
|
|
502
|
+
generatedTitleMap,
|
|
503
|
+
readingTimeMap,
|
|
504
|
+
structuredDataPages
|
|
505
|
+
};
|
|
753
506
|
}
|
|
754
507
|
/**
|
|
755
508
|
* Build a Next.js Metadata object from the docs config.
|
|
@@ -944,7 +697,6 @@ function createDocsLayout(config, options) {
|
|
|
944
697
|
const tocStyle = tocConfig?.style;
|
|
945
698
|
const analyticsEnabled = resolveDocsAnalyticsConfig(config.analytics).enabled;
|
|
946
699
|
const localeContext = resolveDocsLocaleContext(config, options?.locale);
|
|
947
|
-
const sitemapManifest = readDocsSitemapManifest(process.cwd(), config.sitemap);
|
|
948
700
|
const i18n = resolveDocsI18nConfig(getDocsI18n(config));
|
|
949
701
|
const activeLocale = localeContext.locale ?? i18n?.defaultLocale;
|
|
950
702
|
const docsApiUrl = withLangInUrl("/api/docs", activeLocale);
|
|
@@ -999,6 +751,7 @@ function createDocsLayout(config, options) {
|
|
|
999
751
|
const aiConfig = config.ai;
|
|
1000
752
|
const aiEnabled = !staticExport && !!aiConfig?.enabled;
|
|
1001
753
|
const aiMode = aiConfig?.mode ?? "search";
|
|
754
|
+
const aiHandlesSearch = aiEnabled && (aiMode === "search" || aiMode === "sidebar-icon");
|
|
1002
755
|
const aiPosition = aiConfig?.position ?? "bottom-right";
|
|
1003
756
|
const aiFloatingStyle = aiConfig?.floatingStyle ?? "panel";
|
|
1004
757
|
const aiTriggerComponentHtml = aiConfig?.triggerComponent ? serializeIcon(aiConfig.triggerComponent) : void 0;
|
|
@@ -1014,22 +767,28 @@ function createDocsLayout(config, options) {
|
|
|
1014
767
|
aiModels = rawModelConfig.models ?? aiModels;
|
|
1015
768
|
aiDefaultModelId = rawModelConfig.defaultModel ?? rawModelConfig.models?.[0]?.id ?? aiDefaultModelId;
|
|
1016
769
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
const readingTimeEnabled = readingTimeEnabledByDefault || Object.keys(readingTimeMap).length > 0;
|
|
1027
|
-
return function DocsLayoutWrapper({ children }) {
|
|
1028
|
-
const tree = applySidebarFolderIndexBehavior(buildTree(config, localeContext, !!sidebarFlat), {
|
|
770
|
+
function prepareContent() {
|
|
771
|
+
const reader = createDocsContentReader();
|
|
772
|
+
const maps = buildPageMaps(config, localeContext, reader, readDocsSitemapManifest(process.cwd(), config.sitemap), {
|
|
773
|
+
lastUpdated: lastUpdatedEnabled,
|
|
774
|
+
enabledByDefault: readingTimeEnabledByDefault,
|
|
775
|
+
wordsPerMinute: readingTimeWordsPerMinute,
|
|
776
|
+
includeCode: readingTimeIncludeCode
|
|
777
|
+
});
|
|
778
|
+
const tree = applySidebarFolderIndexBehavior(buildTree(config, localeContext, reader, !!sidebarFlat), {
|
|
1029
779
|
sidebar: config.sidebar,
|
|
1030
780
|
defaultBehavior: config.theme?.name === "shadcn" ? "hidden" : "link"
|
|
1031
781
|
});
|
|
1032
|
-
|
|
782
|
+
return {
|
|
783
|
+
...maps,
|
|
784
|
+
localizedTree: i18n ? localizeTreeUrls(tree, activeLocale) : tree
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
let productionContent;
|
|
788
|
+
return function DocsLayoutWrapper({ children }) {
|
|
789
|
+
const { lastModifiedMap, descriptionMap, generatedTitleMap, readingTimeMap, structuredDataPages, localizedTree: preparedTree } = process.env.NODE_ENV === "production" ? productionContent ??= prepareContent() : prepareContent();
|
|
790
|
+
const localizedTree = cloneTree(preparedTree);
|
|
791
|
+
const readingTimeEnabled = readingTimeEnabledByDefault || Object.keys(readingTimeMap).length > 0;
|
|
1033
792
|
const finalSidebarProps = { ...sidebarProps };
|
|
1034
793
|
const sidebarFooter = withStableReactKey(sidebarProps.footer, "docs-sidebar-footer");
|
|
1035
794
|
finalSidebarProps.banner = withStableReactKey(sidebarProps.banner, "docs-sidebar-banner");
|
|
@@ -1073,7 +832,7 @@ function createDocsLayout(config, options) {
|
|
|
1073
832
|
/* @__PURE__ */ jsx(TypographyStyle, { typography }),
|
|
1074
833
|
/* @__PURE__ */ jsx(LayoutStyle, { layout: layoutDimensions }),
|
|
1075
834
|
forcedTheme && /* @__PURE__ */ jsx(ForcedThemeScript, { theme: forcedTheme }),
|
|
1076
|
-
!staticExport && /* @__PURE__ */ jsx(Suspense, {
|
|
835
|
+
!staticExport && !aiHandlesSearch && /* @__PURE__ */ jsx(Suspense, {
|
|
1077
836
|
fallback: null,
|
|
1078
837
|
children: /* @__PURE__ */ jsx(DocsCommandSearch, {
|
|
1079
838
|
api: docsApiUrl,
|
|
@@ -1137,7 +896,7 @@ function createDocsLayout(config, options) {
|
|
|
1137
896
|
readingTimeEnabled,
|
|
1138
897
|
readingTimeFormat,
|
|
1139
898
|
readingTimeMap,
|
|
1140
|
-
|
|
899
|
+
structuredDataPages,
|
|
1141
900
|
llmsTxtEnabled,
|
|
1142
901
|
generatedTitleMap,
|
|
1143
902
|
descriptionMap,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DocsStructuredDataPages } from "./page-structured-data.mjs";
|
|
1
2
|
import { ReactNode } from "react";
|
|
2
3
|
import { CopyMarkdownFormat, DocsFeedbackData, DocsTelemetryConfig, DocsTelemetryFramework, PageActionConnectMcpConfig, PageActionInstallSkillsConfig, ReadingTimeFormat } from "@farming-labs/docs";
|
|
3
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -67,6 +68,8 @@ interface DocsPageClientProps {
|
|
|
67
68
|
nextPage?: PageNavigationItem | null;
|
|
68
69
|
/** Map of pathname → serialized Schema.org JSON-LD. */
|
|
69
70
|
structuredDataMap?: Record<string, string>;
|
|
71
|
+
/** Compact page fields; shared schema and breadcrumbs expand only for the active page. */
|
|
72
|
+
structuredDataPages?: DocsStructuredDataPages;
|
|
70
73
|
/** Direct serialized Schema.org JSON-LD override for the current page. */
|
|
71
74
|
structuredData?: string;
|
|
72
75
|
/**
|
|
@@ -141,6 +144,7 @@ declare function DocsPageClient({
|
|
|
141
144
|
previousPage,
|
|
142
145
|
nextPage,
|
|
143
146
|
structuredDataMap,
|
|
147
|
+
structuredDataPages,
|
|
144
148
|
structuredData: structuredDataProp,
|
|
145
149
|
readingTimeEnabled,
|
|
146
150
|
lastUpdatedEnabled,
|
|
@@ -6,6 +6,7 @@ import { useWindowPathname, useWindowSearchParams } from "./client-location.mjs"
|
|
|
6
6
|
import { DocsFeedback } from "./docs-feedback.mjs";
|
|
7
7
|
import { resolveClientLocale, withLangInUrl } from "./i18n.mjs";
|
|
8
8
|
import { escapeJsonLdForScript } from "./json-ld.mjs";
|
|
9
|
+
import { renderPageStructuredData } from "./page-structured-data.mjs";
|
|
9
10
|
import { Children, Fragment, useEffect, useLayoutEffect, useState } from "react";
|
|
10
11
|
import { DocsBody, DocsPage, EditOnGitHub } from "fumadocs-ui/layouts/docs/page";
|
|
11
12
|
import { createPortal } from "react-dom";
|
|
@@ -25,6 +26,14 @@ const agentLlmsDirectiveStyle = {
|
|
|
25
26
|
whiteSpace: "nowrap",
|
|
26
27
|
border: 0
|
|
27
28
|
};
|
|
29
|
+
/** Read authored heading text without changing its anchor controls or accessible names. */
|
|
30
|
+
function getTocHeadingText(node) {
|
|
31
|
+
if (node.nodeType === Node.TEXT_NODE) return node.textContent ?? "";
|
|
32
|
+
if (node instanceof Element && node.matches("button, [role=\"button\"]")) return "";
|
|
33
|
+
let text = "";
|
|
34
|
+
for (const child of node.childNodes) text += getTocHeadingText(child);
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
28
37
|
/**
|
|
29
38
|
* Path-based breadcrumb that shows only parent / current folder.
|
|
30
39
|
* Skips the entry segment (e.g. "docs"). Parent is clickable.
|
|
@@ -256,7 +265,7 @@ function findThreadlineTocActionsContainer() {
|
|
|
256
265
|
}
|
|
257
266
|
return toc.parentElement ?? toc;
|
|
258
267
|
}
|
|
259
|
-
function DocsPageClient({ tocEnabled, showLlmsInHeader = false, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, copyMarkdownFormat, copyMarkdownIncludeTitle, copyMarkdownLabel, copyMarkdownCopiedLabel, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, connectMcp, installSkills, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", previousPage, nextPage, structuredDataMap, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedLabel = "Last updated", lastUpdatedPosition = "footer", llmsTxtEnabled = false, generatedTitleMap, descriptionMap, description, descriptionInBody = false, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackRequireComment, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackSuccessMessage, feedbackErrorMessage, feedbackOnFeedback, analytics = false, telemetry, telemetryFramework, children }) {
|
|
268
|
+
function DocsPageClient({ tocEnabled, showLlmsInHeader = false, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, copyMarkdownFormat, copyMarkdownIncludeTitle, copyMarkdownLabel, copyMarkdownCopiedLabel, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, connectMcp, installSkills, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", previousPage, nextPage, structuredDataMap, structuredDataPages, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedLabel = "Last updated", lastUpdatedPosition = "footer", llmsTxtEnabled = false, generatedTitleMap, descriptionMap, description, descriptionInBody = false, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackRequireComment, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackSuccessMessage, feedbackErrorMessage, feedbackOnFeedback, analytics = false, telemetry, telemetryFramework, children }) {
|
|
260
269
|
const router = useRouter();
|
|
261
270
|
const fdTocStyle = tocStyle === "directional" ? "clerk" : void 0;
|
|
262
271
|
const [toc, setToc] = useState([]);
|
|
@@ -276,7 +285,7 @@ function DocsPageClient({ tocEnabled, showLlmsInHeader = false, tocStyle = "defa
|
|
|
276
285
|
const pageDescription = description ?? descriptionMap?.[normalizedPath];
|
|
277
286
|
const isChangelogRoute = !!(changelogBasePath && (normalizedPath === changelogBasePath || normalizedPath.startsWith(`${changelogBasePath}/`)));
|
|
278
287
|
const matchedReadingTime = readingTimeMap?.[normalizedPath];
|
|
279
|
-
const structuredDataJson = !isChangelogRoute ? structuredDataProp ?? structuredDataMap?.[normalizedPath] : void 0;
|
|
288
|
+
const structuredDataJson = !isChangelogRoute ? structuredDataProp ?? structuredDataMap?.[normalizedPath] ?? renderPageStructuredData(structuredDataPages, normalizedPath) : void 0;
|
|
280
289
|
useEffect(() => {
|
|
281
290
|
if (!analytics) return;
|
|
282
291
|
emitClientAnalyticsEvent({
|
|
@@ -326,7 +335,7 @@ function DocsPageClient({ tocEnabled, showLlmsInHeader = false, tocStyle = "defa
|
|
|
326
335
|
if (!container) return;
|
|
327
336
|
const headings = container.querySelectorAll("h2[id], h3[id], h4[id]");
|
|
328
337
|
setToc(Array.from(headings).map((el) => ({
|
|
329
|
-
title: el.
|
|
338
|
+
title: getTocHeadingText(el).replace(/^#\s*/, ""),
|
|
330
339
|
url: `#${el.id}`,
|
|
331
340
|
depth: parseInt(el.tagName[1], 10)
|
|
332
341
|
})));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DocsPageStructuredDataInput } from "@farming-labs/docs";
|
|
2
|
+
|
|
3
|
+
//#region src/page-structured-data.d.ts
|
|
4
|
+
type Page = Pick<DocsPageStructuredDataInput, "title" | "description" | "url" | "dateModified" | "breadcrumbs"> & {
|
|
5
|
+
mainEntity?: unknown;
|
|
6
|
+
};
|
|
7
|
+
interface DocsStructuredDataPages {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
entry?: string;
|
|
10
|
+
pages: Record<string, Page>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DocsStructuredDataPages };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { buildDocsPageStructuredData } from "@farming-labs/docs/browser";
|
|
2
|
+
|
|
3
|
+
//#region src/page-structured-data.ts
|
|
4
|
+
/** Retain only fields that contribute to the public JSON-LD, never raw agent frontmatter. */
|
|
5
|
+
function compactPageStructuredData(input) {
|
|
6
|
+
return {
|
|
7
|
+
title: input.title,
|
|
8
|
+
description: input.description,
|
|
9
|
+
url: input.url,
|
|
10
|
+
dateModified: input.dateModified,
|
|
11
|
+
breadcrumbs: input.breadcrumbs,
|
|
12
|
+
mainEntity: input.agent ? buildDocsPageStructuredData(input).mainEntity : void 0
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Expand only the active page, during both server rendering and client navigation. */
|
|
16
|
+
function renderPageStructuredData(data, pathname) {
|
|
17
|
+
const page = data?.pages[pathname];
|
|
18
|
+
if (!page) return void 0;
|
|
19
|
+
const { mainEntity, ...input } = page;
|
|
20
|
+
const value = buildDocsPageStructuredData({
|
|
21
|
+
...input,
|
|
22
|
+
baseUrl: data?.baseUrl,
|
|
23
|
+
entry: data?.entry
|
|
24
|
+
});
|
|
25
|
+
if (mainEntity !== void 0) value.mainEntity = mainEntity;
|
|
26
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { compactPageStructuredData, renderPageStructuredData };
|
|
@@ -16,7 +16,7 @@ function resolveReadingTimeOptions(readingTime) {
|
|
|
16
16
|
includeCode: false
|
|
17
17
|
};
|
|
18
18
|
return {
|
|
19
|
-
enabled: readingTime.enabled
|
|
19
|
+
enabled: readingTime.enabled === true,
|
|
20
20
|
wordsPerMinute: typeof readingTime.wordsPerMinute === "number" && Number.isFinite(readingTime.wordsPerMinute) ? readingTime.wordsPerMinute : void 0,
|
|
21
21
|
format: readingTime.format === "short" ? "short" : "long",
|
|
22
22
|
includeCode: readingTime.includeCode === true
|
package/dist/tanstack-layout.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import { resolveOpenDocsProviders } from "./open-docs-providers.mjs";
|
|
|
2
2
|
import { withLangInUrl } from "./i18n.mjs";
|
|
3
3
|
import { escapeJsonLdForScript } from "./json-ld.mjs";
|
|
4
4
|
import { DocsPageClient } from "./docs-page-client.mjs";
|
|
5
|
-
import { DocsAIFeatures } from "./docs-ai-features.mjs";
|
|
6
5
|
import { resolveDocsCloudAIClientRequest } from "./docs-cloud-ai-client.mjs";
|
|
7
6
|
import { DocsCommandSearch } from "./docs-command-search.mjs";
|
|
8
7
|
import { resolveReadingTimeOptions } from "./reading-time-options.mjs";
|
|
9
8
|
import { SidebarSearchWithAI } from "./sidebar-search-ai.mjs";
|
|
10
9
|
import { LocaleThemeControl } from "./locale-theme-control.mjs";
|
|
10
|
+
import { DocsAIFeatures } from "./docs-ai-features.mjs";
|
|
11
11
|
import { TabletSidebarBridge } from "./tablet-sidebar-bridge.mjs";
|
|
12
12
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
13
13
|
import { Suspense } from "react";
|
|
@@ -287,6 +287,7 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
|
|
|
287
287
|
const aiConfig = config.ai;
|
|
288
288
|
const aiEnabled = !staticExport && !!aiConfig?.enabled;
|
|
289
289
|
const aiMode = aiConfig?.mode ?? "search";
|
|
290
|
+
const aiHandlesSearch = aiEnabled && (aiMode === "search" || aiMode === "sidebar-icon");
|
|
290
291
|
const aiPosition = aiConfig?.position ?? "bottom-right";
|
|
291
292
|
const aiFloatingStyle = aiConfig?.floatingStyle ?? "panel";
|
|
292
293
|
const aiSuggestedQuestions = aiConfig?.suggestedQuestions;
|
|
@@ -350,7 +351,7 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
|
|
|
350
351
|
/* @__PURE__ */ jsx(LayoutStyle, { layout: layoutDimensions }),
|
|
351
352
|
forcedTheme && /* @__PURE__ */ jsx(ForcedThemeScript, { theme: forcedTheme }),
|
|
352
353
|
browserRuntime && config.theme?.name === "fumadocs-pixel-border" && /* @__PURE__ */ jsx(TabletSidebarBridge, {}),
|
|
353
|
-
!staticExport && /* @__PURE__ */ jsx(Suspense, {
|
|
354
|
+
!staticExport && !aiHandlesSearch && /* @__PURE__ */ jsx(Suspense, {
|
|
354
355
|
fallback: null,
|
|
355
356
|
children: /* @__PURE__ */ jsx(DocsCommandSearch, {
|
|
356
357
|
api: docsApiUrl,
|
|
@@ -381,7 +382,6 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
|
|
|
381
382
|
fallback: children,
|
|
382
383
|
children: /* @__PURE__ */ jsx(DocsPageClient, {
|
|
383
384
|
tocEnabled,
|
|
384
|
-
showLlmsInHeader: browserRuntime && config.theme?.name === "fumadocs-pixel-border",
|
|
385
385
|
tocStyle,
|
|
386
386
|
breadcrumbEnabled,
|
|
387
387
|
entry: config.entry ?? "docs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.121",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"tsdown": "^0.20.3",
|
|
162
162
|
"typescript": "^5.9.3",
|
|
163
163
|
"vitest": "^4.1.8",
|
|
164
|
-
"@farming-labs/docs": "0.2.
|
|
164
|
+
"@farming-labs/docs": "0.2.121"
|
|
165
165
|
},
|
|
166
166
|
"peerDependencies": {
|
|
167
167
|
"@farming-labs/docs": ">=0.0.1",
|
package/styles/framework.css
CHANGED