@mdguggenbichler/slugbase-core 0.0.27 → 0.0.28
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.
|
@@ -46,7 +46,9 @@ export default function AppSidebar({ user, version = null }: AppSidebarProps) {
|
|
|
46
46
|
const { appBasePath, pathPrefixForLinks, hideAdminOidcAndSmtp } = useAppConfig();
|
|
47
47
|
const { setOpenMobile, toggleSidebar, isMobile, state } = useSidebar();
|
|
48
48
|
const prefix = pathPrefixForLinks || '';
|
|
49
|
-
|
|
49
|
+
// For active matching use pathPrefixForLinks so it matches useLocation().pathname (e.g. when Router has basename="/app", pathname is "/bookmarks" not "/app/bookmarks").
|
|
50
|
+
const pathBaseForActive = pathPrefixForLinks ?? appBasePath ?? '';
|
|
51
|
+
const adminBaseFull = `${pathBaseForActive}/admin`.replace(/\/+/g, '/') || '/admin';
|
|
50
52
|
const adminBaseLink = `${prefix}/admin`.replace(/\/+/g, '/') || '/admin';
|
|
51
53
|
|
|
52
54
|
const adminNavItems = [
|
|
@@ -61,10 +63,11 @@ export default function AppSidebar({ user, version = null }: AppSidebarProps) {
|
|
|
61
63
|
{ pathForLink: `${adminBaseLink}/ai`, pathForActive: `${adminBaseFull}/ai`, label: t('admin.ai.nav'), icon: Sparkles },
|
|
62
64
|
];
|
|
63
65
|
|
|
66
|
+
const rootActivePath = pathBaseForActive || '/';
|
|
64
67
|
const isOverviewActive =
|
|
65
|
-
pathname ===
|
|
66
|
-
pathname ===
|
|
67
|
-
pathname === (
|
|
68
|
+
pathname === rootActivePath ||
|
|
69
|
+
pathname === rootActivePath + '/' ||
|
|
70
|
+
pathname === (pathBaseForActive || '/');
|
|
68
71
|
|
|
69
72
|
const showAdmin = user?.is_admin;
|
|
70
73
|
const [adminOpen, setAdminOpen] = useState(() => {
|
|
@@ -78,12 +81,12 @@ export default function AppSidebar({ user, version = null }: AppSidebarProps) {
|
|
|
78
81
|
}, [adminOpen]);
|
|
79
82
|
|
|
80
83
|
const rootLink = prefix || '/';
|
|
81
|
-
const rootActive =
|
|
84
|
+
const rootActive = rootActivePath;
|
|
82
85
|
const primaryNavItems = [
|
|
83
86
|
{ pathForLink: rootLink, pathForActive: rootActive, label: t('dashboard.overview'), icon: LayoutDashboard },
|
|
84
|
-
{ pathForLink: `${prefix}/bookmarks`.replace(/\/+/g, '/') || '/bookmarks', pathForActive: `${
|
|
85
|
-
{ pathForLink: `${prefix}/folders`.replace(/\/+/g, '/') || '/folders', pathForActive: `${
|
|
86
|
-
{ pathForLink: `${prefix}/tags`.replace(/\/+/g, '/') || '/tags', pathForActive: `${
|
|
87
|
+
{ pathForLink: `${prefix}/bookmarks`.replace(/\/+/g, '/') || '/bookmarks', pathForActive: `${pathBaseForActive}/bookmarks`.replace(/\/+/g, '/') || '/bookmarks', label: t('bookmarks.title'), icon: Bookmark },
|
|
88
|
+
{ pathForLink: `${prefix}/folders`.replace(/\/+/g, '/') || '/folders', pathForActive: `${pathBaseForActive}/folders`.replace(/\/+/g, '/') || '/folders', label: t('folders.title'), icon: Folder },
|
|
89
|
+
{ pathForLink: `${prefix}/tags`.replace(/\/+/g, '/') || '/tags', pathForActive: `${pathBaseForActive}/tags`.replace(/\/+/g, '/') || '/tags', label: t('tags.title'), icon: Tag },
|
|
87
90
|
];
|
|
88
91
|
|
|
89
92
|
const handleNavClick = () => {
|
|
@@ -104,7 +107,7 @@ export default function AppSidebar({ user, version = null }: AppSidebarProps) {
|
|
|
104
107
|
<SidebarMenuButton
|
|
105
108
|
asChild
|
|
106
109
|
isActive={
|
|
107
|
-
item.pathForActive ===
|
|
110
|
+
item.pathForActive === rootActivePath ? isOverviewActive : pathname === item.pathForActive
|
|
108
111
|
}
|
|
109
112
|
tooltip={item.label}
|
|
110
113
|
>
|