@@ -10,6 +10,7 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/co
10
10
import { Tooltip , TooltipContent , TooltipProvider , TooltipTrigger } from ' @/components/ui/tooltip' ;
11
11
import UserMenuContent from ' @/components/UserMenuContent.vue' ;
12
12
import { getInitials } from ' @/composables/useInitials' ;
13
+ import { toUrl , urlIsActive } from ' @/lib/utils' ;
13
14
import { dashboard } from ' @/routes' ;
14
15
import type { BreadcrumbItem , NavItem } from ' @/types' ;
15
16
import { InertiaLinkProps , Link , usePage } from ' @inertiajs/vue3' ;
@@ -27,11 +28,11 @@ const props = withDefaults(defineProps<Props>(), {
27
28
const page = usePage ();
28
29
const auth = computed (() => page .props .auth );
29
30
30
- const isCurrentRoute = computed (() => (url : NonNullable <InertiaLinkProps [' href' ]>) => page . url === ( typeof url === ' string ' ? url : url .url ));
31
+ const isCurrentRoute = computed (() => (url : NonNullable <InertiaLinkProps [' href' ]>) => urlIsActive ( url , page .url ));
31
32
32
33
const activeItemStyles = computed (
33
34
() => (url : NonNullable <InertiaLinkProps [' href' ]>) =>
34
- isCurrentRoute .value (typeof url === ' string ' ? url : url . url ) ? ' text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100' : ' ' ,
35
+ isCurrentRoute .value (toUrl ( url ) ) ? ' text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100' : ' ' ,
35
36
);
36
37
37
38
const mainNavItems: NavItem [] = [
@@ -90,7 +91,7 @@ const rightNavItems: NavItem[] = [
90
91
<a
91
92
v-for =" item in rightNavItems"
92
93
:key =" item.title"
93
- :href =" typeof item.href === 'string' ? item.href : item.href?.url "
94
+ :href =" toUrl( item.href) "
94
95
target =" _blank"
95
96
rel =" noopener noreferrer"
96
97
class =" flex items-center space-x-2 text-sm font-medium"
@@ -141,11 +142,7 @@ const rightNavItems: NavItem[] = [
141
142
<Tooltip >
142
143
<TooltipTrigger >
143
144
<Button variant =" ghost" size =" icon" as-child class =" group h-9 w-9 cursor-pointer" >
144
- <a
145
- :href =" typeof item.href === 'string' ? item.href : item.href?.url"
146
- target =" _blank"
147
- rel =" noopener noreferrer"
148
- >
145
+ <a :href =" toUrl(item.href)" target =" _blank" rel =" noopener noreferrer" >
149
146
<span class =" sr-only" >{{ item.title }}</span >
150
147
<component :is =" item.icon" class =" size-5 opacity-80 group-hover:opacity-100" />
151
148
</a >
0 commit comments