diff --git a/src/utils/seo.ts b/src/utils/seo.ts index 7a2fb2113..c8324a53a 100644 --- a/src/utils/seo.ts +++ b/src/utils/seo.ts @@ -81,8 +81,12 @@ export async function generateMetadataFromSeo( ): Promise { const companyInfo = await fetchCompanyInfo(); - const title = seo?.title || companyInfo?.siteMetadata?.siteName || "Variant"; - const description = seo?.description; + const title = + seo?.title || + companyInfo?.defaultSEO?.title || + companyInfo?.siteMetadata?.siteName || + "Variant"; + const description = seo?.description || companyInfo?.defaultSEO?.description; const keywords = seo?.keywords || ""; const favicon = companyInfo?.brandAssets?.favicon; @@ -96,8 +100,17 @@ export async function generateMetadataFromSeo( title: title, ...(description ? { description: description } : {}), })}`; - const imageUrl = - seo?.imageUrl || companyInfo?.defaultSEO?.imageUrl || fallbackImageUrl; + const sanityImageUrl = seo?.imageUrl || companyInfo?.defaultSEO?.imageUrl; + const sanityImageParams = `?${new URLSearchParams({ + w: "1200", + h: "630", + fit: "fill", + fm: "png", // required for transparent + bg: "00000000", // transparent + })}`; + const imageUrl = sanityImageUrl + ? `${sanityImageUrl}${sanityImageParams}` + : fallbackImageUrl; return { title: title,