Skip to content

Commit

Permalink
feat(pdc-frontend): integrate open graph image into frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
AliKdhim87 committed Oct 30, 2023
1 parent b2f957f commit 5da013b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/pdc-frontend/src/app/[locale]/products/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export async function generateMetadata({ params }: any): Promise<Metadata> {
const { product } = await getAllProducts(params?.locale, params?.slug);
const title = product?.attributes?.metaTags?.title;
const description = product?.attributes?.metaTags?.description;
const openGraphImage = product?.attributes?.metaTags?.ogImage?.data?.attributes?.url;

return {
title,
description,
Expand All @@ -74,6 +76,7 @@ export async function generateMetadata({ params }: any): Promise<Metadata> {
openGraph: {
title: `${title} | ${t('website-setting.website-name')}`,
description,
images: openGraphImage && getImageBaseUrl() && `${getImageBaseUrl()}${openGraphImage}`,
locale: params?.locale,
url: `${process.env.FRONTEND_PUBLIC_URL}/${params?.locale}/products/${params?.slug}`,
siteName: t('website-setting.website-name') || 'Gemeente Utrecht',
Expand Down
7 changes: 7 additions & 0 deletions apps/pdc-frontend/src/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export const GET_PRODUCT_BY_SLUG_FETCH = gql(`
title
description
keymatch
ogImage {
data {
attributes {
url
}
}
}
}
content
sections {
Expand Down

0 comments on commit 5da013b

Please sign in to comment.