From 2a64a3103d8f6317fc99214fa9b6beeeca9c289d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=BE=E6=B5=A6=20=E7=9F=A5=E4=B9=9F=20Matsuura=20Tomoy?= =?UTF-8?q?a?= Date: Sat, 1 Nov 2025 12:25:58 -0400 Subject: [PATCH] ogimage plugin returns array of promises instead async iterator --- quartz/plugins/emitters/ogImage.tsx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/quartz/plugins/emitters/ogImage.tsx b/quartz/plugins/emitters/ogImage.tsx index af2aa5d44..48ca16972 100644 --- a/quartz/plugins/emitters/ogImage.tsx +++ b/quartz/plugins/emitters/ogImage.tsx @@ -1,7 +1,14 @@ import { QuartzEmitterPlugin } from "../types" import { i18n } from "../../i18n" import { unescapeHTML } from "../../util/escape" -import { FullSlug, getFileExtension, isAbsoluteURL, joinSegments, QUARTZ } from "../../util/path" +import { + FilePath, + FullSlug, + getFileExtension, + isAbsoluteURL, + joinSegments, + QUARTZ, +} from "../../util/path" import { ImageOptions, SocialImageOptions, defaultImage, getSatoriFonts } from "../../util/og" import sharp from "sharp" import satori, { SatoriOptions } from "satori" @@ -109,17 +116,19 @@ export const CustomOgImages: QuartzEmitterPlugin> = getQuartzComponents() { return [] }, - async *emit(ctx, content, _resources) { + async emit(ctx, content, _resources): Promise { const cfg = ctx.cfg.configuration const headerFont = cfg.theme.typography.header const bodyFont = cfg.theme.typography.body const fonts = await getSatoriFonts(headerFont, bodyFont) - Promise.all( - content.map(([_tree, vfile]) => { - if (vfile.data.frontmatter?.socialImage !== undefined) { - processOgImage(ctx, vfile.data, fonts, fullOptions) - } - }), + return Promise.all( + content + .filter( + ([_tree, vfile]) => + vfile.data.frontmatter?.socialImage !== undefined && + vfile.data.filePath !== undefined, + ) + .map(([_tree, vfile]) => processOgImage(ctx, vfile.data, fonts, fullOptions)), ) }, async *partialEmit(ctx, _content, _resources, changeEvents) {