Skip to content

Commit

Permalink
feat(openGraph): ensure 1200x630 with transparent fill
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Sep 10, 2024
1 parent bd1df00 commit b74e7e3
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/utils/seo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ export async function generateMetadataFromSeo(
): Promise<Metadata> {
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;
Expand All @@ -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,
Expand Down

0 comments on commit b74e7e3

Please sign in to comment.