fix: duplicated structured data in product search context #671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is this solving?
This commit has the intention to fix the duplicated array of itemList in structured data , that occurs on PLP pages. Google rich result is complaining about this duplicated node element causing some crawling issues
We found out that there are two occurrences of ProductListStructuredData in the same PLP.
The SearchWrapper element from
vtex-apps/store
is responsible for the first.Gallery
andvtex.search-result
is responsible for the otherWhat happens is that when in search context we add the structured data, and, in search context, we also use gallery, which is also adding the structured data.
The main purpose is to check if the block is under the context of store.search to check if it's going to add the structured data element or not
This PR simply adds this validation to understand in which context the gallery is being used to avoid duplicated node content
How to test it?
Before
Steps to reproduce:
{"@context":"https://schema.org","@type":"ItemList","itemListElement"
Expected Behavior:
After
Steps to reproduce:
{"@context":"https://schema.org","@type":"ItemList","itemListElement"
Expected Behavior:
SearchWrapper
componentDescribe alternatives you've considered, if any.
We adopted this approach instead of removing it from store.search the gallery component just to be safe, avoiding any undesired behavior since we don't know exactly the side effects that this might cause
How does this PR make you feel?