@@ -58,6 +58,11 @@ const rightNavItems: NavItem[] = [
58
58
icon: BookOpen ,
59
59
},
60
60
];
61
+
62
+ const getNavItemLink = (item : NavItem ,defaultValue : string = ' #' ) : string => {
63
+ if (! item .href ) return defaultValue ;
64
+ return item .type === ' route' ? route (item .href ): item .href ;
65
+ }
61
66
</script >
62
67
63
68
<template >
@@ -82,9 +87,9 @@ const rightNavItems: NavItem[] = [
82
87
<Link
83
88
v-for =" item in mainNavItems"
84
89
:key =" item.title"
85
- :href =" item.href "
90
+ :href =" getNavItemLink( item) "
86
91
class =" flex items-center gap-x-3 rounded-lg px-3 py-2 text-sm font-medium hover:bg-accent"
87
- :class =" activeItemStyles(item.href )"
92
+ :class =" activeItemStyles(getNavItemLink( item) )"
88
93
>
89
94
<component v-if =" item.icon" :is =" item.icon" class =" h-5 w-5" />
90
95
{{ item.title }}
@@ -94,7 +99,7 @@ const rightNavItems: NavItem[] = [
94
99
<a
95
100
v-for =" item in rightNavItems"
96
101
:key =" item.title"
97
- :href =" item.href "
102
+ :href =" getNavItemLink( item) "
98
103
target =" _blank"
99
104
rel =" noopener noreferrer"
100
105
class =" flex items-center space-x-2 text-sm font-medium"
@@ -117,16 +122,16 @@ const rightNavItems: NavItem[] = [
117
122
<NavigationMenu class =" ml-10 flex h-full items-stretch" >
118
123
<NavigationMenuList class =" flex h-full items-stretch space-x-2" >
119
124
<NavigationMenuItem v-for =" (item, index) in mainNavItems" :key =" index" class =" relative flex h-full items-center" >
120
- <Link :href =" item.href " >
125
+ <Link :href =" getNavItemLink( item) " >
121
126
<NavigationMenuLink
122
- :class =" [navigationMenuTriggerStyle(), activeItemStyles(item.href ), 'h-9 cursor-pointer px-3']"
127
+ :class =" [navigationMenuTriggerStyle(), activeItemStyles(getNavItemLink( item) ), 'h-9 cursor-pointer px-3']"
123
128
>
124
129
<component v-if =" item.icon" :is =" item.icon" class =" mr-2 h-4 w-4" />
125
130
{{ item.title }}
126
131
</NavigationMenuLink >
127
132
</Link >
128
133
<div
129
- v-if =" isCurrentRoute(item.href )"
134
+ v-if =" isCurrentRoute(getNavItemLink( item) )"
130
135
class =" absolute bottom-0 left-0 h-0.5 w-full translate-y-px bg-black dark:bg-white"
131
136
></div >
132
137
</NavigationMenuItem >
@@ -146,7 +151,7 @@ const rightNavItems: NavItem[] = [
146
151
<Tooltip >
147
152
<TooltipTrigger >
148
153
<Button variant =" ghost" size =" icon" as-child class =" group h-9 w-9 cursor-pointer" >
149
- <a :href =" item.href " target =" _blank" rel =" noopener noreferrer" >
154
+ <a :href =" getNavItemLink( item) " target =" _blank" rel =" noopener noreferrer" >
150
155
<span class =" sr-only" >{{ item.title }}</span >
151
156
<component :is =" item.icon" class =" size-5 opacity-80 group-hover:opacity-100" />
152
157
</a >
0 commit comments