Skip to content

Commit

Permalink
feat(seo): include default SEO image url in OpenGraph image
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Sep 9, 2024
1 parent 3187d23 commit 7baacf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/seo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type CompanyInfo = {
brandAssets: {
favicon: string;
};
defaultSEO: SeoData;
};

export async function fetchSeoData(
Expand Down Expand Up @@ -95,12 +96,14 @@ export async function generateMetadataFromSeo(
title: title,
...(description ? { description: description } : {}),
})}`;
const imageUrl =
seo?.imageUrl || companyInfo?.defaultSEO?.imageUrl || fallbackImageUrl;

return {
title: title,
description: description,
openGraph: {
images: [seo?.imageUrl ?? fallbackImageUrl],
images: [imageUrl],
},
icons: { icon: icons },
keywords: keywords,
Expand Down
6 changes: 6 additions & 0 deletions studio/lib/queries/companyInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ import { groq } from "next-sanity";
export const COMPANY_INFO_QUERY = groq`*[_type == "companyInfo"]{
brandAssets,
siteMetadata,
defaultSEO {
"title": seoTitle,
"description": seoDescription,
"keywords": seoKeywords,
"imageUrl": seoImage.asset->url
},
legalPages,
}[0]`;

0 comments on commit 7baacf7

Please sign in to comment.