From 2acfa0fa238f193332db4605a5f1ce666334717b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Wed, 5 Mar 2025 17:13:19 -0800 Subject: [PATCH] fix(og-image): overflow ellipses in title and description --- quartz.config.ts | 2 +- quartz/components/Head.tsx | 2 +- quartz/util/og.tsx | 51 +++++++++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/quartz.config.ts b/quartz.config.ts index 6c89215..0cd7e94 100644 --- a/quartz.config.ts +++ b/quartz.config.ts @@ -19,7 +19,7 @@ const config: QuartzConfig = { baseUrl: "quartz.jzhao.xyz", ignorePatterns: ["private", "templates", ".obsidian"], defaultDateType: "created", - generateSocialImages: false, + generateSocialImages: true, theme: { fontOrigin: "googleFonts", cdnCaching: true, diff --git a/quartz/components/Head.tsx b/quartz/components/Head.tsx index 3a4db10..983dc50 100644 --- a/quartz/components/Head.tsx +++ b/quartz/components/Head.tsx @@ -98,7 +98,7 @@ export default (() => { if (fileName) { // Generate social image (happens async) - generateSocialImage( + void generateSocialImage( { title, description, diff --git a/quartz/util/og.tsx b/quartz/util/og.tsx index 42b9b27..4d675cb 100644 --- a/quartz/util/og.tsx +++ b/quartz/util/og.tsx @@ -143,12 +143,10 @@ export const defaultImage: SocialImageOptions["imageStructure"] = ( fonts: SatoriOptions["fonts"], _fileData: QuartzPluginData, ) => { - // How many characters are allowed before switching to smaller font const fontBreakPoint = 22 const useSmallerFont = title.length > fontBreakPoint - - // Setup to access image const iconPath = `https://${cfg.baseUrl}/static/icon.png` + return (
-

- {title} -

+

+ {title} +

+
-

- {description} -

+

+ {description} +

+ ) }