Best way to match to the current "parent route" #100
Closed
thunfisch987
started this conversation in
General
Replies: 4 comments
-
I also just saw that there's experimental support for typed pages in nuxt via unplugin-vue-router 🧐 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm gonna try the pages:extend hook to add a property to every route |
Beta Was this translation helpful? Give feedback.
0 replies
-
Nevermind, can i do that with definePageMeta? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I did it with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
In my project i'm matching the route name to a string to display a specific icon for the current route, but there's only one icon per "main route" / folder.
Example:
In this example there would be one icon for
index.vue
, one forsubroute/
and one forsubroute2
.With only
index.vue
,subroute/index.vue
andsubroute2/index.vue
i would use:route.name === 'index'
,route.name === subroute
androute.name === 'subroute2'
But this becomes trickier when not only having index.vue and also sub-sub-folders...
I'm currently using
.split(-)[0]
for that but this way seems very impractical to me...Is there any way i could use nuxt-typed-router and extend it (or something like that) to also have an option to get the "parent route"?
Or extend the router in general?
Or do you have any other ideas?
[NuxtLink for example has the css classes
nuxt-link-active
andnuxt-link-exact-active
(you can also set these to different classes) where i.e.<NuxtLink :to={name: 'subroute-about'} />
would have the css class
nuxt-link-active
when visitingsubroute/
and have the css classnuxt-link-exact-active
when visitingsubroute/about(.vue)
]Beta Was this translation helpful? Give feedback.
All reactions