2020-07-13 09:45:24 +00:00
|
|
|
import React from "react"
|
|
|
|
import PropTypes from "prop-types"
|
|
|
|
import { Helmet } from "react-helmet"
|
|
|
|
import { useStaticQuery, graphql } from "gatsby"
|
|
|
|
import ogThumbnail from "@images/og_thumbnail.png"
|
|
|
|
|
2020-07-13 17:04:46 +00:00
|
|
|
function SEO({ description, lang, meta, title, pathname }) {
|
2020-07-13 09:45:24 +00:00
|
|
|
const { site } = useStaticQuery(
|
|
|
|
graphql`
|
|
|
|
query {
|
|
|
|
site {
|
|
|
|
siteMetadata {
|
|
|
|
title
|
|
|
|
description
|
|
|
|
siteUrl
|
2021-01-16 20:58:43 +00:00
|
|
|
authorTwitter
|
2020-07-13 09:45:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
)
|
|
|
|
|
|
|
|
const metaDescription = description || site.siteMetadata.description
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Helmet
|
|
|
|
htmlAttributes={{
|
|
|
|
lang,
|
|
|
|
}}
|
2021-01-16 20:58:43 +00:00
|
|
|
title={title ?? site.siteMetadata.title}
|
|
|
|
titleTemplate={title ? `%s | ${site.siteMetadata.title}` : "%s"}
|
2020-07-13 09:45:24 +00:00
|
|
|
meta={[
|
|
|
|
{
|
|
|
|
name: `description`,
|
|
|
|
content: metaDescription,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:site_name`,
|
|
|
|
content: site.siteMetadata.title,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:title`,
|
|
|
|
content: title,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:description`,
|
|
|
|
content: metaDescription,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:url`,
|
2020-07-13 17:04:46 +00:00
|
|
|
content: `${site.siteMetadata.siteUrl}${pathname}`,
|
2020-07-13 09:45:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:image`,
|
|
|
|
content: `${site.siteMetadata.siteUrl}${ogThumbnail}`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:image:width`,
|
|
|
|
content: `400`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:image:height`,
|
|
|
|
content: `400`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:image`,
|
|
|
|
content: `website`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: `og:locale`,
|
|
|
|
content: `pl`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:creator`,
|
2021-01-16 20:58:43 +00:00
|
|
|
content: site.siteMetadata.authorTwitter,
|
2020-07-13 09:45:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:card`,
|
|
|
|
content: `summary_large_image`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:title`,
|
|
|
|
content: title,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:description`,
|
|
|
|
content: metaDescription,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:url`,
|
2020-07-13 17:04:46 +00:00
|
|
|
content: `${site.siteMetadata.siteUrl}${pathname}`,
|
2020-07-13 09:45:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:image`,
|
|
|
|
content: `${site.siteMetadata.siteUrl}${ogThumbnail}`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: `twitter:image:alt`,
|
|
|
|
content: site.siteMetadata.title,
|
|
|
|
},
|
|
|
|
].concat(meta)}
|
|
|
|
>
|
|
|
|
<link
|
|
|
|
rel="canonical"
|
2020-07-13 17:04:46 +00:00
|
|
|
content={`${site.siteMetadata.siteUrl}${pathname}`}
|
2020-07-13 09:45:24 +00:00
|
|
|
></link>
|
|
|
|
</Helmet>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
SEO.defaultProps = {
|
|
|
|
lang: `pl`,
|
|
|
|
meta: [],
|
|
|
|
description: ``,
|
|
|
|
}
|
|
|
|
|
|
|
|
SEO.propTypes = {
|
|
|
|
description: PropTypes.string,
|
|
|
|
lang: PropTypes.string,
|
|
|
|
meta: PropTypes.arrayOf(PropTypes.object),
|
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SEO
|