diff --git a/docs/plugins/CustomOgImages.md b/docs/plugins/CustomOgImages.md index 3bc9f8ad4..aafea5d89 100644 --- a/docs/plugins/CustomOgImages.md +++ b/docs/plugins/CustomOgImages.md @@ -115,9 +115,7 @@ export const myImage: SocialImageOptions["imageStructure"] = (...) => { > const bodyWeight: FontWeight = 400 > > const [header, body] = await Promise.all( -> [headerFont, bodyFont].map((font) => -> fs.promises.readFile(path.resolve(font)) -> ), +> [headerFont, bodyFont].map((font) => fs.promises.readFile(path.resolve(font))), > ) > > return [ diff --git a/quartz/build.ts b/quartz/build.ts index 81558f950..91a5a5ab4 100644 --- a/quartz/build.ts +++ b/quartz/build.ts @@ -250,15 +250,25 @@ async function partialRebuildFromEntrypoint( ([_node, vfile]) => !toRemove.has(vfile.data.filePath!), ) - const emittedFps = await emitter.emit(ctx, files, staticResources) - - if (ctx.argv.verbose) { - for (const file of emittedFps) { - console.log(`[emit:${emitter.name}] ${file}`) + const emitted = await emitter.emit(ctx, files, staticResources) + if (Symbol.asyncIterator in emitted) { + // Async generator case + for await (const file of emitted) { + emittedFiles++ + if (ctx.argv.verbose) { + console.log(`[emit:${emitter.name}] ${file}`) + } + } + } else { + // Array case + emittedFiles += emitted.length + if (ctx.argv.verbose) { + for (const file of emitted) { + console.log(`[emit:${emitter.name}] ${file}`) + } } } - emittedFiles += emittedFps.length continue } @@ -280,15 +290,24 @@ async function partialRebuildFromEntrypoint( .filter((file) => !toRemove.has(file)) .map((file) => contentMap.get(file)!) - const emittedFps = await emitter.emit(ctx, upstreamContent, staticResources) - - if (ctx.argv.verbose) { - for (const file of emittedFps) { - console.log(`[emit:${emitter.name}] ${file}`) + const emitted = await emitter.emit(ctx, upstreamContent, staticResources) + if (Symbol.asyncIterator in emitted) { + // Async generator case + for await (const file of emitted) { + emittedFiles++ + if (ctx.argv.verbose) { + console.log(`[emit:${emitter.name}] ${file}`) + } + } + } else { + // Array case + emittedFiles += emitted.length + if (ctx.argv.verbose) { + for (const file of emitted) { + console.log(`[emit:${emitter.name}] ${file}`) + } } } - - emittedFiles += emittedFps.length } } diff --git a/quartz/processors/emit.ts b/quartz/processors/emit.ts index 423d830f1..b4d4aecd7 100644 --- a/quartz/processors/emit.ts +++ b/quartz/processors/emit.ts @@ -20,9 +20,7 @@ export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) { const emitted = await emitter.emit(ctx, content, staticResources) if (Symbol.asyncIterator in emitted) { // Async generator case - const files: string[] = [] for await (const file of emitted) { - files.push(file) emittedFiles++ if (ctx.argv.verbose) { console.log(`[emit:${emitter.name}] ${file}`)