daaru00 / gridsome-plugin-i18n

Gridsome plugin for i18n
MIT License
53 stars 12 forks source link

Warning from vue-router: Duplicate named routes definition for 404 route #3

Closed cfecherolle closed 4 years ago

cfecherolle commented 4 years ago

Hello!

As I'm now using your plugin in my personal project, I have a question regarding a router-related warning showing up in the console when I'm working with gridsome develop :

image

I think this message is due to the internal workflow of the plugin (creating 2 different 404 routes, one for each of the two languages I have set), have you ever encountered this message? If so, how could we fix the routing and/or the warning about the 404 route?

Thanks in advance! :smile:

Cécile

daaru00 commented 4 years ago

Hi @cfecherolle

yep, it seems there are a strange behaviour coming from Gridsome core plugin

if (/\/404\/?/.test(options.path)) {
  options.name = NOT_FOUND_NAME
}

it set a fixed name '404' to all routes that contain string /404/, here the regex test. Don't know if it should be reported also Gridsome core repo, maybe some /path/with/404/innocently/inside/ can trigger the same warning.

However, I create a similar plugin's hook and rewrite 404 routes name including locale code into name (commit) and deployed a new version v1.1.1.

Try to update this module to latest version to check if warning disappear:

$ npm update gridsome-plugin-i18n

Thank you so much for reporting it! I foolishly left the console warnings off and I didn't notice it :sweat_smile:

Fabio

cfecherolle commented 4 years ago

Perfect! I upgraded and the warnings disappeared :smile: :tada: That's some weird behaviour for Gridsome core plugin, indeed.

I'll keep reporting stuff I find for the i18n plugin, but I would also like to help (if you need any) and not just "report and wait for things to magically happen" :laughing:

Anyway, thanks!

daaru00 commented 4 years ago

I'll keep reporting stuff I find for the i18n plugin, but I would also like to help (if you need any) and not just "report and wait for things to magically happen"

Really happy to hear this! I've just added a contributing guide to help to setup a development environment to be able to see and touch the code easily.

Any help is always really appreciated, thank you!