Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should be possible to set route name to undefined #530

Open
ricardo17coelho opened this issue Oct 30, 2024 · 2 comments
Open

Should be possible to set route name to undefined #530

ricardo17coelho opened this issue Oct 30, 2024 · 2 comments

Comments

@ricardo17coelho
Copy link

In order to match this case: https://router.vuejs.org/guide/essentials/nested-routes.html#Nested-Named-Routes
Where the parent route name should not be defined, it should be possible to defined the route name as undefined

definePage({
....
name: undefined,
....
});

This works but theres is an warning in the console & should be the case:
⚠️ [unplugin-vue-router]: route name must be a string literal. Found in "/path/file_01.vue".
⚠️ [unplugin-vue-router]: route name must be a string literal. Found in "/path/file_02.vue".
⚠️ [unplugin-vue-router]: route name must be a string literal. Found in "/path/file_03.vue".

i "reported" this as well here: https://discord.com/channels/325477692906536972/325479452773580800/1298912972734992405
but no reactions so far..

@posva
Copy link
Owner

posva commented Oct 30, 2024

Why are you trying to remove the name from the page? Is this just a convenience thing?
Right now you can achieve this by extending the routs.

@ricardo17coelho
Copy link
Author

Hi @posva 😀

From my original question on discord:

I've a project where we're using unplugin-vue-router but i'm struggling to create a "breadcrumbs" component based on the router "matched" array.
Basically, when i'm in a nested route & i navigate to a "parent" ( which has a kind of "layout" => like the users.vue ( outside of the "users" directory)) ... it's navigating to the "users.vue" instead of navigating to the /users/index.vue wich normally should be the default "children" route of "users".
The strange thing for me is:
If i'm in the route /users and i navigate to /users/profile, then click on the breadcrum "users", everything is fine
If i'm in the router /users/profile and i reload the page ( starting the navigation from there ) & then click on the breadcrumb "users", i only the see the layout "users.vue" instead of the default page /users/index.vue
i'm trying to understand why the issue happens but still not understand 🤔

maybe i'm doing something wrongly. But removing the parent route name works.

2024-10-24_09-33-04_1

Repo: https://github.com/ricardo17coelho/vue-router-unplugin-breadcrumbs
StackBlitz Playground: https://stackblitz.com/~/github.com/ricardo17coelho/vue-router-unplugin-breadcrumbs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants