Skip to content

Commit 3c57caa

Browse files
committed
fix: only show stars/likes in OG image when there are any
1 parent f2ea817 commit 3c57caa

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

app/components/OgImage/Package.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ const { data: likes, refresh: refreshLikes } = useFetch(() => `/api/social/likes
5353
const { stars, refresh: refreshRepoMeta } = useRepoMeta(repositoryUrl)
5454
5555
const formattedStars = computed(() =>
56-
Intl.NumberFormat('en', {
57-
notation: 'compact',
58-
maximumFractionDigits: 1,
59-
}).format(stars.value),
56+
stars.value > 0
57+
? Intl.NumberFormat('en', {
58+
notation: 'compact',
59+
maximumFractionDigits: 1,
60+
}).format(stars.value)
61+
: '',
6062
)
6163
6264
try {
@@ -75,6 +77,7 @@ try {
7577
class="h-full w-full flex flex-col justify-center px-20 bg-[#050505] text-[#fafafa] relative overflow-hidden"
7678
>
7779
<div class="relative z-10 flex flex-col gap-6">
80+
<!-- Package name -->
7881
<div class="flex items-start gap-4">
7982
<div
8083
class="flex items-center justify-center w-16 h-16 p-4 rounded-xl shadow-lg bg-gradient-to-tr from-[#3b82f6]"
@@ -107,6 +110,7 @@ try {
107110
</h1>
108111
</div>
109112

113+
<!-- Version -->
110114
<div
111115
class="flex items-center gap-5 text-4xl font-light text-[#a3a3a3]"
112116
style="font-family: 'Geist Sans', sans-serif"
@@ -122,6 +126,8 @@ try {
122126
>
123127
{{ resolvedVersion }}
124128
</span>
129+
130+
<!-- Downloads (if any) -->
125131
<span v-if="downloads" class="flex items-center gap-2">
126132
<svg
127133
width="30"
@@ -139,6 +145,8 @@ try {
139145
</svg>
140146
<span>{{ $n(downloads.downloads) }}/wk</span>
141147
</span>
148+
149+
<!-- License (if any) -->
142150
<span v-if="pkg?.license" class="flex items-center gap-2">
143151
<svg
144152
viewBox="0 0 32 32"
@@ -162,7 +170,9 @@ try {
162170
{{ pkg.license }}
163171
</span>
164172
</span>
165-
<span class="flex items-center gap-2">
173+
174+
<!-- Stars (if any) -->
175+
<span v-if="formattedStars" class="flex items-center gap-2">
166176
<svg
167177
xmlns="http://www.w3.org/2000/svg"
168178
viewBox="0 0 32 32"
@@ -179,7 +189,9 @@ try {
179189
{{ formattedStars }}
180190
</span>
181191
</span>
182-
<span class="flex items-center gap-2">
192+
193+
<!-- Likes (if any) -->
194+
<span v-if="likes.totalLikes > 0" class="flex items-center gap-2">
183195
<svg
184196
width="32"
185197
height="32"
-1.19 KB
Loading

0 commit comments

Comments
 (0)