Open dhruvkb opened 4 years ago
Hi @dhruvkb,
thank you for reporting, and yes, you're right, it doesn't work properly. I don't have many solutions in mind right now and I have to look at the core code to understand how the active class switch is made.
This could be related to the issue I'm having - prefixed urls seem to break $route.params
, e.g.: With a template/Help.vue
, accessing http://localhost:8080/help/faq
retains the params { "handle": "faq" }
with a prefixed url http://localhost:8080/sg/help/faq
the params are {}
.
I'm assuming Gridsome is using $route.params
to determine active class on g-links.
Describe the bug I have an app with two routes
/
and/about/
and two locales'en'
(default) and'hi'
. I am rewriting paths using theenablePathRewrite
flag set totrue
andrewriteDefaultLanguage
set to false. This yields the following 6 paths:/
/about/
/en/
/en/about/
/hi/
/hi/about/
The active class on the
g-link
s (which have theirto
prop set to'/'
and'/about/'
) only works on the unprefixed versions (0 and 1). In all other paths, theg-link
s are inactive.To Reproduce Steps to reproduce the behavior:
enablePathRewrite
totrue
andrewriteDefaultLanguage
tofalse
g-link
s are active as expectedg-link
s are inactiveExpected behavior
g-link
s should also be active on locale-prefixed URLs.Environment (please complete the following information):
Plugin configuration
Something I tried If I change the
to
prop on theg-link
s to$tp('to')
and$tp('/about/')
respectively, the active status works for routes 0, 1, 4 and 5 (but not 2 and 3, which I think is because ofrewriteDefaultLanguage
set tofalse
). Is there a way to redirect 2 and 3 to 0 and 1 respectively whenrewriteDefaultLanguage
is set tofalse
?