Skip to content

Commit d8b3f68

Browse files
committed
fix: generate full paths for nested routes
1 parent 34f9ac6 commit d8b3f68

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@nuxt/kit": "^3.0.0-rc.4",
5959
"pathe": "^0.3.0",
6060
"std-env": "^3.1.1",
61+
"ufo": "^0.8.4",
6162
"unimport": "^0.2.9"
6263
},
6364
"devDependencies": {

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
addPlugin,
88
installModule,
99
} from '@nuxt/kit'
10+
import { joinURL } from 'ufo'
1011
import type { NuxtPage } from '@nuxt/schema'
1112
import { provider } from 'std-env'
1213

@@ -140,14 +141,13 @@ export default defineNuxtModule<ModuleOptions>({
140141

141142
nuxt.hook('pages:extend', pages => {
142143
routes.length = 0
143-
function processPages(pages: NuxtPage[]) {
144+
function processPages(pages: NuxtPage[], currentPath = '') {
144145
for (const page of pages) {
145-
if (!page.path.includes(':')) {
146-
routes.push(page.path)
147-
}
148-
if (page.children) {
149-
processPages(page.children)
150-
}
146+
if (page.path.includes(':')) continue
147+
148+
const path = joinURL(currentPath, page.path)
149+
routes.push(path)
150+
if (page.children) processPages(page.children, path)
151151
}
152152
}
153153
processPages(pages)

0 commit comments

Comments
 (0)