@farming-labs/theme 0.2.41 → 0.2.42
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.
|
@@ -18,18 +18,29 @@ function useWindowHook(key, handler) {
|
|
|
18
18
|
};
|
|
19
19
|
}, [handler, key]);
|
|
20
20
|
}
|
|
21
|
+
function isAnalyticsDisabled(analytics) {
|
|
22
|
+
return analytics === false || analytics && typeof analytics === "object" && analytics.enabled === false;
|
|
23
|
+
}
|
|
21
24
|
function isDocsClientAnalyticsEnabled(analytics) {
|
|
25
|
+
if (isAnalyticsDisabled(analytics)) return false;
|
|
22
26
|
return resolveDocsAnalyticsConfig(analytics).enabled;
|
|
23
27
|
}
|
|
28
|
+
function callAnalyticsHandler(handler, event) {
|
|
29
|
+
if (!handler) return;
|
|
30
|
+
try {
|
|
31
|
+
Promise.resolve(handler(event)).catch(() => {});
|
|
32
|
+
} catch {}
|
|
33
|
+
}
|
|
24
34
|
function useAnalyticsHook(analytics) {
|
|
25
35
|
useEffect(() => {
|
|
26
36
|
if (typeof window === "undefined") return;
|
|
27
37
|
if (!isDocsClientAnalyticsEnabled(analytics)) return;
|
|
28
38
|
const target = window;
|
|
39
|
+
const previous = target.__fdAnalytics__;
|
|
29
40
|
const handler = (event) => {
|
|
30
|
-
|
|
41
|
+
callAnalyticsHandler(previous, event);
|
|
42
|
+
emitDocsAnalyticsEvent(analytics, event).catch(() => {});
|
|
31
43
|
};
|
|
32
|
-
const previous = target.__fdAnalytics__;
|
|
33
44
|
target.__fdAnalytics__ = handler;
|
|
34
45
|
const queued = target.__fdAnalyticsQueue__ ?? [];
|
|
35
46
|
delete target.__fdAnalyticsQueue__;
|
|
@@ -505,10 +505,12 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
505
505
|
setTitlePortalHost(null);
|
|
506
506
|
};
|
|
507
507
|
}, [needsTitleDecorationsPortal, pathname]);
|
|
508
|
-
const
|
|
508
|
+
const titleDecorations = needsTitleDecorationsPortal ? /* @__PURE__ */ jsx(TitleDecorations, {
|
|
509
509
|
description: titleDescription,
|
|
510
510
|
belowTitle: belowTitleBlock
|
|
511
|
-
})
|
|
511
|
+
}) : null;
|
|
512
|
+
const titleDecorationsPortal = titleDecorations && titlePortalHost ? createPortal(titleDecorations, titlePortalHost, "title-decorations") : null;
|
|
513
|
+
const titleDecorationsFallback = titleDecorations && !titlePortalHost ? titleDecorations : null;
|
|
512
514
|
const titleControlsPortal = showActionsInToc && titleControlsPortalHost ? createPortal(/* @__PURE__ */ jsx(ThreadlinePageControls, {}), titleControlsPortalHost, "title-controls") : null;
|
|
513
515
|
const tocActionsPortal = showActionsInToc && tocActionsPortalHost ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
514
516
|
className: "fd-actions-toc-portal not-prose",
|
|
@@ -596,6 +598,7 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
596
598
|
style: { flex: 1 },
|
|
597
599
|
children: renderedChildren
|
|
598
600
|
}, "content"),
|
|
601
|
+
titleDecorationsFallback,
|
|
599
602
|
titleDecorationsPortal,
|
|
600
603
|
!isChangelogRoute && feedbackEnabled && /* @__PURE__ */ jsx(DocsFeedback, {
|
|
601
604
|
pathname: normalizedPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.42",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"tsdown": "^0.20.3",
|
|
147
147
|
"typescript": "^5.9.3",
|
|
148
148
|
"vitest": "^4.1.8",
|
|
149
|
-
"@farming-labs/docs": "0.2.
|
|
149
|
+
"@farming-labs/docs": "0.2.42"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"@farming-labs/docs": ">=0.0.1",
|