@@ -87,7 +87,14 @@ function resolveAuthors(authors: Author[], avatarMap: Map<string, string>): Reso
8787 * Returns all posts (including drafts) sorted by date descending.
8888 * Resolves Bluesky avatars at build time.
8989 */
90- async function loadBlogPosts ( blogDir : string , imagesDir : string ) : Promise < BlogPostFrontmatter [ ] > {
90+ async function loadBlogPosts (
91+ blogDir : string ,
92+ options : {
93+ imagesDir : string
94+ resolveAvatars : boolean
95+ } ,
96+ ) : Promise < BlogPostFrontmatter [ ] > {
97+ const { imagesDir, resolveAvatars } = options
9198 const files = await Array . fromAsync ( glob ( join ( blogDir , '**/*.md' ) . replace ( / \\ / g, '/' ) ) )
9299
93100 // First pass: extract raw frontmatter and collect all Bluesky handles
@@ -120,8 +127,10 @@ async function loadBlogPosts(blogDir: string, imagesDir: string): Promise<BlogPo
120127 rawPosts . push ( { frontmatter } )
121128 }
122129
123- // Batch-fetch all Bluesky avatars in a single request
124- const avatarMap = await fetchBlueskyAvatars ( imagesDir , [ ...allHandles ] )
130+ // Batch-fetch all Bluesky avatars in a single request when avatar resolution is enabled.
131+ const avatarMap = resolveAvatars
132+ ? await fetchBlueskyAvatars ( imagesDir , [ ...allHandles ] )
133+ : new Map < string , string > ( )
125134
126135 // Second pass: validate with raw schema, then enrich authors with avatars
127136 const posts : BlogPostFrontmatter [ ] = [ ]
@@ -150,13 +159,14 @@ export default defineNuxtModule({
150159 const resolver = createResolver ( import . meta. url )
151160 const blogDir = resolver . resolve ( '../app/pages/blog' )
152161 const blogImagesDir = resolver . resolve ( '../public/blog/avatar' )
162+ const resolveAvatars = ! nuxt . options . _prepare
153163
154164 nuxt . options . extensions . push ( '.md' )
155165 nuxt . options . vite . vue = defu ( nuxt . options . vite . vue , {
156166 include : [ / \. v u e ( $ | \? ) / , / \. ( m d | m a r k d o w n ) ( $ | \? ) / ] ,
157167 } )
158168
159- if ( ! existsSync ( blogImagesDir ) ) {
169+ if ( resolveAvatars && ! existsSync ( blogImagesDir ) ) {
160170 await mkdir ( blogImagesDir , { recursive : true } )
161171 }
162172
@@ -180,7 +190,10 @@ export default defineNuxtModule({
180190 )
181191
182192 // Load posts once with resolved Bluesky avatars (shared across template + route rules)
183- const allPosts = await loadBlogPosts ( blogDir , blogImagesDir )
193+ const allPosts = await loadBlogPosts ( blogDir , {
194+ imagesDir : blogImagesDir ,
195+ resolveAvatars,
196+ } )
184197
185198 // Expose frontmatter for the `/blog` listing page.
186199 const showDrafts = nuxt . options . dev || ! isProduction
0 commit comments