-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathpage-metadata.jsx
More file actions
48 lines (43 loc) · 1.69 KB
/
page-metadata.jsx
File metadata and controls
48 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright (c) 2025, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import PropTypes from 'prop-types'
import Seo from '../../components/seo'
/**
* Metadata component for the product detail page.
* @param {Object} product - The product object
* @param {string} product.pageTitle - The title of the product
* @param {string} product.pageDescription - The description of the product
* @param {string} product.pageKeywords - The keywords of the product
* @param {Array} product.pageMetaTags - The meta tags of the product
* @param {string} product.pageMetaTags.id - The id of the meta tag
* @param {string} product.pageMetaTags.value - The value of the meta tag
*/
export default function PageMetadata({product}) {
if (!product) {
return null
}
const metaTags = product.pageMetaTags || []
const title = product.pageTitle
const keywords = metaTags.find((tag) => tag.id === 'keywords')?.value || product.pageKeywords
const description =
metaTags.find((tag) => tag.id === 'description')?.value || product.pageDescription
return <Seo title={title} description={description} keywords={keywords} metaTags={metaTags} />
}
PageMetadata.propTypes = {
product: PropTypes.shape({
pageTitle: PropTypes.string,
pageDescription: PropTypes.string,
pageKeywords: PropTypes.string,
pageMetaTags: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
value: PropTypes.string.isRequired
})
)
})
}