@farming-labs/theme 0.2.48 → 0.2.49
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/client-location.mjs
CHANGED
|
@@ -30,14 +30,21 @@ function subscribe(onStoreChange) {
|
|
|
30
30
|
window.removeEventListener("fd-location-change", notify);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function getSearchSnapshot() {
|
|
34
34
|
if (typeof window === "undefined") return "";
|
|
35
35
|
return window.location.search;
|
|
36
36
|
}
|
|
37
|
+
function getPathnameSnapshot() {
|
|
38
|
+
if (typeof window === "undefined") return "";
|
|
39
|
+
return window.location.pathname;
|
|
40
|
+
}
|
|
37
41
|
function useWindowSearchParams() {
|
|
38
|
-
const search = useSyncExternalStore(subscribe,
|
|
42
|
+
const search = useSyncExternalStore(subscribe, getSearchSnapshot, () => "");
|
|
39
43
|
return new URLSearchParams(search);
|
|
40
44
|
}
|
|
45
|
+
function useWindowPathname() {
|
|
46
|
+
return useSyncExternalStore(subscribe, getPathnameSnapshot, () => "");
|
|
47
|
+
}
|
|
41
48
|
|
|
42
49
|
//#endregion
|
|
43
|
-
export { useWindowSearchParams };
|
|
50
|
+
export { useWindowPathname, useWindowSearchParams };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { emitClientAnalyticsEvent } from "./client-analytics.mjs";
|
|
4
4
|
import { PageActions } from "./page-actions.mjs";
|
|
5
|
-
import { useWindowSearchParams } from "./client-location.mjs";
|
|
5
|
+
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";
|
|
@@ -261,13 +261,15 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
261
261
|
const [titlePortalHost, setTitlePortalHost] = useState(null);
|
|
262
262
|
const [titleControlsPortalHost, setTitleControlsPortalHost] = useState(null);
|
|
263
263
|
const [tocActionsPortalHost, setTocActionsPortalHost] = useState(null);
|
|
264
|
-
const [browserPath, setBrowserPath] = useState(null);
|
|
265
264
|
const pathname = usePathname();
|
|
266
|
-
const
|
|
265
|
+
const browserPathname = useWindowPathname();
|
|
266
|
+
const searchParams = useWindowSearchParams();
|
|
267
|
+
const browserSearch = searchParams.toString();
|
|
268
|
+
const activeLocale = resolveClientLocale(searchParams, locale);
|
|
267
269
|
const resolvedPublicPath = normalizePublicDocsPath(publicPath, entry);
|
|
268
270
|
const llmsLangQuery = activeLocale ? `?lang=${encodeURIComponent(activeLocale)}` : "";
|
|
269
271
|
const pageDescription = description ?? descriptionMap?.[pathname.replace(/\/$/, "") || "/"];
|
|
270
|
-
const normalizedPath = (
|
|
272
|
+
const normalizedPath = (browserPathname || pathname).replace(/\/$/, "") || "/";
|
|
271
273
|
const isChangelogRoute = !!(changelogBasePath && (normalizedPath === changelogBasePath || normalizedPath.startsWith(`${changelogBasePath}/`)));
|
|
272
274
|
const matchedReadingTime = readingTimeMap?.[normalizedPath];
|
|
273
275
|
const structuredDataJson = !isChangelogRoute ? structuredDataProp ?? structuredDataMap?.[normalizedPath] : void 0;
|
|
@@ -280,12 +282,14 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
280
282
|
properties: {
|
|
281
283
|
entry,
|
|
282
284
|
pathname: normalizedPath,
|
|
285
|
+
search: browserSearch,
|
|
283
286
|
isChangelogRoute
|
|
284
287
|
}
|
|
285
288
|
});
|
|
286
289
|
}, [
|
|
287
290
|
analytics,
|
|
288
291
|
activeLocale,
|
|
292
|
+
browserSearch,
|
|
289
293
|
entry,
|
|
290
294
|
isChangelogRoute,
|
|
291
295
|
normalizedPath
|
|
@@ -322,15 +326,12 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
322
326
|
return () => cancelAnimationFrame(timer);
|
|
323
327
|
}, [
|
|
324
328
|
activeLocale,
|
|
325
|
-
|
|
329
|
+
browserPathname,
|
|
326
330
|
children,
|
|
327
331
|
entry,
|
|
328
332
|
pathname,
|
|
329
333
|
resolvedPublicPath
|
|
330
334
|
]);
|
|
331
|
-
useEffect(() => {
|
|
332
|
-
setBrowserPath(window.location.pathname);
|
|
333
|
-
}, [pathname]);
|
|
334
335
|
useEffect(() => {
|
|
335
336
|
const root = document.documentElement;
|
|
336
337
|
if (isChangelogRoute) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.49",
|
|
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.49"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"@farming-labs/docs": ">=0.0.1",
|