mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:54:05 -06:00
feat(og-image): add config option to use default og image for root path
This commit is contained in:
parent
07aa615138
commit
12c99a5673
@ -45,6 +45,7 @@ const defaultOptions: SocialImageOptions = {
|
|||||||
width: 1200,
|
width: 1200,
|
||||||
height: 630,
|
height: 630,
|
||||||
imageStructure: defaultImage,
|
imageStructure: defaultImage,
|
||||||
|
excludeRoot: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (() => {
|
export default (() => {
|
||||||
@ -145,6 +146,13 @@ export default (() => {
|
|||||||
fileData.frontmatter?.socialImage ??
|
fileData.frontmatter?.socialImage ??
|
||||||
fileData.frontmatter?.image ??
|
fileData.frontmatter?.image ??
|
||||||
fileData.frontmatter?.cover
|
fileData.frontmatter?.cover
|
||||||
|
|
||||||
|
// Override with default og image if config option is set
|
||||||
|
if (fileData.slug === "index") {
|
||||||
|
ogImagePath = ogImageDefaultPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override with frontmatter url if existing
|
||||||
if (frontmatterImgUrl) {
|
if (frontmatterImgUrl) {
|
||||||
ogImagePath = `https://${cfg.baseUrl}/static/${frontmatterImgUrl}`
|
ogImagePath = `https://${cfg.baseUrl}/static/${frontmatterImgUrl}`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,10 @@ export type SocialImageOptions = {
|
|||||||
* Width to generate image with in pixels (should be around 1200px)
|
* Width to generate image with in pixels (should be around 1200px)
|
||||||
*/
|
*/
|
||||||
width: number
|
width: number
|
||||||
|
/**
|
||||||
|
* Wether to use the auto generated image for the root path ("/", when set to false) or the default og image (when set to true).
|
||||||
|
*/
|
||||||
|
excludeRoot: boolean
|
||||||
/**
|
/**
|
||||||
* JSX to use for generating image. See satori docs for more info (https://github.com/vercel/satori)
|
* JSX to use for generating image. See satori docs for more info (https://github.com/vercel/satori)
|
||||||
* @param cfg global quartz config
|
* @param cfg global quartz config
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user