gatsby-pingbot/src/components/seo.js

67 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-08-19 21:13:03 +00:00
import React from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import PropTypes from 'prop-types'
import { Helmet } from 'react-helmet'
2021-08-04 19:17:51 +00:00
function Seo(props) {
const { site } = useStaticQuery(
graphql`
query {
site {
siteMetadata {
title
description
}
}
}
`
)
const defaultDesc = props.description || site.siteMetadata.description
const defaultTitle = site.siteMetadata?.title
return (
<Helmet
2021-08-19 21:13:03 +00:00
title={props.title + ' - ' + defaultTitle}
2021-08-04 19:17:51 +00:00
meta={[
{
2021-08-19 21:13:03 +00:00
name: 'description',
2021-08-04 19:17:51 +00:00
content: defaultDesc,
},
{
2021-08-19 21:13:03 +00:00
property: 'og:title',
2021-08-04 19:17:51 +00:00
content: props.title || defaultTitle,
},
{
2021-08-19 21:13:03 +00:00
property: 'og:description',
2021-08-04 19:17:51 +00:00
content: defaultDesc,
},
{
2021-08-19 21:13:03 +00:00
property: 'og:type',
content: 'website',
2021-08-04 19:17:51 +00:00
},
{
2021-08-19 21:13:03 +00:00
property: 'theme-color',
2021-08-04 19:17:51 +00:00
content: props.embedColor
}
].concat(props.meta)}
/>
)
}
Seo.defaultProps = {
2021-08-19 21:13:03 +00:00
lang: 'en',
2021-08-04 19:17:51 +00:00
meta: [],
2021-08-19 21:13:03 +00:00
embedColor: '#9517cf'
2021-08-04 19:17:51 +00:00
}
Seo.propTypes = {
description: PropTypes.string,
lang: PropTypes.string,
meta: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string,
embedColor: PropTypes.string
}
export default Seo