Skip to content

Commit

Permalink
fix: duplicated structured data in product search context
Browse files Browse the repository at this point in the history
  • Loading branch information
iago1501 committed Sep 30, 2024
1 parent 600e4a9 commit ba78b6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Duplicated structured data in product search context

## [3.133.0] - 2024-08-01

### Added
Expand Down
9 changes: 8 additions & 1 deletion react/Gallery.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Fragment } from 'react'
import { ProductList as ProductListStructuredData } from 'vtex.structured-data'
import { useRuntime } from 'vtex.render-runtime'

import GalleryLayout from './GalleryLayout'
import type { GalleryLayoutProps, Slots } from './GalleryLayout'
Expand All @@ -16,6 +17,10 @@ type GalleryLayoutPropsWithSlots = Omit<GalleryLayoutProps, 'slots'> & Slots
const Gallery: React.FC<
GalleryLegacyProps | GalleryLayoutPropsWithSlots
> = props => {
const {
route: { routeId },
} = useRuntime()

if ('layouts' in props && props.layouts.length > 0) {
const {
layouts,
Expand All @@ -29,7 +34,9 @@ const Gallery: React.FC<

return (
<Fragment>
<ProductListStructuredData products={products} />
{!routeId.includes('store.search') && (
<ProductListStructuredData products={products} />
)}
<GalleryLayout
layouts={layouts}
lazyItemsRemaining={lazyItemsRemaining}
Expand Down

0 comments on commit ba78b6e

Please sign in to comment.