Skip to content

Commit b0af236

Browse files
feat: add vanity number for user & org (#487)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 9aa343a commit b0af236

File tree

6 files changed

+60
-24
lines changed

6 files changed

+60
-24
lines changed

app/pages/@[org].vue

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ watch([() => filters.value.text, sortOption], ([filter, sort]) => {
9797
9898
const filteredCount = computed(() => sortedPackages.value.length)
9999
100+
// Total weekly downloads across displayed packages (updates with filter)
101+
const totalWeeklyDownloads = computed(() =>
102+
sortedPackages.value.reduce((sum, pkg) => sum + (pkg.downloads?.weekly ?? 0), 0),
103+
)
104+
100105
// Reset state when org changes
101106
watch(orgName, () => {
102107
clearAllFilters()
@@ -156,19 +161,30 @@ defineOgImageComponent('Default', {
156161
</p>
157162
</div>
158163

159-
<!-- Link to npmjs.com org page -->
160-
<nav aria-label="External links" class="ms-auto">
161-
<a
162-
:href="`https://www.npmjs.com/org/${orgName}`"
163-
target="_blank"
164-
rel="noopener noreferrer"
165-
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
166-
:title="$t('common.view_on_npm')"
164+
<!-- Link to npmjs.com org page + vanity downloads -->
165+
<div class="ms-auto text-end">
166+
<nav aria-label="External links">
167+
<a
168+
:href="`https://www.npmjs.com/org/${orgName}`"
169+
target="_blank"
170+
rel="noopener noreferrer"
171+
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
172+
:title="$t('common.view_on_npm')"
173+
>
174+
<span class="i-carbon:logo-npm w-4 h-4" aria-hidden="true" />
175+
npm
176+
</a>
177+
</nav>
178+
<p
179+
class="text-fg-subtle text-xs mt-1 flex items-center gap-1.5 justify-end cursor-help"
180+
:title="$t('common.vanity_downloads_hint', { count: filteredCount }, filteredCount)"
167181
>
168-
<span class="i-carbon:logo-npm w-4 h-4" aria-hidden="true" />
169-
npm
170-
</a>
171-
</nav>
182+
<span class="i-carbon:chart-line w-3.5 h-3.5" aria-hidden="true" />
183+
<span class="font-mono"
184+
>{{ formatNumber(totalWeeklyDownloads) }} {{ $t('common.per_week') }}</span
185+
>
186+
</p>
187+
</div>
172188
</div>
173189
</header>
174190

app/pages/~[username]/index.vue

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ const filteredAndSortedPackages = computed(() => {
129129
130130
const filteredCount = computed(() => filteredAndSortedPackages.value.length)
131131
132+
// Total weekly downloads across displayed packages (updates with filter)
133+
const totalWeeklyDownloads = computed(() =>
134+
filteredAndSortedPackages.value.reduce((sum, pkg) => sum + (pkg.downloads?.weekly ?? 0), 0),
135+
)
136+
132137
// Check if there are potentially more results
133138
const hasMore = computed(() => {
134139
if (!results.value) return false
@@ -191,19 +196,30 @@ defineOgImageComponent('Default', {
191196
</p>
192197
</div>
193198

194-
<!-- Link to npmjs.com profile -->
195-
<nav aria-label="External links" class="ms-auto">
196-
<a
197-
:href="`https://www.npmjs.com/~${username}`"
198-
target="_blank"
199-
rel="noopener noreferrer"
200-
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
201-
:title="$t('common.view_on_npm')"
199+
<!-- Link to npmjs.com profile + vanity downloads -->
200+
<div class="ms-auto text-end">
201+
<nav aria-label="External links">
202+
<a
203+
:href="`https://www.npmjs.com/~${username}`"
204+
target="_blank"
205+
rel="noopener noreferrer"
206+
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
207+
:title="$t('common.view_on_npm')"
208+
>
209+
<span class="i-carbon:logo-npm w-4 h-4" aria-hidden="true" />
210+
npm
211+
</a>
212+
</nav>
213+
<p
214+
class="text-fg-subtle text-xs mt-1 flex items-center gap-1.5 justify-end cursor-help"
215+
:title="$t('common.vanity_downloads_hint', { count: filteredCount }, filteredCount)"
202216
>
203-
<span class="i-carbon:logo-npm w-4 h-4" aria-hidden="true" />
204-
npm
205-
</a>
206-
</nav>
217+
<span class="i-carbon:chart-line w-3.5 h-3.5" aria-hidden="true" />
218+
<span class="font-mono"
219+
>{{ formatNumber(totalWeeklyDownloads) }} {{ $t('common.per_week') }}</span
220+
>
221+
</p>
222+
</div>
207223
</div>
208224
</header>
209225

i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"go_back_home": "Go back home",
9999
"view_on_npm": "view on npm",
100100
"per_week": "/ week",
101+
"vanity_downloads_hint": "Vanity number: no packages displayed | Vanity number: for the displayed package | Vanity number: Sum of {count} displayed packages",
101102
"sort": {
102103
"name": "name",
103104
"role": "role",

i18n/locales/fr-FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"go_back_home": "Retour à l'accueil",
9696
"view_on_npm": "voir sur npm",
9797
"per_week": "/ semaine",
98+
"vanity_downloads_hint": "Métrique de vanité : aucun paquet affiché | Métrique de vanité : pour le paquet affiché | Métrique de vanité : somme des {count} paquets affichés",
9899
"sort": {
99100
"name": "nom",
100101
"role": "rôle",

lunaria/files/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"go_back_home": "Go back home",
9999
"view_on_npm": "view on npm",
100100
"per_week": "/ week",
101+
"vanity_downloads_hint": "Vanity number: no packages displayed | Vanity number: for the displayed package | Vanity number: Sum of {count} displayed packages",
101102
"sort": {
102103
"name": "name",
103104
"role": "role",

lunaria/files/fr-FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"go_back_home": "Retour à l'accueil",
9696
"view_on_npm": "voir sur npm",
9797
"per_week": "/ semaine",
98+
"vanity_downloads_hint": "Métrique de vanité : aucun paquet affiché | Métrique de vanité : pour le paquet affiché | Métrique de vanité : somme des {count} paquets affichés",
9899
"sort": {
99100
"name": "nom",
100101
"role": "rôle",

0 commit comments

Comments
 (0)