Skip to content

Commit a3dd4c0

Browse files
authored
@W-17643479@ Add page meta data to search results and product pages (#2282)
* Add page meta data to search results and product pages * Changelog * Apply suggestions --------- Signed-off-by: vcua-mobify <47404250+vcua-mobify@users.noreply.github.com>
1 parent 62a39a2 commit a3dd4c0

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

packages/template-retail-react-app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## v6.1.0-dev (Feb 18, 2025)
22

33
- Fix hreflang alternate links [#2269](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2269)
4+
- PDP / PLP: Add page meta data tags that have been defined in BM [#2232](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2232)
45

56
## v6.0.0 (Feb 18, 2025)
67

packages/template-retail-react-app/app/pages/product-detail/index.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ const ProductDetail = () => {
9999
'prices',
100100
'variations',
101101
'set_products',
102-
'bundled_products'
102+
'bundled_products',
103+
'page_meta_tags'
103104
],
104105
allImages: true
105106
}
@@ -455,7 +456,15 @@ const ProductDetail = () => {
455456
>
456457
<Helmet>
457458
<title>{product?.pageTitle}</title>
458-
<meta name="description" content={product?.pageDescription} />
459+
{product?.pageMetaTags?.length > 0 &&
460+
product.pageMetaTags.map(({id, value}) => (
461+
<meta name={id} content={value} key={id} />
462+
))}
463+
{/* Fallback for description if not included in pageMetaTags */}
464+
{!product?.pageMetaTags?.some((tag) => tag.id === 'description') &&
465+
product?.pageDescription && (
466+
<meta name="description" content={product.pageDescription} />
467+
)}
459468
</Helmet>
460469

461470
<Stack spacing={16}>

packages/template-retail-react-app/app/pages/product-list/index.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,14 @@ const ProductList = (props) => {
159159
perPricebook: true,
160160
allVariationProperties: true,
161161
allImages: true,
162-
expand: ['promotions', 'variations', 'prices', 'images', 'custom_properties'],
162+
expand: [
163+
'promotions',
164+
'variations',
165+
'prices',
166+
'images',
167+
'page_meta_tags',
168+
'custom_properties'
169+
],
163170
refine: _refine
164171
}
165172
},
@@ -411,6 +418,9 @@ const ProductList = (props) => {
411418
<title>{category?.pageTitle ?? searchQuery}</title>
412419
<meta name="description" content={category?.pageDescription ?? searchQuery} />
413420
<meta name="keywords" content={category?.pageKeywords} />
421+
{productSearchResult?.pageMetaTags?.map(({id, value}) => {
422+
return <meta name={id} content={value} key={id} />
423+
})}
414424
</Helmet>
415425
{showNoResults ? (
416426
<EmptySearchResults searchQuery={searchQuery} category={category} />

0 commit comments

Comments
 (0)