Skip to content

Commit b470fa2

Browse files
committed
fix/og-name-size configure title scale and use mono font
1 parent dbecf41 commit b470fa2

1 file changed

Lines changed: 34 additions & 28 deletions

File tree

app/components/OgImage/Package.vue

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,20 @@ const formattedStars = computed(() =>
6464
: '',
6565
)
6666
67-
// Dynamic font sizing based on name length
68-
// OG images are 1200px wide, with 64px padding on each side = 1072px content width
69-
// Icon is 80px + 24px gap = 104px, leaving ~968px for name + version
70-
const titleFontSize = computed(() => {
71-
const len = name.value.length
72-
if (len <= 12) return 96 // text-8xl
73-
if (len <= 18) return 80
74-
if (len <= 24) return 64
75-
if (len <= 32) return 52
76-
if (len <= 40) return 44
77-
return 36 // very long names
67+
const MAX_LOGO_SYMBOLS = 40
68+
69+
const titleTruncated = computed(() => {
70+
return name.value.length > MAX_LOGO_SYMBOLS
71+
? `${name.value.slice(0, MAX_LOGO_SYMBOLS - 1)}…`
72+
: name.value
7873
})
7974
80-
const truncatedVersion = computed(() => {
81-
const ver = resolvedVersion.value ?? version.value
82-
if (ver.length <= 12) return ver
83-
return ver.slice(0, 11) + ''
75+
// Dynamic font sizing based on name length
76+
// OG images are 1200px wide, with 64px padding on each side = 1072px content width
77+
// The original size (8xl) can fit 19 characters (2 logo characters + 17 name characters)
78+
const titleScale = computed(() => {
79+
const len = titleTruncated.value.length + 2
80+
return Math.min(Math.floor((19 / len) * 100) / 100, 1)
8481
})
8582
8683
try {
@@ -97,7 +94,7 @@ try {
9794
<template>
9895
<div
9996
class="h-full w-full flex flex-col justify-center px-20 bg-[#050505] text-[#fafafa] relative overflow-hidden"
100-
style="font-family: 'Geist', sans-serif"
97+
style="font-family: 'Geist Mono', sans-serif"
10198
>
10299
<div class="relative z-10 flex flex-col gap-6">
103100
<!-- Package name -->
@@ -126,19 +123,20 @@ try {
126123
</div>
127124

128125
<h1
129-
class="font-bold tracking-tighter"
130-
style="font-family: 'Geist Mono', sans-serif"
131-
:style="{ fontSize: titleFontSize }"
126+
class="font-bold text-8xl origin-cl tracking-tighter text-nowrap flex flex-nowrap"
127+
:style="{ transform: `scale(${titleScale})` }"
132128
>
133-
<span :style="{ color: primaryColor }" class="opacity-80">./</span>{{ pkg?.name }}
129+
<span
130+
:style="{ color: primaryColor }"
131+
class="opacity-80"
132+
style="margin-left: -0.5rem; margin-right: 0.5rem"
133+
>./</span
134+
>{{ titleTruncated }}
134135
</h1>
135136
</div>
136137

137138
<!-- Version -->
138-
<div
139-
class="flex items-center gap-5 text-3xl font-light text-[#a3a3a3]"
140-
style="font-family: 'Geist Mono', sans-serif"
141-
>
139+
<div class="flex items-center gap-5 text-3xl font-light text-[#a3a3a3]">
142140
<span
143141
class="px-3 py-1 me-2 rounded-lg border font-bold opacity-90"
144142
:style="{
@@ -148,11 +146,11 @@ try {
148146
boxShadow: `0 0 20px ${primaryColor}25`,
149147
}"
150148
>
151-
{{ truncatedVersion }}
149+
{{ resolvedVersion ?? version }}
152150
</span>
153151

154152
<!-- Downloads (if any) -->
155-
<span v-if="downloads" class="flex items-center gap-2">
153+
<span v-if="downloads" class="flex items-center gap-2 tracking-tight">
156154
<svg
157155
width="30"
158156
height="30"
@@ -196,7 +194,11 @@ try {
196194
</span>
197195

198196
<!-- Stars (if any) -->
199-
<span v-if="formattedStars" class="flex items-center gap-2" data-testid="stars">
197+
<span
198+
v-if="formattedStars"
199+
class="flex items-center gap-2 tracking-tight"
200+
data-testid="stars"
201+
>
200202
<svg
201203
xmlns="http://www.w3.org/2000/svg"
202204
viewBox="0 0 32 32"
@@ -215,7 +217,11 @@ try {
215217
</span>
216218

217219
<!-- Likes (if any) -->
218-
<span v-if="likes.totalLikes > 0" class="flex items-center gap-2" data-testid="likes">
220+
<span
221+
v-if="likes.totalLikes > 0"
222+
class="flex items-center gap-2 tracking-tight"
223+
data-testid="likes"
224+
>
219225
<svg
220226
width="32"
221227
height="32"

0 commit comments

Comments
 (0)