Skip to content

Commit a00aed3

Browse files
committed
chore: check remote avatars
1 parent ba2f1f9 commit a00aed3

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

modules/blog.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ import {
1616
import { globSync } from 'tinyglobby'
1717
import { isProduction } from '../config/env'
1818
import { BLUESKY_API } from '../shared/utils/constants'
19-
import { mkdir, writeFile } from 'node:fs/promises'
19+
import { mkdir } from 'node:fs/promises'
2020
import { existsSync } from 'node:fs'
21-
import crypto from 'node:crypto'
2221

2322
/**
2423
* Fetches Bluesky avatars for a set of authors at build time.
2524
* Returns a map of handle → avatar URL.
2625
*/
2726
async function fetchBlueskyAvatars(
28-
imagesDir: string,
27+
_imagesDir: string,
2928
handles: string[],
3029
): Promise<Map<string, string>> {
3130
const avatarMap = new Map<string, string>()
@@ -49,17 +48,7 @@ async function fetchBlueskyAvatars(
4948
const data = (await response.json()) as { profiles: Array<{ handle: string; avatar?: string }> }
5049

5150
for (const profile of data.profiles) {
52-
if (profile.avatar) {
53-
const hash = crypto.createHash('sha256').update(profile.avatar).digest('hex')
54-
const dest = join(imagesDir, `${hash}.jpg`)
55-
56-
if (!existsSync(dest)) {
57-
const res = await fetch(profile.avatar)
58-
await writeFile(join(imagesDir, `${hash}.jpg`), res.body!)
59-
}
60-
61-
avatarMap.set(profile.handle, `/blog/avatar/${hash}.jpg`)
62-
}
51+
if (profile.avatar) avatarMap.set(profile.handle, profile.avatar)
6352
}
6453
} catch (error) {
6554
console.warn(`[blog] Failed to fetch Bluesky avatars:`, error)
@@ -195,7 +184,6 @@ export default defineNuxtModule({
195184
})
196185

197186
nuxt.options.alias['#blog/posts'] = join(nuxt.options.buildDir, 'blog/posts')
198-
nuxt.options.alias['/blog/avatar'] = join(nuxt.options.dir.public, 'blog/avatar')
199187

200188
// Add X-Robots-Tag header for draft posts to prevent indexing
201189
for (const post of allPosts) {

0 commit comments

Comments
 (0)