This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/website/src/components/seo.js

95 lines
1.9 KiB
JavaScript
Raw Normal View History

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-03-31 11:24:05 +00:00
const metaDescription = description || site.siteMetadata.description;
const defaultTitle = site.siteMetadata?.title;
2021-03-23 12:07:19 +00:00
return (
<Helmet
htmlAttributes={{
lang,
}}
title={title}
titleTemplate={defaultTitle ? `%s | ${defaultTitle}` : null}
meta={[
{
name: `description`,
content: metaDescription,
},
{
property: `og:title`,
content: title,
},
{
property: `og:description`,
content: metaDescription,
},
{
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`,
content: metaDescription,
},
].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;