posva / unplugin-vue-router

Next Generation file based typed routing for Vue Router
https://uvr.esm.is
MIT License
1.62k stars 79 forks source link

Invalid route path generated when trying to use `/pages/index.vue` as layout #442

Closed MellKam closed 2 months ago

MellKam commented 2 months ago

Hi! I want to create the layout for my dashboard, but I don't want to set path for it as in docs. I want it to start from root /. I came up with the following strucutre:

/src/pages/index.vue (layout)
/src/pages/index/servers/index.vue (alias to `/`, so it can be accessed as main page)
/src/pages/index/users/index.vue 

I also have other pages that dont need this layout, so I can't just move it all to App.vue

/src/pages/login/index.vue (doesn't need index layout)

Here is how it looks in code: https://stackblitz.com/edit/github-wfreqt-udvslk?file=typed-router.d.ts

Everything seems to be working just fine, but generated types are not exactly correct. For some reason another slash is inserted for pages with index layout image

I would like to know if there's a better way to structure this. Thanks for your work, awsome library ❤️

posva commented 2 months ago

Thanks, I'm glad you like it!

They type isn't wrong, that's the name given to the route. If you use it, it works. You can customize how names are set with getRouteName (https://uvr.esm.is/guide/configuration.html)