@@ -59,6 +59,11 @@ const { repoRef, stars, refresh: refreshRepoMeta } = useRepoMeta(repositoryUrl)
5959
6060const formattedStars = computed (() => (stars .value > 0 ? compactFormat .format (stars .value ) : ' ' ))
6161
62+ const totalLikes = shallowRef (0 )
63+ const formattedLikes = computed (() =>
64+ totalLikes .value ? compactFormat .format (totalLikes .value ) : ' ' ,
65+ )
66+
6267const { name : siteName } = useSiteConfig ()
6368
6469const pkgNameParts = computed (() => {
@@ -176,8 +181,14 @@ function fetchVariantData() {
176181 return fetchWeeklyEvolution ()
177182}
178183
184+ const fetchLikes = $fetch <{ totalLikes: number }>(` /api/social/likes/${name } ` )
185+ .then (d => {
186+ totalLikes .value = d ?.totalLikes ?? 0
187+ })
188+ .catch (() => {})
189+
179190try {
180- await Promise .all ([refreshPkg ().then (() => refreshRepoMeta ()), fetchVariantData ()])
191+ await Promise .all ([refreshPkg ().then (() => refreshRepoMeta ()), fetchVariantData (), fetchLikes ])
181192} catch (err ) {
182193 console .warn (' [og-image-package] Failed to load data server-side:' , err )
183194 throw createError ({
@@ -272,6 +283,11 @@ const sparklineSrc = computed(() => {
272283 <span >{{ formattedStars }}</span >
273284 </span >
274285
286+ <span v-if =" formattedLikes" class =" flex items-center gap-2" data-testid =" likes" >
287+ <div class =" i-lucide:heart w-8 h-8 text-fg-muted" :style =" { fill: 'white' }" />
288+ <span >{{ formattedLikes }}</span >
289+ </span >
290+
275291 <div
276292 v-if =" pkg?.license && !pkg.license.includes(' ')"
277293 class =" flex items-center gap-2"
@@ -287,30 +303,33 @@ const sparklineSrc = computed(() => {
287303 <img
288304 v-if =" variant === 'download-chart' && sparklineSrc"
289305 :src =" sparklineSrc"
290- class =" absolute force-left-0 bottom-0 w-full h-[65%] opacity-45 "
306+ class =" absolute force-left-0 bottom-0 w-full h-[65%] opacity-30 "
291307 />
292308
293309 <!-- Code tree variant -->
294310 <div
295- v-if =" variant === 'code-tree' && treeRows.length"
296- class =" absolute force-right-8 top-8 bottom-8 w-[340px] flex flex-col gap-0 opacity-25 overflow-hidden font-mono text-4.5 leading-7"
311+ v-else- if =" variant === 'code-tree' && treeRows.length"
312+ class =" text-fg-muted absolute force-right-8 top-8 bottom-8 w-[340px] flex flex-col gap-0 opacity-30 overflow-hidden font-mono text-4.5 leading-7"
297313 >
298314 <div
299315 v-for =" (row, i) in treeRows"
300316 :key =" i"
301317 class =" flex items-center whitespace-nowrap text-fg"
302318 :style =" { paddingLeft: `${row.depth * 20}px` }"
303319 >
304- <span v-if =" row.isDir" class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:folder" />
305- <span v-else class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:file" />
320+ <span
321+ v-if =" row.isDir"
322+ class =" w-5 h-5 text-fg-muted shrink-0 force-mr-1.5 i-lucide:folder"
323+ />
324+ <span v-else class =" w-5 h-5 text-fg-muted shrink-0 force-mr-1.5 i-lucide:file" />
306325 <span >{{ row.name }}</span >
307326 </div >
308327 </div >
309328
310329 <!-- Function tree variant (API symbols) -->
311330 <div
312- v-if =" variant === 'function-tree' && symbolRows.length"
313- class =" absolute force-right-8 top-8 bottom-8 w-[340px] flex flex-col gap-0 opacity-25 overflow-hidden font-mono text-4.5 leading-7"
331+ v-else- if =" variant === 'function-tree' && symbolRows.length"
332+ class =" absolute force-right-8 top-8 bottom-8 w-[340px] flex flex-col gap-0 opacity-30 overflow-hidden font-mono text-4.5 leading-7"
314333 >
315334 <div
316335 v-for =" (row, i) in symbolRows"
@@ -320,37 +339,39 @@ const sparklineSrc = computed(() => {
320339 >
321340 <span
322341 v-if =" row.icon === 'i-lucide:parentheses'"
323- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:parentheses"
342+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:parentheses"
324343 />
325344 <span
326345 v-else-if =" row.icon === 'i-lucide:box'"
327- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:box"
346+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:box"
328347 />
329348 <span
330349 v-else-if =" row.icon === 'i-lucide:puzzle'"
331- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:puzzle"
350+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:puzzle"
332351 />
333352 <span
334353 v-else-if =" row.icon === 'i-lucide:type'"
335- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:type"
354+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:type"
336355 />
337356 <span
338357 v-else-if =" row.icon === 'i-lucide:variable'"
339- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:variable"
358+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:variable"
340359 />
341360 <span
342361 v-else-if =" row.icon === 'i-lucide:list'"
343- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:list"
362+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:list"
344363 />
345364 <span
346365 v-else-if =" row.icon === 'i-lucide:package'"
347- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:package"
366+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:package"
348367 />
349368 <span
350369 v-else-if =" row.kind === 'symbol'"
351- class =" w-5 h-5 shrink-0 force-mr-1.5 i-lucide:code"
370+ class =" w-5 h-5 shrink-0 text-fg-muted force-mr-1.5 i-lucide:code"
352371 />
353- <span :class =" row.kind === 'section' ? 'opacity-60 text-4 mt-1' : ''" >{{ row.name }}</span >
372+ <span class =" text-fg-muted" :class =" row.kind === 'section' ? 'text-4 mt-1' : ''" >{{
373+ row.name
374+ }}</span >
354375 </div >
355376 </div >
356377 </div >
0 commit comments