Skip to content

Commit b3fab8c

Browse files
committed
chore: check alias
1 parent 8381129 commit b3fab8c

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

modules/blog.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import crypto from 'node:crypto'
2626
*/
2727
async function fetchBlueskyAvatars(
2828
imagesDir: string,
29-
publicAvatarBasePath: string,
3029
handles: string[],
3130
): Promise<Map<string, string>> {
3231
const avatarMap = new Map<string, string>()
@@ -59,15 +58,13 @@ async function fetchBlueskyAvatars(
5958
await writeFile(join(imagesDir, `${hash}.jpg`), res.body!)
6059
}
6160

62-
avatarMap.set(profile.handle, join(publicAvatarBasePath, `${hash}.jpg`))
61+
avatarMap.set(profile.handle, `/blog/avatar/${hash}.jpg`)
6362
}
6463
}
6564
} catch (error) {
6665
console.warn(`[blog] Failed to fetch Bluesky avatars:`, error)
6766
}
6867

69-
console.log('avatarMap', avatarMap);
70-
7168
return avatarMap
7269
}
7370

@@ -87,11 +84,7 @@ function resolveAuthors(authors: Author[], avatarMap: Map<string, string>): Reso
8784
* Returns all posts (including drafts) sorted by date descending.
8885
* Resolves Bluesky avatars at build time.
8986
*/
90-
async function loadBlogPosts(
91-
blogDir: string,
92-
imagesDir: string,
93-
publicAvatarBasePath: string,
94-
): Promise<BlogPostFrontmatter[]> {
87+
async function loadBlogPosts(blogDir: string, imagesDir: string): Promise<BlogPostFrontmatter[]> {
9588
const files: string[] = globSync(join(blogDir, '*.md'))
9689

9790
// First pass: extract raw frontmatter and collect all Bluesky handles
@@ -125,7 +118,7 @@ async function loadBlogPosts(
125118
}
126119

127120
// Batch-fetch all Bluesky avatars in a single request
128-
const avatarMap = await fetchBlueskyAvatars(imagesDir, publicAvatarBasePath, [...allHandles])
121+
const avatarMap = await fetchBlueskyAvatars(imagesDir, [...allHandles])
129122

130123
// Second pass: validate with raw schema, then enrich authors with avatars
131124
const posts: BlogPostFrontmatter[] = []
@@ -154,7 +147,6 @@ export default defineNuxtModule({
154147
const resolver = createResolver(import.meta.url)
155148
const blogDir = resolver.resolve('../app/pages/blog')
156149
const blogImagesDir = resolver.resolve('../public/blog/avatar')
157-
const publicAvatarBasePath = join(nuxt.options.app.baseURL || '/', 'blog/avatar')
158150

159151
nuxt.options.extensions.push('.md')
160152
nuxt.options.vite.vue = defu(nuxt.options.vite.vue, {
@@ -185,7 +177,7 @@ export default defineNuxtModule({
185177
)
186178

187179
// Load posts once with resolved Bluesky avatars (shared across template + route rules)
188-
const allPosts = await loadBlogPosts(blogDir, blogImagesDir, publicAvatarBasePath)
180+
const allPosts = await loadBlogPosts(blogDir, blogImagesDir)
189181

190182
// Expose frontmatter for the `/blog` listing page.
191183
const showDrafts = nuxt.options.dev || !isProduction
@@ -203,6 +195,7 @@ export default defineNuxtModule({
203195
})
204196

205197
nuxt.options.alias['#blog/posts'] = join(nuxt.options.buildDir, 'blog/posts')
198+
nuxt.options.alias['/blog/avatar'] = join(nuxt.options.dir.public, '/blog/avatar')
206199

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

0 commit comments

Comments
 (0)