Skip to content

Commit 28eda99

Browse files
committed
fix: optionality of org
1 parent b08b19d commit 28eda99

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

app/components/Package/InstallScripts.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { getOutdatedTooltip, getVersionClass } from '~/utils/npm/outdated-dependencies'
3+
import type { RouteLocationRaw } from 'vue-router'
34
45
const props = defineProps<{
56
packageName: string
@@ -11,12 +12,26 @@ const props = defineProps<{
1112
}
1213
}>()
1314
14-
function getCodeLink(filePath: string): string {
15-
return `/code/${props.packageName}/v/${props.version}/${filePath}`
15+
function getCodeLink(filePath: string): RouteLocationRaw {
16+
const split = props.packageName.split('/')
17+
18+
console.log({ split })
19+
return {
20+
name: 'code',
21+
params: {
22+
org: split.length === 2 ? split[0] : null,
23+
packageName: split.length === 2 ? split[1]! : split[0]!,
24+
version: props.version,
25+
filePath: '',
26+
},
27+
}
1628
}
1729
1830
const scriptParts = computed(() => {
19-
const parts: Record<string, { prefix: string | null; filePath: string | null; link: string }> = {}
31+
const parts: Record<
32+
string,
33+
{ prefix: string | null; filePath: string | null; link: RouteLocationRaw }
34+
> = {}
2035
for (const scriptName of props.installScripts.scripts) {
2136
const content = props.installScripts.content?.[scriptName]
2237
if (!content) continue

app/pages/package-code/@[[org]]/[packageName]/v/[version]/[...filePath].vue renamed to app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import type {
77
88
definePageMeta({
99
name: 'code',
10-
path: '/package-code/@:org?/:packageName/v/:version/:filePath(.*)?',
10+
path: '/package-code/:org?/:packageName/v/:version/:filePath(.*)?',
1111
alias: [
12-
'/package/code/@:org?/:packageName/v/:version/:filePath(.*)?',
13-
'/code/@:org?/:packageName/v/:version/:filePath(.*)?',
12+
'/package/code/:org?/:packageName/v/:version/:filePath(.*)?',
13+
'/package/code/:packageName/v/:version/:filePath(.*)?',
14+
// '/code/@:org?/:packageName/v/:version/:filePath(.*)?',
1415
],
1516
})
1617
@@ -44,7 +45,7 @@ function getCodeUrl(args: {
4445
filePath?: string
4546
}): string {
4647
const base = args.org
47-
? `/package-code/@${args.org}/${args.packageName}/v/${args.version}`
48+
? `/package-code/${args.org}/${args.packageName}/v/${args.version}`
4849
: `/package-code/${args.packageName}/v/${args.version}`
4950
return args.filePath ? `${base}/${args.filePath}` : base
5051
}

app/pages/package/[[org]]/[name].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ const codeLink = computed((): RouteLocationRaw | null => {
525525
return {
526526
name: 'code',
527527
params: {
528-
org: split.length === 2 ? split[0]?.replace(/^@/, '') : undefined,
528+
org: split.length === 2 ? split[0] : undefined,
529529
packageName: split.length === 2 ? split[1]! : split[0]!,
530530
version: resolvedVersion.value,
531531
filePath: '',

0 commit comments

Comments
 (0)