2021-03-23 12:07:19 +00:00
|
|
|
/**
|
|
|
|
* SEO component that queries for data with
|
|
|
|
* Gatsby's useStaticQuery React hook
|
|
|
|
*
|
|
|
|
* See: https://www.gatsbyjs.com/docs/use-static-query/
|
|
|
|
*/
|
|
|
|
|
2021-03-31 11:24:05 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import { Helmet } from "react-helmet";
|
|
|
|
import { useStaticQuery, graphql } from "gatsby";
|
2021-03-23 12:07:19 +00:00
|
|
|
|
|
|
|
function SEO({ description, lang, meta, title }) {
|
|
|
|
const { site } = useStaticQuery(
|
|
|
|
graphql`
|
|
|
|
query {
|
|
|
|
site {
|
|
|
|
siteMetadata {
|
|
|
|
title
|
|
|
|
description
|
|
|
|
author
|
2021-03-31 11:24:05 +00:00
|
|
|
image
|
2021-03-23 12:07:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2021-03-31 11:24:05 +00:00
|
|
|
);
|
2021-03-23 12:07:19 +00:00
|
|
|
|
2021-04-01 17:11:24 +00:00
|
|
|
const { title: siteTitle, description: siteDescription } = site.siteMetadata;
|
|
|
|
const pageDescription = description || siteDescription;
|
2021-03-23 12:07:19 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Helmet
|
|
|
|
htmlAttributes={{
|
|
|
|
lang,
|
|
|
|
}}
|
|
|
|
title={title}
|
2021-04-01 17:11:24 +00:00
|
|
|
titleTemplate={`%s | ${siteTitle}`}
|
2021-03-23 12:07:19 +00:00
|
|
|
meta={[
|
|
|
|
{
|
|
|
|
name: `description`,
|
2021-04-01 17:11:24 +00:00
|
|
|
content: pageDescription,
|
2021-03-23 12:07:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:title`,
|
2021-04-01 17:11:24 +00:00
|
|
|
content: `${title} | ${siteTitle}`,
|
2021-03-23 12:07:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:description`,
|
2021-04-01 17:11:24 +00:00
|
|
|
content: pageDescription,
|
2021-03-23 12:07:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:type`,
|
|
|
|
content: `website`,
|
|
|
|
},
|
2021-03-31 11:24:05 +00:00
|
|
|
{
|
|
|
|
property: `og:image`,
|
|
|
|
content: site.siteMetadata?.image || "",
|
|
|
|
},
|
2021-03-23 12:07:19 +00:00
|
|
|
{
|
|
|
|
name: `twitter:card`,
|
|
|
|
content: `summary`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:creator`,
|
|
|
|
content: site.siteMetadata?.author || ``,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:title`,
|
|
|
|
content: title,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:description`,
|
2021-04-01 17:11:24 +00:00
|
|
|
content: pageDescription,
|
2021-03-23 12:07:19 +00:00
|
|
|
},
|
|
|
|
].concat(meta)}
|
|
|
|
/>
|
2021-03-31 11:24:05 +00:00
|
|
|
);
|
2021-03-23 12:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SEO.defaultProps = {
|
|
|
|
lang: `en`,
|
|
|
|
meta: [],
|
|
|
|
description: ``,
|
2021-03-31 11:24:05 +00:00
|
|
|
};
|
2021-03-23 12:07:19 +00:00
|
|
|
|
|
|
|
SEO.propTypes = {
|
|
|
|
description: PropTypes.string,
|
|
|
|
lang: PropTypes.string,
|
|
|
|
meta: PropTypes.arrayOf(PropTypes.object),
|
|
|
|
title: PropTypes.string.isRequired,
|
2021-03-31 11:24:05 +00:00
|
|
|
};
|
2021-03-23 12:07:19 +00:00
|
|
|
|
2021-03-31 11:24:05 +00:00
|
|
|
export default SEO;
|