Add Schema Component
This commit is contained in:
parent
a16bc7ae99
commit
2c52850d63
1 changed files with 48 additions and 0 deletions
48
src/components/Schema.js
Normal file
48
src/components/Schema.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
const Schema = ({
|
||||
name,
|
||||
address,
|
||||
email,
|
||||
phone: telephone,
|
||||
url,
|
||||
logoUrl,
|
||||
type,
|
||||
openingHours
|
||||
}) => {
|
||||
// see http://schema.org/docs/schemas.html
|
||||
|
||||
const data = {
|
||||
'@context': 'http://schema.org/',
|
||||
'@type': type,
|
||||
address: {
|
||||
'@type': 'PostalAddress',
|
||||
streetAddress: address
|
||||
},
|
||||
name,
|
||||
email,
|
||||
telephone,
|
||||
url,
|
||||
openingHours
|
||||
}
|
||||
|
||||
return (
|
||||
<script
|
||||
type='application/ld+json'
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Schema.propTypes = {
|
||||
type: PropTypes.string, // schema type e.g. LocalBusiness
|
||||
name: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
address: PropTypes.string,
|
||||
email: PropTypes.string,
|
||||
phone: PropTypes.string,
|
||||
logoUrl: PropTypes.string
|
||||
}
|
||||
|
||||
export default Schema
|
||||
Loading…
Add table
Reference in a new issue