@mdguggenbichler/slugbase-core 0.0.26 → 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
- const adminBaseFull = `${appBasePath || ''}/admin`;
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 === appBasePath ||
66
- pathname === appBasePath + '/' ||
67
- pathname === (appBasePath || '/');
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 = appBasePath || '/';
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: `${appBasePath || ''}/bookmarks`, label: t('bookmarks.title'), icon: Bookmark },
85
- { pathForLink: `${prefix}/folders`.replace(/\/+/g, '/') || '/folders', pathForActive: `${appBasePath || ''}/folders`, label: t('folders.title'), icon: Folder },
86
- { pathForLink: `${prefix}/tags`.replace(/\/+/g, '/') || '/tags', pathForActive: `${appBasePath || ''}/tags`, label: t('tags.title'), icon: Tag },
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 === (appBasePath || '/') ? isOverviewActive : pathname === item.pathForActive
110
+ item.pathForActive === rootActivePath ? isOverviewActive : pathname === item.pathForActive
108
111
  }
109
112
  tooltip={item.label}
110
113
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdguggenbichler/slugbase-core",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "SlugBase core: backend and frontend entrypoints for self-hosted and cloud apps",
5
5
  "type": "module",
6
6
  "exports": {