-
-
Notifications
You must be signed in to change notification settings - Fork 339
refactor(ui): move package external links to component #2077
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
Merged
graphieros
merged 2 commits into
npmx-dev:main
from
MatteoGabriele:refactor/package-external-links
Mar 15, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <script setup lang="ts"> | ||
| import type { IconClass } from '~/types' | ||
|
|
||
| const props = defineProps<{ | ||
| pkg: SlimPackument | ||
| jsrInfo?: JsrPackageInfo | ||
| }>() | ||
|
|
||
| const displayVersion = computed(() => props.pkg?.requestedVersion ?? null) | ||
| const { repositoryUrl } = useRepositoryUrl(displayVersion) | ||
| const { meta: repoMeta, repoRef, stars, starsLink, forks, forksLink } = useRepoMeta(repositoryUrl) | ||
| const compactNumberFormatter = useCompactNumberFormatter() | ||
|
|
||
| const homepageUrl = computed(() => { | ||
| const homepage = displayVersion.value?.homepage | ||
| if (!homepage) return null | ||
|
|
||
| // Don't show homepage if it's the same as the repository URL | ||
| if (repositoryUrl.value && areUrlsEquivalent(homepage, repositoryUrl.value)) { | ||
| return null | ||
| } | ||
|
|
||
| return homepage | ||
| }) | ||
|
|
||
| const fundingUrl = computed(() => { | ||
| let funding = displayVersion.value?.funding | ||
| if (Array.isArray(funding)) funding = funding[0] | ||
|
|
||
| if (!funding) return null | ||
|
|
||
| return typeof funding === 'string' ? funding : funding.url | ||
| }) | ||
|
|
||
| const PROVIDER_ICONS: Record<string, IconClass> = { | ||
| github: 'i-simple-icons:github', | ||
| gitlab: 'i-simple-icons:gitlab', | ||
| bitbucket: 'i-simple-icons:bitbucket', | ||
| codeberg: 'i-simple-icons:codeberg', | ||
| gitea: 'i-simple-icons:gitea', | ||
| forgejo: 'i-simple-icons:forgejo', | ||
| gitee: 'i-simple-icons:gitee', | ||
| sourcehut: 'i-simple-icons:sourcehut', | ||
| tangled: 'i-custom:tangled', | ||
| radicle: 'i-lucide:network', // Radicle is a P2P network, using network icon | ||
| } | ||
|
|
||
| const repoProviderIcon = computed((): IconClass => { | ||
| const provider = repoRef.value?.provider | ||
| if (!provider) return 'i-simple-icons:github' | ||
| return PROVIDER_ICONS[provider] ?? 'i-lucide:code' | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <ul 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"> | ||
| <li v-if="repositoryUrl"> | ||
| <LinkBase :to="repositoryUrl" :classicon="repoProviderIcon"> | ||
| <span v-if="repoRef"> | ||
| {{ repoRef.owner }}<span class="opacity-50">/</span>{{ repoRef.repo }} | ||
| </span> | ||
| <span v-else>{{ $t('package.links.repo') }}</span> | ||
| </LinkBase> | ||
| </li> | ||
| <li v-if="repositoryUrl && repoMeta && starsLink"> | ||
| <LinkBase :to="starsLink" classicon="i-lucide:star"> | ||
| {{ compactNumberFormatter.format(stars) }} | ||
| </LinkBase> | ||
| </li> | ||
| <li v-if="forks && forksLink"> | ||
| <LinkBase :to="forksLink" classicon="i-lucide:git-fork"> | ||
| {{ compactNumberFormatter.format(forks) }} | ||
| </LinkBase> | ||
| </li> | ||
| <li class="basis-full sm:hidden" /> | ||
| <li v-if="homepageUrl"> | ||
| <LinkBase :to="homepageUrl" classicon="i-lucide:link"> | ||
| {{ $t('package.links.homepage') }} | ||
| </LinkBase> | ||
| </li> | ||
| <li v-if="displayVersion?.bugs?.url"> | ||
| <LinkBase :to="displayVersion.bugs.url" classicon="i-lucide:circle-alert"> | ||
| {{ $t('package.links.issues') }} | ||
| </LinkBase> | ||
| </li> | ||
| <li> | ||
| <LinkBase | ||
| :to="`https://www.npmjs.com/package/${pkg.name}`" | ||
| :title="$t('common.view_on.npm')" | ||
| classicon="i-simple-icons:npm" | ||
| > | ||
| npm | ||
| </LinkBase> | ||
| </li> | ||
| <li v-if="jsrInfo?.exists && jsrInfo.url"> | ||
| <LinkBase :to="jsrInfo.url" :title="$t('badges.jsr.title')" classicon="i-simple-icons:jsr"> | ||
| {{ $t('package.links.jsr') }} | ||
| </LinkBase> | ||
| </li> | ||
| <li v-if="fundingUrl"> | ||
| <LinkBase :to="fundingUrl" classicon="i-lucide:heart"> | ||
| {{ $t('package.links.fund') }} | ||
| </LinkBase> | ||
| </li> | ||
| </ul> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 5693
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 632
Add
titleprop toLinkBaseand forward it to both template branches.The
titleattribute passed on lines 89 and 96 is not declared as a prop inapp/components/Link/Base.vueand will be silently dropped at runtime. The component uses av-if/v-elsefragment with a disabled<span>and<NuxtLink>branch; Vue 3 does not automatically apply fallthrough attributes in this pattern, andv-bind="props"only forwards declared props. AddtitletodefinePropsand bind:title="title"on both the<span>and<NuxtLink>branches to ensure the hover text appears.