| | |
| | | import { QuartzEmitterPlugin } from "../types" |
| | | import { i18n } from "../../i18n" |
| | | import { unescapeHTML } from "../../util/escape" |
| | | import { FullSlug, getFileExtension, joinSegments, QUARTZ } from "../../util/path" |
| | | import { 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" |
| | |
| | | additionalHead: [ |
| | | (pageData) => { |
| | | const isRealFile = pageData.filePath !== undefined |
| | | const userDefinedOgImagePath = pageData.frontmatter?.socialImage |
| | | let userDefinedOgImagePath = pageData.frontmatter?.socialImage |
| | | |
| | | if (userDefinedOgImagePath) { |
| | | userDefinedOgImagePath = isAbsoluteURL(userDefinedOgImagePath) |
| | | ? userDefinedOgImagePath |
| | | : `https://${baseUrl}/static/${userDefinedOgImagePath}` |
| | | } |
| | | |
| | | const generatedOgImagePath = isRealFile |
| | | ? `https://${baseUrl}/${pageData.slug!}-og-image.webp` |
| | | : undefined |
| | | const defaultOgImagePath = `https://${baseUrl}/static/og-image.png` |
| | | const ogImagePath = userDefinedOgImagePath ?? generatedOgImagePath ?? defaultOgImagePath |
| | | |
| | | const ogImageMimeType = `image/${getFileExtension(ogImagePath) ?? "png"}` |
| | | return ( |
| | | <> |