gatsby-pingbot/src/components/seo.js

72 lines
1.3 KiB
JavaScript

import React from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import PropTypes from 'prop-types'
import { Helmet } from 'react-helmet'
function Seo(props) {
const { site } = useStaticQuery(
graphql`
query {
site {
siteMetadata {
siteName
description
}
}
}
`
)
const defaultDesc = props.description || site.siteMetadata.description
let title = site.siteMetadata.siteName
if (props.title && props.title != '') {
title = props.title + ' - ' + title
}
return (
<Helmet
title={title}
meta={[
{
name: 'description',
content: defaultDesc,
},
{
property: 'og:title',
content: title,
},
{
property: 'og:description',
content: defaultDesc,
},
{
property: 'og:type',
content: 'website',
},
{
property: 'theme-color',
content: props.embedColor
}
].concat(props.meta)}
/>
)
}
Seo.defaultProps = {
lang: 'en',
meta: [],
embedColor: '#9517cf'
}
Seo.propTypes = {
description: PropTypes.string,
lang: PropTypes.string,
meta: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string,
embedColor: PropTypes.string
}
export default Seo