@rspress-theme-anatole/theme-default 0.7.21 → 0.7.22-alpha1
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 +48 -2
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -334,11 +334,52 @@ function useLocaleSiteData() {
|
|
|
334
334
|
langRoutePrefix: lang === defaultLang ? '/' : (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addTrailingSlash)(lang)
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
|
+
function normalizeRoleList(value) {
|
|
338
|
+
if (!value) return [];
|
|
339
|
+
const list = Array.isArray(value) ? value : String(value).split(',');
|
|
340
|
+
return list.map((role) => String(role).trim().toLowerCase()).filter(Boolean);
|
|
341
|
+
}
|
|
342
|
+
function getUserRoles() {
|
|
343
|
+
if (typeof getUserFromStorage !== 'function') return [];
|
|
344
|
+
const user = getUserFromStorage();
|
|
345
|
+
const roles = user?.roles ?? user?.role ?? user?.groups ?? user?.group ?? [];
|
|
346
|
+
return normalizeRoleList(roles);
|
|
347
|
+
}
|
|
348
|
+
function hasRoleAccess(item, userRoles) {
|
|
349
|
+
const requiredRoles = normalizeRoleList(item?.roles);
|
|
350
|
+
if (!requiredRoles.length) return true;
|
|
351
|
+
if (!userRoles.length) return false;
|
|
352
|
+
return requiredRoles.some((role) => userRoles.includes(role));
|
|
353
|
+
}
|
|
354
|
+
function filterSidebarItems(items, userRoles) {
|
|
355
|
+
if (!Array.isArray(items)) return items;
|
|
356
|
+
return items.map((item) => {
|
|
357
|
+
if (!item) return null;
|
|
358
|
+
let nextItem = item;
|
|
359
|
+
if ('items' in item && Array.isArray(item.items)) {
|
|
360
|
+
const filteredItems = filterSidebarItems(item.items, userRoles);
|
|
361
|
+
if (filteredItems.length !== item.items.length) {
|
|
362
|
+
nextItem = {
|
|
363
|
+
...item,
|
|
364
|
+
items: filteredItems
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
if (!nextItem.link && filteredItems.length === 0 && !('dividerType' in nextItem) && !('sectionHeaderText' in nextItem)) {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return hasRoleAccess(nextItem, userRoles) ? nextItem : null;
|
|
372
|
+
}).filter(Boolean);
|
|
373
|
+
}
|
|
337
374
|
function useSidebarData() {
|
|
338
375
|
const { sidebar } = useLocaleSiteData();
|
|
339
376
|
const { pathname: rawPathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
|
|
340
377
|
const pathname = decodeURIComponent(rawPathname);
|
|
341
|
-
const sidebarData = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(() =>
|
|
378
|
+
const sidebarData = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(() => {
|
|
379
|
+
const data = getSidebarDataGroup(sidebar, pathname);
|
|
380
|
+
const userRoles = getUserRoles();
|
|
381
|
+
return filterSidebarItems(data, userRoles);
|
|
382
|
+
}, [
|
|
342
383
|
sidebar,
|
|
343
384
|
pathname
|
|
344
385
|
]);
|
|
@@ -4661,6 +4702,7 @@ function parseKBGatewayUserContext(cookieValue) {
|
|
|
4661
4702
|
return {
|
|
4662
4703
|
username: username,
|
|
4663
4704
|
email: parsed.email || null,
|
|
4705
|
+
roles: parsed.roles || parsed.role || parsed.groups || parsed.group || null,
|
|
4664
4706
|
avatar: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAYCAYAAAAPtVbGAAAAAXNSR0IArs4c6QAAAsJJREFUSEullU1IFHEYxp9ndpc+KHLzAyyDIIjO+TEzqWDtbFYXK/Bi0Cm61Ck6iEFsFEhFtyKiY2SBh0AIyZ1VQ2P/q3hMKIgOkUJahgRG6+4bo7kfzs7OSnPb+b/v8/s/78csscVHLP0T7dShUmkSNa5BoCMTvMexyZmNGG6FIRE9CnIElE7GUyMbuXLSPIKsvAegFeh9pa0anN9bg0SNHxCEQSwhrqoJiDgalpH1uOwAbXWhYohEmpvBwFReTEzaKSXRliaINu1VEdqKlUPWb1sYL7SVJifMFmiS+m+IWGYPIM9dQtQuomr/AJa+rHpAhmirroqciNtFTtMph0T04yBHi0H8iXBDDQcHM74QscxeQPo9p1DYx0Sy/98AvATQCOABbfW44hEWy3BKESgz6hnaKlhuFco6Ecu4A+CG7y4J7jKhej2b73UgjY0hhEMrPi420jOYW97J2dk/pfQ8nUjUvAWRm74ucoXnbcaTJeNLQny22JtrqwAB1/aXhkTMh6BcqdhF3s0jxpNXN+e5INLdHSixXI65Z9DQj2PJj3jXehTI9EFwznWR8IGgsxuF790Qy3gN4ExB0AraTu1iLOYqg7S27saOzHcAofx2YphxVZhf/BWWGDRMru1FHh6SPRxOLXtOYYdxEEF8LjgXtKkgY/neFDkRS58G2JRLELxiQp33641YxgcAhwvyZphQOZ0cRE631yKd/lYkGEjv45uZeX+I3gZwoiguFKrj8MSC8y4PsYwxAB1FgZKtYWLKqXnZRzrb65FJz20KektbremtQSTSUg1qiy4lTZo4ksr9V3v2JWpcguCp63x1ey3HxxfXIZaRBGC4gsgFxpN1vk4sw/mc5Ccsn6BoK5NytqMKv34veQoRXYyrIU8XEf0yyCee+duCeymWPgewvuxts+zhaPLF5hixzOuA3Pfp2PxfA8n5ENhQazEAAAAASUVORK5CYII="
|
|
4665
4707
|
};
|
|
4666
4708
|
} catch (e) {
|
|
@@ -4678,6 +4720,7 @@ function parseKBGatewayUserContext(cookieValue) {
|
|
|
4678
4720
|
return {
|
|
4679
4721
|
username: username,
|
|
4680
4722
|
email: parsed.email || null,
|
|
4723
|
+
roles: parsed.roles || parsed.role || parsed.groups || parsed.group || null,
|
|
4681
4724
|
avatar: parsed.Avatar || parsed.avatar || null
|
|
4682
4725
|
};
|
|
4683
4726
|
} catch (e2) {
|
|
@@ -4744,7 +4787,7 @@ function UserAuth() {
|
|
|
4744
4787
|
const showSignInButton = siteData?.auth?.showSignInButton !== false;
|
|
4745
4788
|
|
|
4746
4789
|
// Get sign in URL from site config
|
|
4747
|
-
const signInUrl = siteData?.auth?.
|
|
4790
|
+
const signInUrl = siteData?.auth?.endpoints?.signIn;
|
|
4748
4791
|
|
|
4749
4792
|
// Cookie name for KBGateway
|
|
4750
4793
|
const KB_COOKIE_NAME = 'KBGateway-User-Context';
|
|
@@ -6600,11 +6643,14 @@ function loadGiscus() {
|
|
|
6600
6643
|
script.src = 'https://giscus.app/client.js';
|
|
6601
6644
|
|
|
6602
6645
|
// script.setAttribute('data-repo', 'anatole-tong-avepoint/rspress-theme-anatole');
|
|
6646
|
+
// script.setAttribute('data-repo', 'avepoint-copilot-enterprise/aprm-server');
|
|
6603
6647
|
script.setAttribute('data-repo', 'AvePoint/wiki-comments');
|
|
6604
6648
|
// script.setAttribute('data-repo-id', 'R_kgDOO69M6A');
|
|
6649
|
+
// script.setAttribute('data-repo-id', 'R_kgDOPr00TQ');
|
|
6605
6650
|
script.setAttribute('data-repo-id', 'R_kgDOO8WYwg');
|
|
6606
6651
|
script.setAttribute('data-category', 'Announcements');
|
|
6607
6652
|
// script.setAttribute('data-category-id', 'DIC_kwDOO69M6M4CrcUp');
|
|
6653
|
+
// script.setAttribute('data-category-id', 'DIC_kwDOPr00Tc4Cv1Li');
|
|
6608
6654
|
script.setAttribute('data-category-id', 'DIC_kwDOO8WYws4CrjjN');
|
|
6609
6655
|
script.setAttribute('data-mapping', 'pathname');
|
|
6610
6656
|
script.setAttribute('data-reactions-enabled', '1');
|
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.22-alpha1",
|
|
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.22-alpha1",
|
|
25
|
+
"@rspress-theme-anatole/shared": "0.7.22-alpha1",
|
|
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",
|