@rspress-theme-anatole/theme-default 0.7.42 → 0.7.44
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/bundle.js +18 -3
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -342,6 +342,11 @@ function normalizeRoleList(value) {
|
|
|
342
342
|
// Cache for user context fetched from userContext endpoint
|
|
343
343
|
let _cachedUserContext = null;
|
|
344
344
|
let _userContextFetchPromise = null;
|
|
345
|
+
let _userContextResolved = false;
|
|
346
|
+
|
|
347
|
+
function isUserContextResolved() {
|
|
348
|
+
return _userContextResolved;
|
|
349
|
+
}
|
|
345
350
|
|
|
346
351
|
function getUserContext() {
|
|
347
352
|
// Return cached user context if available
|
|
@@ -360,6 +365,7 @@ async function fetchUserContext(userContextUrl) {
|
|
|
360
365
|
if (!response.ok) {
|
|
361
366
|
console.warn('Failed to fetch user context:', response.status);
|
|
362
367
|
_cachedUserContext = { isAuthenticated: false, userId: null };
|
|
368
|
+
_userContextResolved = true;
|
|
363
369
|
return _cachedUserContext;
|
|
364
370
|
}
|
|
365
371
|
const data = await response.json();
|
|
@@ -367,6 +373,7 @@ async function fetchUserContext(userContextUrl) {
|
|
|
367
373
|
isAuthenticated: data?.isAuthenticated || false,
|
|
368
374
|
userId: data?.userId || null
|
|
369
375
|
};
|
|
376
|
+
_userContextResolved = true;
|
|
370
377
|
// Dispatch event to trigger sidebar re-render
|
|
371
378
|
if (typeof window !== 'undefined') {
|
|
372
379
|
window.dispatchEvent(new Event('UserContextReady'));
|
|
@@ -375,6 +382,7 @@ async function fetchUserContext(userContextUrl) {
|
|
|
375
382
|
} catch (e) {
|
|
376
383
|
console.warn('Error fetching user context:', e);
|
|
377
384
|
_cachedUserContext = { isAuthenticated: false, userId: null };
|
|
385
|
+
_userContextResolved = true;
|
|
378
386
|
return _cachedUserContext;
|
|
379
387
|
} finally {
|
|
380
388
|
_userContextFetchPromise = null;
|
|
@@ -420,6 +428,9 @@ function useSidebarData() {
|
|
|
420
428
|
const userContextUrl = siteData?.auth?.endpoints?.userContext;
|
|
421
429
|
if (userContextUrl) {
|
|
422
430
|
fetchUserContext(userContextUrl);
|
|
431
|
+
} else {
|
|
432
|
+
// No auth endpoint configured — mark as resolved immediately
|
|
433
|
+
_userContextResolved = true;
|
|
423
434
|
}
|
|
424
435
|
}, [siteData?.auth?.endpoints?.userContext]);
|
|
425
436
|
|
|
@@ -507,10 +518,14 @@ function getFirstAccessiblePage(items) {
|
|
|
507
518
|
function useRedirectToAccessiblePage() {
|
|
508
519
|
const { pathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
|
|
509
520
|
const navigate = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useNavigate)();
|
|
521
|
+
const { siteData } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)();
|
|
510
522
|
const items = useSidebarData();
|
|
523
|
+
const hasAuthEndpoint = !!siteData?.auth?.endpoints?.userContext;
|
|
511
524
|
|
|
512
525
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => {
|
|
513
526
|
if (!items || items.length === 0) return;
|
|
527
|
+
// If auth endpoint is configured, wait for user context to resolve before redirecting
|
|
528
|
+
if (hasAuthEndpoint && !isUserContextResolved()) return;
|
|
514
529
|
|
|
515
530
|
// Find current page in sidebar
|
|
516
531
|
const findCurrentPage = (items, targetPath) => {
|
|
@@ -6629,7 +6644,7 @@ function SearchPanel({ focused, setFocused }) {
|
|
|
6629
6644
|
}
|
|
6630
6645
|
};
|
|
6631
6646
|
const { siteData, page: { lang, version, frontmatter, routePath } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)();
|
|
6632
|
-
const { searchPlaceholderText = 'Search Docs' } = useLocaleSiteData();
|
|
6647
|
+
const { searchPlaceholderText = 'Search Docs', scopedSearchPrefixText = 'Search in' } = useLocaleSiteData();
|
|
6633
6648
|
const { search, title: siteTitle, base } = siteData;
|
|
6634
6649
|
const versionedSearch = search && 'remote' !== search.mode && search.versioned;
|
|
6635
6650
|
const DEFAULT_RESULT = [
|
|
@@ -7108,14 +7123,14 @@ function SearchPanel({ focused, setFocused }) {
|
|
|
7108
7123
|
if (!searchScope || !searchScope.scopeType) return searchPlaceholderText;
|
|
7109
7124
|
|
|
7110
7125
|
if (searchScope.scopeType === 'product') {
|
|
7111
|
-
return
|
|
7126
|
+
return `${scopedSearchPrefixText} ${searchScope.productName.toUpperCase()}...`;
|
|
7112
7127
|
}
|
|
7113
7128
|
if (searchScope.scopeType === 'solution') {
|
|
7114
7129
|
const formattedName = searchScope.solutionName
|
|
7115
7130
|
.split('-')
|
|
7116
7131
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
7117
7132
|
.join(' ');
|
|
7118
|
-
return
|
|
7133
|
+
return `${scopedSearchPrefixText} ${formattedName}...`;
|
|
7119
7134
|
}
|
|
7120
7135
|
return searchPlaceholderText;
|
|
7121
7136
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress-theme-anatole/theme-default",
|
|
3
3
|
"author": "Anatole Tong",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.44",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.css",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"types": "./dist/bundle.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@mdx-js/react": "2.3.0",
|
|
24
|
-
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.7.
|
|
25
|
-
"@rspress-theme-anatole/shared": "0.7.
|
|
24
|
+
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.7.44",
|
|
25
|
+
"@rspress-theme-anatole/shared": "0.7.44",
|
|
26
26
|
"@rspress/runtime": "1.43.8",
|
|
27
27
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
28
28
|
"copy-to-clipboard": "^3.3.3",
|