|
1 | 1 | <script setup lang="ts"> |
2 | | -import type { JsrPackageInfo } from '#shared/types/jsr' |
3 | | -import type { IconClass } from '~/types' |
4 | 2 | import { assertValidPackageName } from '#shared/utils/npm' |
5 | | -import { areUrlsEquivalent } from '#shared/utils/url' |
6 | 3 | import { getDependencyCount } from '~/utils/npm/dependency-count' |
7 | | -import { detectPublishSecurityDowngradeForVersion } from '~/utils/publish-security' |
8 | | -import { useInstallSizeDiff } from '~/composables/useInstallSizeDiff' |
9 | | -import { useViewOnGitProvider } from '~/composables/useViewOnGitProvider' |
10 | 4 |
|
11 | 5 | defineOgImageComponent('Package', { |
12 | 6 | name: () => packageName.value, |
@@ -390,50 +384,10 @@ const totalDepsCount = computed(() => { |
390 | 384 |
|
391 | 385 | const { repositoryUrl } = useRepositoryUrl(displayVersion) |
392 | 386 |
|
393 | | -const { meta: repoMeta, repoRef, stars, starsLink, forks, forksLink } = useRepoMeta(repositoryUrl) |
394 | | -
|
395 | | -const PROVIDER_ICONS: Record<string, IconClass> = { |
396 | | - github: 'i-simple-icons:github', |
397 | | - gitlab: 'i-simple-icons:gitlab', |
398 | | - bitbucket: 'i-simple-icons:bitbucket', |
399 | | - codeberg: 'i-simple-icons:codeberg', |
400 | | - gitea: 'i-simple-icons:gitea', |
401 | | - forgejo: 'i-simple-icons:forgejo', |
402 | | - gitee: 'i-simple-icons:gitee', |
403 | | - sourcehut: 'i-simple-icons:sourcehut', |
404 | | - tangled: 'i-custom:tangled', |
405 | | - radicle: 'i-lucide:network', // Radicle is a P2P network, using network icon |
406 | | -} |
407 | | -
|
408 | | -const repoProviderIcon = computed((): IconClass => { |
409 | | - const provider = repoRef.value?.provider |
410 | | - if (!provider) return 'i-simple-icons:github' |
411 | | - return PROVIDER_ICONS[provider] ?? 'i-lucide:code' |
412 | | -}) |
| 387 | +const { repoRef } = useRepoMeta(repositoryUrl) |
413 | 388 |
|
414 | 389 | const viewOnGitProvider = useViewOnGitProvider(() => repoRef.value?.provider) |
415 | 390 |
|
416 | | -const homepageUrl = computed(() => { |
417 | | - const homepage = displayVersion.value?.homepage |
418 | | - if (!homepage) return null |
419 | | -
|
420 | | - // Don't show homepage if it's the same as the repository URL |
421 | | - if (repositoryUrl.value && areUrlsEquivalent(homepage, repositoryUrl.value)) { |
422 | | - return null |
423 | | - } |
424 | | -
|
425 | | - return homepage |
426 | | -}) |
427 | | -
|
428 | | -const fundingUrl = computed(() => { |
429 | | - let funding = displayVersion.value?.funding |
430 | | - if (Array.isArray(funding)) funding = funding[0] |
431 | | -
|
432 | | - if (!funding) return null |
433 | | -
|
434 | | - return typeof funding === 'string' ? funding : funding.url |
435 | | -}) |
436 | | -
|
437 | 391 | // Check if a version has provenance/attestations |
438 | 392 | // The dist object may have attestations that aren't in the base type |
439 | 393 | function hasProvenance(version: PackumentVersion | null): boolean { |
@@ -496,7 +450,6 @@ const versionUrlPattern = computed( |
496 | 450 | const dependencyCount = computed(() => getDependencyCount(displayVersion.value)) |
497 | 451 |
|
498 | 452 | const numberFormatter = useNumberFormatter() |
499 | | -const compactNumberFormatter = useCompactNumberFormatter() |
500 | 453 | const bytesFormatter = useBytesFormatter() |
501 | 454 |
|
502 | 455 | useHead({ |
@@ -578,63 +531,7 @@ const showSkeleton = shallowRef(false) |
578 | 531 | </p> |
579 | 532 | </div> |
580 | 533 |
|
581 | | - <!-- External links --> |
582 | | - <ul |
583 | | - class="flex flex-wrap items-center gap-x-3 gap-y-1.5 sm:gap-4 list-none m-0 p-0 mt-3 text-sm" |
584 | | - > |
585 | | - <li v-if="repositoryUrl"> |
586 | | - <LinkBase :to="repositoryUrl" :classicon="repoProviderIcon"> |
587 | | - <span v-if="repoRef"> |
588 | | - {{ repoRef.owner }}<span class="opacity-50">/</span>{{ repoRef.repo }} |
589 | | - </span> |
590 | | - <span v-else>{{ $t('package.links.repo') }}</span> |
591 | | - </LinkBase> |
592 | | - </li> |
593 | | - <li v-if="repositoryUrl && repoMeta && starsLink"> |
594 | | - <LinkBase :to="starsLink" classicon="i-lucide:star"> |
595 | | - {{ compactNumberFormatter.format(stars) }} |
596 | | - </LinkBase> |
597 | | - </li> |
598 | | - <li v-if="forks && forksLink"> |
599 | | - <LinkBase :to="forksLink" classicon="i-lucide:git-fork"> |
600 | | - {{ compactNumberFormatter.format(forks) }} |
601 | | - </LinkBase> |
602 | | - </li> |
603 | | - <li class="basis-full sm:hidden" /> |
604 | | - <li v-if="homepageUrl"> |
605 | | - <LinkBase :to="homepageUrl" classicon="i-lucide:link"> |
606 | | - {{ $t('package.links.homepage') }} |
607 | | - </LinkBase> |
608 | | - </li> |
609 | | - <li v-if="displayVersion?.bugs?.url"> |
610 | | - <LinkBase :to="displayVersion.bugs.url" classicon="i-lucide:circle-alert"> |
611 | | - {{ $t('package.links.issues') }} |
612 | | - </LinkBase> |
613 | | - </li> |
614 | | - <li> |
615 | | - <LinkBase |
616 | | - :to="`https://www.npmjs.com/package/${pkg.name}`" |
617 | | - :title="$t('common.view_on.npm')" |
618 | | - classicon="i-simple-icons:npm" |
619 | | - > |
620 | | - npm |
621 | | - </LinkBase> |
622 | | - </li> |
623 | | - <li v-if="jsrInfo?.exists && jsrInfo.url"> |
624 | | - <LinkBase |
625 | | - :to="jsrInfo.url" |
626 | | - :title="$t('badges.jsr.title')" |
627 | | - classicon="i-simple-icons:jsr" |
628 | | - > |
629 | | - {{ $t('package.links.jsr') }} |
630 | | - </LinkBase> |
631 | | - </li> |
632 | | - <li v-if="fundingUrl"> |
633 | | - <LinkBase :to="fundingUrl" classicon="i-lucide:heart"> |
634 | | - {{ $t('package.links.fund') }} |
635 | | - </LinkBase> |
636 | | - </li> |
637 | | - </ul> |
| 534 | + <PackageExternalLinks :pkg :jsrInfo /> |
638 | 535 | <PackageMetricsBadges |
639 | 536 | v-if="resolvedVersion" |
640 | 537 | :package-name="packageName" |
|
0 commit comments