mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-31 00:34:05 -06:00
fix: get output dir via ctx.argv.output
This commit is contained in:
parent
84a70a7688
commit
4ae42220d6
@ -16,6 +16,7 @@ import { unescapeHTML } from "../util/escape"
|
|||||||
async function generateSocialImage(
|
async function generateSocialImage(
|
||||||
{ cfg, description, fileName, fontsPromise, title, fileData }: ImageOptions,
|
{ cfg, description, fileName, fontsPromise, title, fileData }: ImageOptions,
|
||||||
userOpts: SocialImageOptions,
|
userOpts: SocialImageOptions,
|
||||||
|
imageDir: string,
|
||||||
) {
|
) {
|
||||||
const fonts = await fontsPromise
|
const fonts = await fontsPromise
|
||||||
|
|
||||||
@ -37,7 +38,6 @@ async function generateSocialImage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const extension = "webp"
|
const extension = "webp"
|
||||||
const imageDir = "public/static/social-images"
|
|
||||||
|
|
||||||
const defaultOptions: SocialImageOptions = {
|
const defaultOptions: SocialImageOptions = {
|
||||||
colorScheme: "lightMode",
|
colorScheme: "lightMode",
|
||||||
@ -50,7 +50,7 @@ export default (() => {
|
|||||||
let fontsPromise: Promise<SatoriOptions["fonts"]>
|
let fontsPromise: Promise<SatoriOptions["fonts"]>
|
||||||
|
|
||||||
let fullOptions: SocialImageOptions
|
let fullOptions: SocialImageOptions
|
||||||
function Head({ cfg, fileData, externalResources }: QuartzComponentProps) {
|
function Head({ cfg, fileData, externalResources, ctx }: QuartzComponentProps) {
|
||||||
// Initialize options if not set
|
// Initialize options if not set
|
||||||
if (!fullOptions) {
|
if (!fullOptions) {
|
||||||
if (typeof cfg.generateSocialImages !== "boolean") {
|
if (typeof cfg.generateSocialImages !== "boolean") {
|
||||||
@ -85,6 +85,7 @@ export default (() => {
|
|||||||
description = fileData.frontmatter?.description
|
description = fileData.frontmatter?.description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const imageDir = joinSegments(ctx.argv.output, "static", "social-images")
|
||||||
if (cfg.generateSocialImages) {
|
if (cfg.generateSocialImages) {
|
||||||
// Generate folders for social images (if they dont exist yet)
|
// Generate folders for social images (if they dont exist yet)
|
||||||
if (!fs.existsSync(imageDir)) {
|
if (!fs.existsSync(imageDir)) {
|
||||||
@ -105,6 +106,7 @@ export default (() => {
|
|||||||
fileData,
|
fileData,
|
||||||
},
|
},
|
||||||
fullOptions,
|
fullOptions,
|
||||||
|
imageDir,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +122,7 @@ export default (() => {
|
|||||||
const ogImageDefaultPath = `https://${cfg.baseUrl}/static/og-image.png`
|
const ogImageDefaultPath = `https://${cfg.baseUrl}/static/og-image.png`
|
||||||
// "static/social-images/filename.ext"
|
// "static/social-images/filename.ext"
|
||||||
const ogImageGeneratedPath = `https://${cfg.baseUrl}/${imageDir.replace(
|
const ogImageGeneratedPath = `https://${cfg.baseUrl}/${imageDir.replace(
|
||||||
"public/",
|
`${ctx.argv.output}/`,
|
||||||
"",
|
"",
|
||||||
)}/${fileName}.${extension}`
|
)}/${fileName}.${extension}`
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user