Skip to content

Commit c9d9c9d

Browse files
authored
feat: improvements for og-image-package (#953)
1 parent 8483ee4 commit c9d9c9d

File tree

1 file changed

+83
-26
lines changed

1 file changed

+83
-26
lines changed

app/components/OgImage/Package.vue

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const repositoryUrl = computed(() => {
4646
return url
4747
})
4848
49+
const { data: likes, refresh: refreshLikes } = useFetch(() => `/api/social/likes/${name.value}`, {
50+
default: () => ({ totalLikes: 0, userHasLiked: false }),
51+
})
52+
4953
const { stars, refresh: refreshRepoMeta } = useRepoMeta(repositoryUrl)
5054
5155
const formattedStars = computed(() =>
@@ -57,7 +61,7 @@ const formattedStars = computed(() =>
5761
5862
try {
5963
await refreshPkg()
60-
await Promise.all([refreshRepoMeta(), refreshDownloads()])
64+
await Promise.all([refreshRepoMeta(), refreshDownloads(), refreshLikes()])
6165
} catch (err) {
6266
console.warn('[og-image-package] Failed to load data server-side:', err)
6367
throw createError({
@@ -73,7 +77,7 @@ try {
7377
<div class="relative z-10 flex flex-col gap-6">
7478
<div class="flex items-start gap-4">
7579
<div
76-
class="flex items-start justify-center w-16 h-16 rounded-xl shadow-lg bg-gradient-to-tr from-[#3b82f6]"
80+
class="flex items-center justify-center w-16 h-16 p-4 rounded-xl shadow-lg bg-gradient-to-tr from-[#3b82f6]"
7781
:style="{ backgroundColor: primaryColor }"
7882
>
7983
<svg
@@ -104,11 +108,11 @@ try {
104108
</div>
105109

106110
<div
107-
class="flex items-center gap-3 text-4xl font-light text-[#a3a3a3]"
111+
class="flex items-center gap-5 text-4xl font-light text-[#a3a3a3]"
108112
style="font-family: 'Geist Sans', sans-serif"
109113
>
110114
<span
111-
class="px-3 py-1 rounded-lg border"
115+
class="px-3 py-1 mr-2 rounded-lg border font-bold opacity-90"
112116
:style="{
113117
color: primaryColor,
114118
backgroundColor: primaryColor + '10',
@@ -118,39 +122,92 @@ try {
118122
>
119123
{{ resolvedVersion }}
120124
</span>
121-
<span v-if="downloads">
122-
<span>• {{ $n(downloads.downloads) }} </span>
123-
<span class="flex items-center gap-0">
124-
<svg
125-
width="30"
126-
height="30"
127-
viewBox="0 0 24 24"
128-
fill="none"
129-
stroke="currentColor"
130-
stroke-width="2"
131-
stroke-linecap="round"
132-
stroke-linejoin="round"
133-
class="text-white/70"
134-
>
135-
<circle cx="12" cy="12" r="10" class="opacity-40" />
136-
<path d="M12 8v8m-3-3l3 3 3-3" />
137-
</svg>
138-
<span>/wk</span>
125+
<span v-if="downloads" class="flex items-center gap-2">
126+
<svg
127+
width="30"
128+
height="30"
129+
viewBox="0 0 24 24"
130+
fill="none"
131+
:stroke="primaryColor"
132+
stroke-width="2"
133+
stroke-linecap="round"
134+
stroke-linejoin="round"
135+
class="opacity-90"
136+
>
137+
<circle cx="12" cy="12" r="10" class="opacity-60" />
138+
<path d="M12 8v8m-3-3l3 3 3-3" />
139+
</svg>
140+
<span>{{ $n(downloads.downloads) }}/wk</span>
141+
</span>
142+
<span v-if="pkg?.license" class="flex items-center gap-2">
143+
<svg
144+
viewBox="0 0 32 32"
145+
:fill="primaryColor"
146+
xmlns="http://www.w3.org/2000/svg"
147+
height="32"
148+
width="32"
149+
class="opacity-90"
150+
>
151+
<path
152+
d="M21.7166 12.57C20.5503 10.631 18.4257 9.33301 15.9997 9.33301C12.3197 9.33301 9.33301 12.3197 9.33301 15.9997C9.33301 19.6797 12.3197 22.6663 15.9997 22.6663C18.4257 22.6663 20.5503 21.3683 21.7166 19.4294L19.4302 18.0586C18.7307 19.2218 17.4566 19.9997 15.9997 19.9997C13.7897 19.9997 11.9997 18.2097 11.9997 15.9997C11.9997 13.7897 13.7897 11.9997 15.9997 11.9997C17.457 11.9997 18.7318 12.7782 19.431 13.9421L21.7166 12.57Z"
153+
/>
154+
<path
155+
fill-rule="evenodd"
156+
clip-rule="evenodd"
157+
d="M15.5247 2.66602C22.8847 2.66602 28.8581 8.63932 28.8581 15.9993C28.8581 23.3593 22.8847 29.3327 15.5247 29.3327C8.16471 29.3327 2.19141 23.3593 2.19141 15.9993C2.19141 8.63932 8.16471 2.66602 15.5247 2.66602ZM4.85807 15.9993C4.85807 10.106 9.63135 5.33268 15.5247 5.33268C21.4181 5.33268 26.1914 10.106 26.1914 15.9993C26.1914 21.8927 21.4181 26.666 15.5247 26.666C9.63135 26.666 4.85807 21.8927 4.85807 15.9993Z"
158+
class="opacity-60"
159+
/>
160+
</svg>
161+
<span>
162+
{{ pkg.license }}
139163
</span>
140164
</span>
141-
<span v-if="pkg?.license"> • {{ pkg.license }}</span>
142165
<span class="flex items-center gap-2">
143-
<span>•</span>
144-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32px" height="32px">
166+
<svg
167+
xmlns="http://www.w3.org/2000/svg"
168+
viewBox="0 0 32 32"
169+
width="32px"
170+
height="32px"
171+
class="opacity-60"
172+
>
145173
<path
146-
fill="currentColor"
174+
:fill="primaryColor"
147175
d="m16 6.52l2.76 5.58l.46 1l1 .15l6.16.89l-4.38 4.3l-.75.73l.18 1l1.05 6.13l-5.51-2.89L16 23l-.93.49l-5.51 2.85l1-6.13l.18-1l-.74-.77l-4.42-4.35l6.16-.89l1-.15l.46-1zM16 2l-4.55 9.22l-10.17 1.47l7.36 7.18L6.9 30l9.1-4.78L25.1 30l-1.74-10.13l7.36-7.17l-10.17-1.48Z"
148176
/>
149177
</svg>
150178
<span>
151179
{{ formattedStars }}
152180
</span>
153181
</span>
182+
<span class="flex items-center gap-2">
183+
<svg
184+
width="32"
185+
height="32"
186+
viewBox="0 0 32 32"
187+
fill="none"
188+
xmlns="http://www.w3.org/2000/svg"
189+
class="opacity-90"
190+
>
191+
<path
192+
d="M19.3057 25.8317L18.011 27.0837C17.7626 27.3691 17.4562 27.5983 17.1124 27.7561C16.7685 27.914 16.3951 27.9969 16.0167 27.9993C15.6384 28.0017 15.2639 27.9235 14.918 27.77C14.5722 27.6165 14.263 27.3912 14.011 27.1091L6.66699 19.9997C4.66699 17.9997 2.66699 15.7331 2.66699 12.6664C2.66702 11.1827 3.11712 9.73384 3.95784 8.51128C4.79856 7.28872 5.99035 6.34994 7.3758 5.81893C8.76126 5.28792 10.2752 5.18965 11.7177 5.53712C13.1602 5.88459 14.4633 6.66143 15.455 7.76506C15.5248 7.83975 15.6093 7.89929 15.7031 7.93999C15.7969 7.9807 15.8981 8.00171 16.0003 8.00171C16.1026 8.00171 16.2038 7.9807 16.2976 7.93999C16.3914 7.89929 16.4758 7.83975 16.5457 7.76506C17.5342 6.65426 18.8377 5.87088 20.2825 5.5192C21.7273 5.16751 23.245 5.26419 24.6335 5.79637C26.022 6.32856 27.2155 7.271 28.0551 8.49826C28.8948 9.72553 29.3407 11.1794 29.3337 12.6664C29.3332 13.3393 29.2349 14.0085 29.0417 14.6531"
193+
:stroke="primaryColor"
194+
stroke-width="2.66667"
195+
stroke-linecap="round"
196+
stroke-linejoin="round"
197+
class="opacity-60"
198+
/>
199+
<path
200+
d="M20 20H24M28 20H24M24 16L24 20M24 24L24 20"
201+
:stroke="primaryColor"
202+
stroke-width="2.66667"
203+
stroke-linecap="round"
204+
stroke-linejoin="round"
205+
/>
206+
</svg>
207+
<span>
208+
{{ likes.totalLikes }}
209+
</span>
210+
</span>
154211
</div>
155212
</div>
156213

0 commit comments

Comments
 (0)