Skip to content

Commit 2ba55bc

Browse files
committed
fix: code and docs edge cases and infinte package load
1 parent d9df4fb commit 2ba55bc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app/pages/package-code/[...path].vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { formatBytes } from '~/utils/formatters'
88
99
definePageMeta({
1010
name: 'code',
11-
alias: ['/package/code/:path(.*)*', '/code/:path(.*)*'],
11+
// Both alias paths need to be (.+) so that they don't match the package page alias.
12+
alias: ['/package/code/:path(.+)', '/code/:path(.+)'],
1213
})
1314
1415
const route = useRoute('code')
@@ -19,7 +20,8 @@ const route = useRoute('code')
1920
// /code/nuxt/v/4.2.0/src/index.ts → packageName: "nuxt", version: "4.2.0", filePath: "src/index.ts"
2021
// /code/@nuxt/kit/v/1.0.0 → packageName: "@nuxt/kit", version: "1.0.0", filePath: null
2122
const parsedRoute = computed(() => {
22-
const segments = route.params.path || []
23+
const path = route.params.path
24+
const segments = typeof path === 'string' ? (path as string).split('/') : path || []
2325
2426
// Find the /v/ separator for version
2527
const vIndex = segments.indexOf('v')

app/pages/package-docs/[...path].vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { assertValidPackageName } from '#shared/utils/npm'
55
66
definePageMeta({
77
name: 'docs',
8-
alias: ['/package/docs/:path(.*)*', '/docs/:path(.*)*'],
8+
// Both alias paths need to be (.+) so that they don't match the package page alias.
9+
alias: ['/package/docs/:path(.+)', '/docs/:path(.+)'],
910
})
1011
1112
const route = useRoute('docs')
1213
const router = useRouter()
1314
1415
const parsedRoute = computed(() => {
15-
const segments = route.params.path || []
16+
const path = route.params.path
17+
const segments = typeof path === 'string' ? (path as string).split('/') : path || []
1618
const vIndex = segments.indexOf('v')
1719
1820
if (vIndex === -1 || vIndex >= segments.length - 1) {

0 commit comments

Comments
 (0)