-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): add properties on structure data organization
feat(react): add properties on structure data organization Revert "fix(react|redux): commerce pages in ssr not working" This reverts commit 7bd944a.
- Loading branch information
1 parent
24ca467
commit 525a58b
Showing
11 changed files
with
281 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/react/src/contents/structured-data/schemas/schemaPotentialAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as schemaProperties from './schemaProperties.js'; | ||
import generateSchemaOrgProperty from '../../utils/generateSchemaOrgProperty.js'; | ||
import type { CustomSearchAction } from '../../types/index.js'; | ||
import type { SEOMetadata } from '@farfetch/blackout-client'; | ||
|
||
/** | ||
* Generate a schema for Potential Action. | ||
* | ||
* @example | ||
* ``` | ||
* const potencialActioin = schemaPotentialAction(searchTitle, urlTemplate, metadata); | ||
* ``` | ||
* | ||
* @param searchTitle - Website title. | ||
* @param urlTemplate - Complete url to query on. | ||
* @param metadata - SEO metadata for type WebsiteSearch on Homepage. | ||
* | ||
* @returns - An object with Potential Action JSON-LD structured data. | ||
*/ | ||
const schemaPotentialAction = ( | ||
searchTitle: string, | ||
urlTemplate: string, | ||
metadata: SEOMetadata, | ||
): CustomSearchAction => ({ | ||
'@type': schemaProperties.DEFAULT_TYPE_ACTION, | ||
name: | ||
generateSchemaOrgProperty('homepage:searchTitle', metadata) || searchTitle, | ||
target: { | ||
'@type': schemaProperties.DEFAULT_TYPE_TARGET, | ||
urlTemplate: | ||
generateSchemaOrgProperty('homepage:searchUrl', metadata) || | ||
`${urlTemplate}{search_term_string}`, | ||
}, | ||
'query-input': { | ||
'@type': schemaProperties.DEFAULT_TYPE_INPUT, | ||
valueRequired: 'True', | ||
valueName: 'search_term_string', | ||
}, | ||
}); | ||
|
||
export default schemaPotentialAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.