@farming-labs/theme 0.2.140 → 0.2.142
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-layout.d.mts +12 -1
- package/dist/docs-layout.mjs +35 -5
- package/dist/docs-page-client.d.mts +18 -1
- package/dist/docs-page-client.mjs +35 -2
- package/dist/page-metadata.mjs +2 -1
- package/package.json +9 -4
package/dist/docs-layout.d.mts
CHANGED
|
@@ -31,13 +31,24 @@ declare function createDocsMetadata(config: DocsConfig): Record<string, unknown>
|
|
|
31
31
|
declare function createPageMetadata(config: DocsConfig, page: Pick<PageFrontmatter, "title" | "description" | "ogImage" | "openGraph" | "twitter">, baseUrl?: string, url?: string, options?: {
|
|
32
32
|
locale?: string;
|
|
33
33
|
}): Record<string, unknown>;
|
|
34
|
+
/** Server boundary used by compiled docs pages; shares the legacy metadata builder. */
|
|
35
|
+
declare function DocsPageContent({
|
|
36
|
+
config,
|
|
37
|
+
route,
|
|
38
|
+
children
|
|
39
|
+
}: {
|
|
40
|
+
config: DocsConfig;
|
|
41
|
+
route: string;
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
34
44
|
declare function createDocsLayout(config: DocsConfig, options?: {
|
|
35
45
|
locale?: string;
|
|
36
46
|
telemetryFramework?: DocsTelemetryFramework;
|
|
47
|
+
pageRoutes?: string[];
|
|
37
48
|
}): ({
|
|
38
49
|
children
|
|
39
50
|
}: {
|
|
40
51
|
children: ReactNode;
|
|
41
52
|
}) => react_jsx_runtime0.JSX.Element;
|
|
42
53
|
//#endregion
|
|
43
|
-
export { createDocsLayout, createDocsMetadata, createPageMetadata };
|
|
54
|
+
export { DocsPageContent, createDocsLayout, createDocsMetadata, createPageMetadata };
|
package/dist/docs-layout.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { resolveOpenDocsProviders } from "./open-docs-providers.mjs";
|
|
|
3
3
|
import { withLangInUrl } from "./i18n.mjs";
|
|
4
4
|
import { compactPageStructuredData } from "./page-structured-data.mjs";
|
|
5
5
|
import { serializePageMetadata } from "./page-metadata.mjs";
|
|
6
|
-
import { DocsPageClient } from "./docs-page-client.mjs";
|
|
6
|
+
import { DocsPageClient, DocsPageContentClient, DocsPageProvider } from "./docs-page-client.mjs";
|
|
7
7
|
import { DocsAIFeatures } from "./docs-ai-features-lazy.mjs";
|
|
8
8
|
import { resolveDocsCloudAIClientRequest } from "./docs-cloud-ai-client.mjs";
|
|
9
9
|
import { DocsCommandSearch } from "./docs-command-search.mjs";
|
|
@@ -475,13 +475,18 @@ function buildPageMaps(config, ctx, reader, manifest, options) {
|
|
|
475
475
|
agent: normalizePageAgentFrontmatter(data.agent)
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
|
+
if (options.slugParts) return;
|
|
478
479
|
for (const name of directories) scan(path.join(
|
|
479
480
|
/* turbopackIgnore: true */
|
|
480
481
|
dir,
|
|
481
482
|
name
|
|
482
483
|
), [...slugParts, name]);
|
|
483
484
|
}
|
|
484
|
-
scan(
|
|
485
|
+
scan(path.join(
|
|
486
|
+
/* turbopackIgnore: true */
|
|
487
|
+
ctx.docsDir,
|
|
488
|
+
...options.slugParts ?? []
|
|
489
|
+
), options.slugParts ?? []);
|
|
485
490
|
return {
|
|
486
491
|
lastModifiedMap,
|
|
487
492
|
descriptionMap,
|
|
@@ -677,7 +682,31 @@ function LayoutStyle({ layout }) {
|
|
|
677
682
|
}
|
|
678
683
|
return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: parts.join("\n") } });
|
|
679
684
|
}
|
|
685
|
+
/** Server boundary used by compiled docs pages; shares the legacy metadata builder. */
|
|
686
|
+
function DocsPageContent({ config, route, children }) {
|
|
687
|
+
const ctx = resolveDocsLocaleContext(config);
|
|
688
|
+
const prefix = publicDocsRoute(ctx);
|
|
689
|
+
const slugParts = (route === prefix ? "" : route.slice(prefix === "/" ? 1 : prefix.length + 1)).split("/").filter(Boolean);
|
|
690
|
+
if (!(route === prefix || route.startsWith(`${prefix === "/" ? "" : prefix}/`)) || slugParts.some((part) => part === "." || part === ".." || part.includes("\\"))) throw new Error("Invalid docs page metadata route");
|
|
691
|
+
const readingTime = resolveReadingTimeOptions(config.readingTime);
|
|
692
|
+
const lastUpdated = config.lastUpdated;
|
|
693
|
+
const maps = buildPageMaps(config, ctx, createDocsContentReader(), readDocsSitemapManifest(process.cwd(), config.sitemap), {
|
|
694
|
+
slugParts,
|
|
695
|
+
lastUpdated: lastUpdated !== false && (typeof lastUpdated !== "object" || lastUpdated.enabled !== false),
|
|
696
|
+
enabledByDefault: readingTime.enabled,
|
|
697
|
+
wordsPerMinute: readingTime.wordsPerMinute ?? 220,
|
|
698
|
+
includeCode: readingTime.includeCode
|
|
699
|
+
});
|
|
700
|
+
return /* @__PURE__ */ jsx(DocsPageContentClient, {
|
|
701
|
+
pageMetadata: serializePageMetadata(maps),
|
|
702
|
+
readingTimeEnabled: readingTime.enabled || Object.keys(maps.readingTimeMap).length > 0,
|
|
703
|
+
children
|
|
704
|
+
});
|
|
705
|
+
}
|
|
680
706
|
function createDocsLayout(config, options) {
|
|
707
|
+
const pageRoutes = config.components?.wrapper ? [] : options?.pageRoutes ?? [];
|
|
708
|
+
const pageRouteSet = new Set(pageRoutes);
|
|
709
|
+
const PageWrapper = pageRoutes.length > 0 ? DocsPageProvider : DocsPageClient;
|
|
681
710
|
const tocConfig = config.theme?.ui?.layout?.toc;
|
|
682
711
|
const tocEnabled = tocConfig?.enabled !== false;
|
|
683
712
|
const tocStyle = tocConfig?.style;
|
|
@@ -767,7 +796,7 @@ function createDocsLayout(config, options) {
|
|
|
767
796
|
defaultBehavior: config.theme?.name === "shadcn" ? "hidden" : "link"
|
|
768
797
|
});
|
|
769
798
|
return {
|
|
770
|
-
pageMetadata: serializePageMetadata(maps),
|
|
799
|
+
pageMetadata: serializePageMetadata(maps, pageRouteSet),
|
|
771
800
|
readingTimeEnabled: readingTimeEnabledByDefault || Object.keys(maps.readingTimeMap).length > 0,
|
|
772
801
|
localizedTree: i18n ? localizeTreeUrls(tree, activeLocale) : tree
|
|
773
802
|
};
|
|
@@ -861,7 +890,8 @@ function createDocsLayout(config, options) {
|
|
|
861
890
|
}),
|
|
862
891
|
/* @__PURE__ */ jsx(Suspense, {
|
|
863
892
|
fallback: children,
|
|
864
|
-
children: /* @__PURE__ */ jsx(
|
|
893
|
+
children: /* @__PURE__ */ jsx(PageWrapper, {
|
|
894
|
+
pageRoutes,
|
|
865
895
|
tocEnabled,
|
|
866
896
|
tocStyle,
|
|
867
897
|
breadcrumbEnabled,
|
|
@@ -972,4 +1002,4 @@ function ForcedThemeScript({ theme }) {
|
|
|
972
1002
|
}
|
|
973
1003
|
|
|
974
1004
|
//#endregion
|
|
975
|
-
export { createDocsLayout, createDocsMetadata, createPageMetadata };
|
|
1005
|
+
export { DocsPageContent, createDocsLayout, createDocsMetadata, createPageMetadata };
|
|
@@ -132,6 +132,23 @@ interface DocsPageClientProps {
|
|
|
132
132
|
footer?: ReactNode;
|
|
133
133
|
children: ReactNode;
|
|
134
134
|
}
|
|
135
|
+
/** Keep layout settings persistent while each compiled MDX page owns its metadata. */
|
|
136
|
+
declare function DocsPageProvider({
|
|
137
|
+
children,
|
|
138
|
+
pageRoutes,
|
|
139
|
+
...props
|
|
140
|
+
}: DocsPageClientProps & {
|
|
141
|
+
pageRoutes: string[];
|
|
142
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
143
|
+
declare function DocsPageContentClient({
|
|
144
|
+
children,
|
|
145
|
+
pageMetadata,
|
|
146
|
+
readingTimeEnabled
|
|
147
|
+
}: {
|
|
148
|
+
children: ReactNode;
|
|
149
|
+
pageMetadata: DocsPageMetadata;
|
|
150
|
+
readingTimeEnabled: boolean;
|
|
151
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
135
152
|
declare function DocsPageClient({
|
|
136
153
|
pageMetadata,
|
|
137
154
|
tocEnabled,
|
|
@@ -204,4 +221,4 @@ declare function DocsPageClient({
|
|
|
204
221
|
children
|
|
205
222
|
}: DocsPageClientProps): react_jsx_runtime0.JSX.Element;
|
|
206
223
|
//#endregion
|
|
207
|
-
export { DocsPageClient };
|
|
224
|
+
export { DocsPageClient, DocsPageContentClient, DocsPageProvider };
|
|
@@ -8,7 +8,7 @@ import { resolveClientLocale, withLangInUrl } from "./i18n.mjs";
|
|
|
8
8
|
import { escapeJsonLdForScript } from "./json-ld.mjs";
|
|
9
9
|
import { renderPageStructuredData } from "./page-structured-data.mjs";
|
|
10
10
|
import { resolvePageMetadata } from "./page-metadata.mjs";
|
|
11
|
-
import { Children, Fragment, useEffect, useLayoutEffect, useState } from "react";
|
|
11
|
+
import { Children, Fragment, createContext, useContext, useEffect, useLayoutEffect, useMemo, useState } from "react";
|
|
12
12
|
import { DocsBody, DocsPage, EditOnGitHub } from "fumadocs-ui/layouts/docs/page";
|
|
13
13
|
import { createPortal } from "react-dom";
|
|
14
14
|
import { usePathname, useRouter } from "fumadocs-core/framework";
|
|
@@ -335,6 +335,39 @@ function findThreadlineTocActionsContainer() {
|
|
|
335
335
|
}
|
|
336
336
|
return toc.parentElement ?? toc;
|
|
337
337
|
}
|
|
338
|
+
const PageContext = createContext(null);
|
|
339
|
+
/** Keep layout settings persistent while each compiled MDX page owns its metadata. */
|
|
340
|
+
function DocsPageProvider({ children, pageRoutes, ...props }) {
|
|
341
|
+
const pathname = usePathname();
|
|
342
|
+
const route = (useWindowPathname() || pathname).replace(/\/$/, "") || "/";
|
|
343
|
+
const enabled = useMemo(() => new Set(pageRoutes), [pageRoutes]).has(route);
|
|
344
|
+
return /* @__PURE__ */ jsx(PageContext.Provider, {
|
|
345
|
+
value: {
|
|
346
|
+
props,
|
|
347
|
+
enabled
|
|
348
|
+
},
|
|
349
|
+
children: enabled ? children : /* @__PURE__ */ jsx(DocsPageClient, {
|
|
350
|
+
...props,
|
|
351
|
+
children
|
|
352
|
+
})
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function DocsPageContentClient({ children, pageMetadata, readingTimeEnabled }) {
|
|
356
|
+
const context = useContext(PageContext);
|
|
357
|
+
if (!context?.enabled) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
358
|
+
return /* @__PURE__ */ jsx(PageContext.Provider, {
|
|
359
|
+
value: {
|
|
360
|
+
...context,
|
|
361
|
+
enabled: false
|
|
362
|
+
},
|
|
363
|
+
children: /* @__PURE__ */ jsx(DocsPageClient, {
|
|
364
|
+
...context.props,
|
|
365
|
+
pageMetadata,
|
|
366
|
+
readingTimeEnabled,
|
|
367
|
+
children
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
}
|
|
338
371
|
function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, copyMarkdownFormat, copyMarkdownIncludeTitle, copyMarkdownLabel, copyMarkdownCopiedLabel, openDocs = false, viewMarkdown = false, openDocsProviders, openDocsTarget, openDocsPrompt, connectMcp, installSkills, pageActionsPosition = "below-title", pageActionsVariant = "buttons", pageActionsDescriptions, tocActions, tocAskAi = true, pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, githubEditUrl, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", previousPage, nextPage, titlePager = false, structuredDataMap, structuredDataPages, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedLabel = "Last updated", lastUpdatedPosition = "footer", llmsTxtEnabled = false, generatedTitleMap, generatedTitle, descriptionMap, description, descriptionInBody = false, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackRequireComment, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackSuccessMessage, feedbackErrorMessage, feedbackOnFeedback, analytics = false, telemetry, telemetryFramework, footer, children }) {
|
|
339
372
|
const router = useRouter();
|
|
340
373
|
const fdTocStyle = tocStyle === "directional" ? "clerk" : void 0;
|
|
@@ -928,4 +961,4 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
|
|
|
928
961
|
}
|
|
929
962
|
|
|
930
963
|
//#endregion
|
|
931
|
-
export { DocsPageClient };
|
|
964
|
+
export { DocsPageClient, DocsPageContentClient, DocsPageProvider };
|
package/dist/page-metadata.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* several overlapping maps for every prerendered page. Keep all routes so a
|
|
5
5
|
* persistent layout still has metadata after client navigation.
|
|
6
6
|
*/
|
|
7
|
-
function serializePageMetadata(maps) {
|
|
7
|
+
function serializePageMetadata(maps, excludeRoutes) {
|
|
8
8
|
const dates = [];
|
|
9
9
|
const dateIndexes = /* @__PURE__ */ new Map();
|
|
10
10
|
const dateIndex = (value) => {
|
|
@@ -17,6 +17,7 @@ function serializePageMetadata(maps) {
|
|
|
17
17
|
};
|
|
18
18
|
const pages = {};
|
|
19
19
|
for (const [route, page] of Object.entries(maps.structuredDataPages.pages)) {
|
|
20
|
+
if (excludeRoutes?.has(route)) continue;
|
|
20
21
|
const generatedTitle = maps.generatedTitleMap[route];
|
|
21
22
|
const description = maps.descriptionMap[route];
|
|
22
23
|
const row = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.142",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -141,7 +141,12 @@
|
|
|
141
141
|
"./threadline/css": "./styles/threadline.css",
|
|
142
142
|
"./presets/neutral": "./styles/presets/neutral.css",
|
|
143
143
|
"./presets/black": "./styles/presets/black.css",
|
|
144
|
-
"./presets/base": "./styles/presets/base.css"
|
|
144
|
+
"./presets/base": "./styles/presets/base.css",
|
|
145
|
+
"./internal/page": {
|
|
146
|
+
"types": "./dist/docs-layout.d.mts",
|
|
147
|
+
"import": "./dist/docs-layout.mjs",
|
|
148
|
+
"default": "./dist/docs-layout.mjs"
|
|
149
|
+
}
|
|
145
150
|
},
|
|
146
151
|
"dependencies": {
|
|
147
152
|
"fumadocs-core": "16.17.8",
|
|
@@ -162,13 +167,13 @@
|
|
|
162
167
|
"tsdown": "^0.20.3",
|
|
163
168
|
"typescript": "^5.9.3",
|
|
164
169
|
"vitest": "^4.1.8",
|
|
165
|
-
"@farming-labs/docs": "0.2.
|
|
170
|
+
"@farming-labs/docs": "0.2.142"
|
|
166
171
|
},
|
|
167
172
|
"peerDependencies": {
|
|
168
173
|
"next": ">=16.0.0",
|
|
169
174
|
"react": ">=19.2.0",
|
|
170
175
|
"react-dom": ">=19.2.0",
|
|
171
|
-
"@farming-labs/docs": "^0.2.
|
|
176
|
+
"@farming-labs/docs": "^0.2.142"
|
|
172
177
|
},
|
|
173
178
|
"peerDependenciesMeta": {
|
|
174
179
|
"next": {
|