mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 19:04:06 -06:00
ogimage plugin returns array of promises instead async iterator
This commit is contained in:
parent
feb5a5c74d
commit
2a64a3103d
@ -1,7 +1,14 @@
|
|||||||
import { QuartzEmitterPlugin } from "../types"
|
import { QuartzEmitterPlugin } from "../types"
|
||||||
import { i18n } from "../../i18n"
|
import { i18n } from "../../i18n"
|
||||||
import { unescapeHTML } from "../../util/escape"
|
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 { ImageOptions, SocialImageOptions, defaultImage, getSatoriFonts } from "../../util/og"
|
||||||
import sharp from "sharp"
|
import sharp from "sharp"
|
||||||
import satori, { SatoriOptions } from "satori"
|
import satori, { SatoriOptions } from "satori"
|
||||||
@ -109,17 +116,19 @@ export const CustomOgImages: QuartzEmitterPlugin<Partial<SocialImageOptions>> =
|
|||||||
getQuartzComponents() {
|
getQuartzComponents() {
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
async *emit(ctx, content, _resources) {
|
async emit(ctx, content, _resources): Promise<FilePath[]> {
|
||||||
const cfg = ctx.cfg.configuration
|
const cfg = ctx.cfg.configuration
|
||||||
const headerFont = cfg.theme.typography.header
|
const headerFont = cfg.theme.typography.header
|
||||||
const bodyFont = cfg.theme.typography.body
|
const bodyFont = cfg.theme.typography.body
|
||||||
const fonts = await getSatoriFonts(headerFont, bodyFont)
|
const fonts = await getSatoriFonts(headerFont, bodyFont)
|
||||||
Promise.all(
|
return Promise.all(
|
||||||
content.map(([_tree, vfile]) => {
|
content
|
||||||
if (vfile.data.frontmatter?.socialImage !== undefined) {
|
.filter(
|
||||||
processOgImage(ctx, vfile.data, fonts, fullOptions)
|
([_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) {
|
async *partialEmit(ctx, _content, _resources, changeEvents) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user