-
-
Notifications
You must be signed in to change notification settings - Fork 345
feat: new og images #2122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: new og images #2122
Changes from all commits
a04f84f
0198696
b76f0e2
fb61483
b4b7ffc
440bdb1
6e89cb9
b366eaa
17e7ef7
6c3add5
b69a6df
25f3f96
347cbcc
8d8a3ee
8e1c597
2cdcc35
114f2e3
499668f
4d5afa5
b196d5a
a1259f7
49a9014
6e62678
9d7060c
83fa423
449232c
9800fc1
b1cae8f
81c6227
f65e30f
2382633
42896a1
1f12d07
ff5c315
f794422
44eb192
f2de5ad
4d97d7f
6a86fa3
533a466
00b80ec
a2e4207
3a762ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <script setup lang="ts"> | ||
| const props = withDefaults( | ||
| defineProps<{ | ||
| height?: number | ||
| }>(), | ||
| { | ||
| height: 60, | ||
| }, | ||
| ) | ||
| const width = computed(() => Math.round(props.height * (602 / 170))) | ||
| </script> | ||
|
|
||
| <template> | ||
| <img | ||
| src="/logo.svg" | ||
| alt="npmx" | ||
| :width="width" | ||
| :height="height" | ||
| :style="{ width: `${width}px`, height: `${height}px` }" | ||
| /> | ||
| </template> | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,114 @@ | ||||||||||||||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||||||||||||||
| import type { ResolvedAuthor } from '#shared/schemas/blog' | ||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||
| title, | ||||||||||||||||||||||||||||||||
| authors = [], | ||||||||||||||||||||||||||||||||
| date = '', | ||||||||||||||||||||||||||||||||
| } = defineProps<{ | ||||||||||||||||||||||||||||||||
| title: string | ||||||||||||||||||||||||||||||||
| authors?: ResolvedAuthor[] | ||||||||||||||||||||||||||||||||
| date?: string | ||||||||||||||||||||||||||||||||
| }>() | ||||||||||||||||||||||||||||||||
| const formattedDate = computed(() => { | ||||||||||||||||||||||||||||||||
| if (!date) return '' | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| return new Date(date).toLocaleDateString('en-US', { | ||||||||||||||||||||||||||||||||
| year: 'numeric', | ||||||||||||||||||||||||||||||||
| month: 'short', | ||||||||||||||||||||||||||||||||
| day: 'numeric', | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||
| return date | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| const MAX_VISIBLE_AUTHORS = 2 | ||||||||||||||||||||||||||||||||
| const getInitials = (name: string) => | ||||||||||||||||||||||||||||||||
| name | ||||||||||||||||||||||||||||||||
| .split(' ') | ||||||||||||||||||||||||||||||||
| .map(n => n[0]) | ||||||||||||||||||||||||||||||||
| .join('') | ||||||||||||||||||||||||||||||||
| .toUpperCase() | ||||||||||||||||||||||||||||||||
| .slice(0, 2) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential runtime error if name contains consecutive spaces. If 🛡️ Proposed fix to filter empty parts const getInitials = (name: string) =>
name
.split(' ')
+ .filter(n => n.length > 0)
.map(n => n[0])
.join('')
.toUpperCase()
.slice(0, 2)📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| const visibleAuthors = computed(() => { | ||||||||||||||||||||||||||||||||
| if (authors.length <= 3) return authors | ||||||||||||||||||||||||||||||||
| return authors.slice(0, MAX_VISIBLE_AUTHORS) | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| const extraCount = computed(() => { | ||||||||||||||||||||||||||||||||
| if (authors.length <= 3) return 0 | ||||||||||||||||||||||||||||||||
| return authors.length - MAX_VISIBLE_AUTHORS | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| const formattedAuthorNames = computed(() => { | ||||||||||||||||||||||||||||||||
| const allNames = authors.map(a => a.name) | ||||||||||||||||||||||||||||||||
| if (allNames.length === 0) return '' | ||||||||||||||||||||||||||||||||
| if (allNames.length === 1) return allNames[0] | ||||||||||||||||||||||||||||||||
| if (allNames.length === 2) return `${allNames[0]} and ${allNames[1]}` | ||||||||||||||||||||||||||||||||
| if (allNames.length === 3) return `${allNames[0]}, ${allNames[1]}, and ${allNames[2]}` | ||||||||||||||||||||||||||||||||
| const shown = allNames.slice(0, MAX_VISIBLE_AUTHORS) | ||||||||||||||||||||||||||||||||
| const remaining = allNames.length - MAX_VISIBLE_AUTHORS | ||||||||||||||||||||||||||||||||
| return `${shown.join(', ')} and ${remaining} others` | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| <template> | ||||||||||||||||||||||||||||||||
| <OgLayout> | ||||||||||||||||||||||||||||||||
| <div class="px-15 py-12 flex flex-col justify-center gap-5 h-full"> | ||||||||||||||||||||||||||||||||
| <OgBrand :height="48" /> | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| <!-- Date + Title --> | ||||||||||||||||||||||||||||||||
| <div class="flex flex-col gap-2"> | ||||||||||||||||||||||||||||||||
| <span v-if="formattedDate" class="text-3xl text-fg-muted"> | ||||||||||||||||||||||||||||||||
| {{ formattedDate }} | ||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||
| class="lg:text-6xl text-5xl tracking-tighter font-mono leading-tight" | ||||||||||||||||||||||||||||||||
| :style="{ lineClamp: 2, textOverflow: 'ellipsis' }" | ||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||
| {{ title }} | ||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| <!-- Authors --> | ||||||||||||||||||||||||||||||||
| <div v-if="authors.length" class="flex items-center gap-4 flex-nowrap"> | ||||||||||||||||||||||||||||||||
| <!-- Stacked avatars --> | ||||||||||||||||||||||||||||||||
| <span> | ||||||||||||||||||||||||||||||||
| <span | ||||||||||||||||||||||||||||||||
| v-for="(author, index) in visibleAuthors" | ||||||||||||||||||||||||||||||||
| :key="author.name" | ||||||||||||||||||||||||||||||||
| class="flex items-center justify-center rounded-full border border-bg bg-bg-muted overflow-hidden w-12 h-12" | ||||||||||||||||||||||||||||||||
| :style="{ marginLeft: index > 0 ? '-20px' : '0' }" | ||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||
| <img | ||||||||||||||||||||||||||||||||
| v-if="author.avatar" | ||||||||||||||||||||||||||||||||
| :src="author.avatar" | ||||||||||||||||||||||||||||||||
| :alt="author.name" | ||||||||||||||||||||||||||||||||
| width="48" | ||||||||||||||||||||||||||||||||
| height="48" | ||||||||||||||||||||||||||||||||
| class="w-full h-full object-cover" | ||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||
| <span v-else class="text-5 text-fg-muted font-medium"> | ||||||||||||||||||||||||||||||||
| {{ getInitials(author.name) }} | ||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||
| <!-- +N badge --> | ||||||||||||||||||||||||||||||||
| <span | ||||||||||||||||||||||||||||||||
| v-if="extraCount > 0" | ||||||||||||||||||||||||||||||||
| class="flex items-center justify-center text-lg font-medium text-fg-muted rounded-full border border-bg bg-bg-muted overflow-hidden w-12 h-12" | ||||||||||||||||||||||||||||||||
| :style="{ marginLeft: '-20px' }" | ||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||
| +{{ extraCount }} | ||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||
| <!-- Names --> | ||||||||||||||||||||||||||||||||
| <span class="text-6 text-fg-muted font-light">{{ formattedAuthorNames }}</span> | ||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||
| </OgLayout> | ||||||||||||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heightis not defined in scope – useprops.height.On line 19,
:height="height"referencesheightwhich isn't directly available in scope. Sincepropsis the return value ofwithDefaults, you need to accessprops.height.🐛 Proposed fix
📝 Committable suggestion