Skip to content

Commit b6da02d

Browse files
alexdlnuserquin
andauthored
fix: fix og image generation errors (#1982)
Co-authored-by: userquin <userquin@gmail.com>
1 parent 0d952fa commit b6da02d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

app/components/OgImage/BlogPost.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ const formattedAuthorNames = computed(() => {
110110
v-if="author.avatar"
111111
:src="author.avatar"
112112
:alt="author.name"
113+
width="48"
114+
height="48"
113115
class="w-full h-full object-cover"
114116
/>
115117
<span v-else style="font-size: 20px; color: #666; font-weight: 500">

modules/blog.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,18 @@ async function fetchBlueskyAvatars(
5151
for (const profile of data.profiles) {
5252
if (profile.avatar) {
5353
const hash = crypto.createHash('sha256').update(profile.avatar).digest('hex')
54-
const dest = join(imagesDir, `${hash}.jpg`)
54+
const dest = join(imagesDir, `${hash}.png`)
5555

5656
if (!existsSync(dest)) {
57-
const res = await fetch(profile.avatar)
58-
await writeFile(join(imagesDir, `${hash}.jpg`), res.body!)
57+
const res = await fetch(`${profile.avatar}@png`)
58+
if (!res.ok || !res.body) {
59+
console.warn(`[blog] Failed to fetch Bluesky avatar: ${profile.avatar}@png`)
60+
continue
61+
}
62+
await writeFile(join(imagesDir, `${hash}.png`), res.body)
5963
}
6064

61-
avatarMap.set(profile.handle, `/blog/avatar/${hash}.jpg`)
65+
avatarMap.set(profile.handle, `/blog/avatar/${hash}.png`)
6266
}
6367
}
6468
} catch (error) {
@@ -85,7 +89,7 @@ function resolveAuthors(authors: Author[], avatarMap: Map<string, string>): Reso
8589
* Resolves Bluesky avatars at build time.
8690
*/
8791
async function loadBlogPosts(blogDir: string, imagesDir: string): Promise<BlogPostFrontmatter[]> {
88-
const files: string[] = globSync(join(blogDir, '*.md'))
92+
const files: string[] = globSync(join(blogDir, '*.md').replace(/\\/g, '/'))
8993

9094
// First pass: extract raw frontmatter and collect all Bluesky handles
9195
const rawPosts: Array<{ frontmatter: Record<string, unknown> }> = []

0 commit comments

Comments
 (0)