Add Schema Component

This commit is contained in:
Eric Jinks 2018-02-01 09:28:52 +10:00
parent a16bc7ae99
commit 2c52850d63

48
src/components/Schema.js Normal file
View 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