@rspress-theme-anatole/theme-default 0.7.41 → 0.7.43
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 +26 -6
- 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) => {
|
|
@@ -3700,12 +3715,17 @@ function HomepageFeaturesTabs({ frontmatter, routePath }) {
|
|
|
3700
3715
|
}
|
|
3701
3716
|
|
|
3702
3717
|
function HomepageFaqs({ frontmatter, routePath }) {
|
|
3703
|
-
const tabs = frontmatter?.faqTabs
|
|
3704
|
-
const
|
|
3718
|
+
const tabs = frontmatter?.faqTabs;
|
|
3719
|
+
const allTabs = tabs?.tabItems || [];
|
|
3720
|
+
const [activeTab, setActiveTab] = __WEBPACK_EXTERNAL_MODULE_react__.useState(allTabs[0]?.title || '');
|
|
3705
3721
|
const [isExpanded, setIsExpanded] = __WEBPACK_EXTERNAL_MODULE_react__.useState(false);
|
|
3706
3722
|
const DEFAULT_VISIBLE_COUNT = 5;
|
|
3723
|
+
|
|
3724
|
+
if (!tabs || !allTabs.length) {
|
|
3725
|
+
return null;
|
|
3726
|
+
}
|
|
3707
3727
|
|
|
3708
|
-
const activeFaqs =
|
|
3728
|
+
const activeFaqs = allTabs.find(tab => tab.title === activeTab);
|
|
3709
3729
|
|
|
3710
3730
|
const handleTabClick = (title) => {
|
|
3711
3731
|
setActiveTab(title);
|
|
@@ -3782,13 +3802,13 @@ function HomepageFaqs({ frontmatter, routePath }) {
|
|
|
3782
3802
|
: [];
|
|
3783
3803
|
const hasMoreItems = activeFaqs && activeFaqs.items.length > DEFAULT_VISIBLE_COUNT;
|
|
3784
3804
|
|
|
3785
|
-
return
|
|
3805
|
+
return allTabs.length > 0 ? (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
3786
3806
|
className: "faqs-div",
|
|
3787
3807
|
children: [
|
|
3788
3808
|
// Tab menu
|
|
3789
3809
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
3790
3810
|
className: "faqs-tabs",
|
|
3791
|
-
children:
|
|
3811
|
+
children: allTabs.map((tab) =>
|
|
3792
3812
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
3793
3813
|
className: activeTab === tab.title ? "faqs-tab active" : "faqs-tab",
|
|
3794
3814
|
onClick: () => handleTabClick(tab.title),
|
|
@@ -3823,7 +3843,7 @@ function HomepageFaqs({ frontmatter, routePath }) {
|
|
|
3823
3843
|
gap: '6px',
|
|
3824
3844
|
},
|
|
3825
3845
|
children: [
|
|
3826
|
-
isExpanded ? "Show less" : "Show more",
|
|
3846
|
+
isExpanded ? (tabs.showLessText ?? "Show less") : (tabs.showMoreText ?? "Show more"),
|
|
3827
3847
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("i", {
|
|
3828
3848
|
className: isExpanded ? "fa-solid fa-chevron-up" : "fa-solid fa-chevron-down",
|
|
3829
3849
|
style: { fontSize: '20px' }
|
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.43",
|
|
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.43",
|
|
25
|
+
"@rspress-theme-anatole/shared": "0.7.43",
|
|
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",
|