-
Notifications
You must be signed in to change notification settings - Fork 129
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
[...all] match problem #273
Comments
|
@hannoer I upgraded the dependency, but the performance is still the same as before repro: https://github.com/Amorites/vite-plugin-pages-all-issue |
For v0.26.0, I noticed the const catchAllIndex = routes.findIndex((it) => it.name === 'all')
if (catchAllIndex !== routes.length - 1) {
routes.push(...routes.splice(catchAllIndex, 1))
} |
Hmm, after further testing, it seems children are not being sorted with dynamic routes last. So to fix it, I had to do the following in my Pages({
routeStyle: 'nuxt',
onRoutesGenerated(routes: Array<VueRoute>) {
function isCatchAll(route: VueRoute) {
return route.name === 'all'
}
function isDynamic(route: VueRoute) {
return route.path.includes(':')
}
function fixAll(routes: Array<VueRoute>) {
routes.sort((a, b) => {
if (isCatchAll(a)) {
return 1
}
if (isCatchAll(b)) {
return -1
}
const aDynamic = isDynamic(a)
const bDynamic = isDynamic(b)
if (aDynamic !== bDynamic) {
// Non-dynamic first
return aDynamic ? 1 : -1
}
const aSize = a.path.length
const bSize = b.path.length
if (aSize !== bSize) {
// Longest length first
return bSize - aSize
}
return a.path.localeCompare(b.path)
})
routes.forEach(fix)
}
function fix(route: VueRoute) {
if (route.children) {
fixAll(route.children)
}
}
fixAll(routes)
return routes
},
}) |
@achaphiv This is not releated to this issue, please open a new issue and provide a minimal reproduction. |
Describe the bug
I have file structure like:
localhost:5173/hi
is supposed to displaypages/hi/[...all].vue
but displaypages/[...all].vue
localhost:5173/hi/
andlocalhost:5173/hi/foo
works as expected.Not really sure this is a bug or feature, but
src/pages/[...all].vue -> /* (/non-existent-page)
described in the doc is a little bit ambiguous.Reproduction
https://github.com/Amorites/vite-plugin-pages-all-issue
System Info
System: OS: Linux 3.10 CentOS Linux 7 (Core) CPU: (12) x64 AMD EPYC 7702P 64-Core Processor Memory: 18.63 GB / 23.39 GB Container: Yes Shell: 5.8.1 - /usr/local/bin/zsh Binaries: Node: 16.16.0 - ~/n/bin/node npm: 6.14.4 - /usr/bin/npm
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: