From b207477248b120464ef5789d8be9bbe4d3598f38 Mon Sep 17 00:00:00 2001 From: Ben Schlegel Date: Sat, 23 Sep 2023 13:45:13 +0200 Subject: [PATCH] feat: use default og image if no path exists --- quartz/components/Head.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quartz/components/Head.tsx b/quartz/components/Head.tsx index 946231ffe..d4a4944bd 100644 --- a/quartz/components/Head.tsx +++ b/quartz/components/Head.tsx @@ -131,13 +131,15 @@ export default (() => { const baseDir = fileData.slug === "404" ? path : pathToRoot(fileData.slug!) const iconPath = joinSegments(baseDir, "static/icon.png") - // TODO: use default image if undefined + const useDefaultOgImage = filePath === undefined const ogImageDefaultPath = `https://${cfg.baseUrl}/static/og-image.png` - const ogImagePath = `https://${cfg.baseUrl}/${imageDir.replace( + const ogImageGeneratedPath = `https://${cfg.baseUrl}/${imageDir.replace( "public/", "", )}/${filePath}.${extension}` + const ogImagePath = useDefaultOgImage ? ogImageDefaultPath : ogImageGeneratedPath + return ( {title}