Skip to content

Commit

Permalink
Use default SEO information to set SEO defaults in layout
Browse files Browse the repository at this point in the history
  • Loading branch information
bookernath committed Jul 28, 2024
1 parent 6f46f00 commit 20f9381
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ const RootLayoutMetadataQuery = graphql(`
site {
settings {
storeName
seo {
pageTitle
metaDescription
metaKeywords
}
}
}
}
Expand All @@ -37,13 +42,17 @@ export async function generateMetadata(): Promise<Metadata> {
fetchOptions: { next: { revalidate } },
});

const title = data.site.settings?.storeName ?? '';
const storeName = data.site.settings?.storeName ?? '';

const { pageTitle, metaDescription, metaKeywords } = data.site.settings?.seo || {};

return {
title: {
template: `${title} - %s`,
default: title,
template: `%s - ${storeName}`,
default: pageTitle || storeName,
},
description: metaDescription,
keywords: metaKeywords ? metaKeywords.split(',') : null,
other: {
platform: 'bigcommerce.catalyst',
build_sha: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA ?? '',
Expand Down

0 comments on commit 20f9381

Please sign in to comment.