File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -5,31 +5,36 @@ const colorMode = useColorMode()
5
5
function onClick(val : string ) {
6
6
colorMode .preference = val
7
7
}
8
+
9
+ const route = useRoute ()
10
+ function isActive(path : string ) {
11
+ return route .path .startsWith (path )
12
+ }
8
13
</script >
9
14
10
15
<template >
11
16
<div class =" py-5 border-b dark:border-gray-800 font-semibold" >
12
17
<div class =" flex px-6 container max-w-5xl justify-between mx-auto items-baseline " >
13
18
<ul class =" flex items-baseline space-x-5" >
14
19
<li class =" text-base sm:text-2xl font-bold" >
15
- <NuxtLink to =" /" >
20
+ <NuxtLink to =" /" :class = " { underline: $route.path === '/' } " >
16
21
{{ navbarData.homeTitle }}
17
22
</NuxtLink >
18
23
</li >
19
24
</ul >
20
25
<ul class =" flex items-center space-x-3 sm:space-x-6 text-sm sm:text-lg" >
21
26
<li >
22
- <NuxtLink to =" /blogs" >
27
+ <NuxtLink to =" /blogs" :class = " { underline: isActive('/blogs') } " >
23
28
Blogs
24
29
</NuxtLink >
25
30
</li >
26
31
<li >
27
- <NuxtLink to =" /categories" >
32
+ <NuxtLink to =" /categories" :class = " { underline: isActive('/categories') } " >
28
33
Categories
29
34
</NuxtLink >
30
35
</li >
31
36
<li title =" About Me" >
32
- <NuxtLink to =" /about" aria-label =" About me" >
37
+ <NuxtLink to =" /about" aria-label =" About me" :class = " { underline: $route.path === '/about' } " >
33
38
About
34
39
</NuxtLink >
35
40
</li >
@@ -63,9 +68,3 @@ function onClick(val: string) {
63
68
</div >
64
69
</div >
65
70
</template >
66
-
67
- <style >
68
- .router-link-active .router-link-exact-active {
69
- @apply underline
70
- }
71
- </style >
You can’t perform that action at this time.
0 commit comments