Skip to content

Commit 2025d0f

Browse files
committed
chore: check names in og
1 parent 6b6b584 commit 2025d0f

1 file changed

Lines changed: 95 additions & 1 deletion

File tree

app/components/OgImage/BlogPost.vue

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,102 @@ const props = withDefaults(
1717
},
1818
)
1919
console.log('blog post 2', props)
20+
21+
const formattedDate = computed(() => {
22+
console.log('blog post 3', props.date)
23+
if (!props.date) return ''
24+
try {
25+
return new Date(props.date).toLocaleDateString('en-US', {
26+
year: 'numeric',
27+
month: 'short',
28+
day: 'numeric',
29+
})
30+
} catch {
31+
console.log('blog post 4', props.date)
32+
return props.date
33+
}
34+
})
35+
36+
const MAX_VISIBLE_AUTHORS = 2
37+
38+
const extraCount = computed(() => {
39+
console.log('blog post 6', props.authors)
40+
if (props.authors.length <= 3) return 0
41+
return props.authors.length - MAX_VISIBLE_AUTHORS
42+
})
43+
44+
const formattedAuthorNames = computed(() => {
45+
console.log('blog post 7', props.authors)
46+
const allNames = props.authors.map(a => a.name)
47+
if (allNames.length === 0) return ''
48+
if (allNames.length === 1) return allNames[0]
49+
if (allNames.length === 2) return `${allNames[0]} and ${allNames[1]}`
50+
if (allNames.length === 3) return `${allNames[0]}, ${allNames[1]}, and ${allNames[2]}`
51+
// More than 3: show first 2 + others
52+
const shown = allNames.slice(0, MAX_VISIBLE_AUTHORS)
53+
const remaining = allNames.length - MAX_VISIBLE_AUTHORS
54+
return `${shown.join(', ')} and ${remaining} others`
55+
})
2056
</script>
2157

2258
<template>
23-
<div>Test</div>
59+
<div
60+
class="h-full w-full flex flex-col justify-center px-20 bg-[#050505] text-[#fafafa] relative overflow-hidden"
61+
>
62+
<!-- npmx logo - top right -->
63+
<div
64+
class="absolute top-12 z-10 flex items-center gap-1 text-5xl font-bold tracking-tight"
65+
style="font-family: 'Geist', sans-serif; right: 6rem"
66+
>
67+
<span :style="{ color: primaryColor }" class="opacity-80">./</span>
68+
<span class="text-white">npmx</span>
69+
</div>
70+
71+
<div class="relative z-10 flex flex-col gap-2">
72+
<!-- Date -->
73+
<span
74+
v-if="formattedDate"
75+
class="text-3xl text-[#a3a3a3] font-light"
76+
style="font-family: 'Geist', sans-serif"
77+
>
78+
{{ formattedDate }}
79+
</span>
80+
81+
<!-- Blog title -->
82+
<h1
83+
class="text-6xl font-semibold tracking-tight leading-snug w-9/10"
84+
style="font-family: 'Geist', sans-serif; letter-spacing: -0.03em"
85+
>
86+
{{ title }}
87+
</h1>
88+
89+
<!-- Authors -->
90+
<div
91+
v-if="authors.length"
92+
class="flex items-center gap-4 self-start justify-start flex-nowrap"
93+
style="font-family: 'Geist', sans-serif"
94+
>
95+
<!-- Stacked avatars -->
96+
<span>
97+
<!-- +N badge -->
98+
<span
99+
v-if="extraCount > 0"
100+
class="flex items-center justify-center text-lg font-medium text-[#a3a3a3] rounded-full border border-[#050505] bg-[#262626] overflow-hidden w-12 h-12"
101+
:style="{ marginLeft: '-20px' }"
102+
>
103+
+{{ extraCount }}
104+
</span>
105+
</span>
106+
<!-- Names -->
107+
<span style="font-size: 24px; color: #a3a3a3; font-weight: 300">{{
108+
formattedAuthorNames
109+
}}</span>
110+
</div>
111+
</div>
112+
113+
<div
114+
class="absolute -top-32 -inset-ie-32 w-[550px] h-[550px] rounded-full blur-3xl"
115+
:style="{ backgroundColor: primaryColor + '10' }"
116+
/>
117+
</div>
24118
</template>

0 commit comments

Comments
 (0)