/
SEOContainer.js
69 lines (61 loc) · 2.59 KB
/
SEOContainer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ─────────────────────────────────────────────────────────────────────────────
// import
// ─────────────────────────────────────────────────────────────────────────────
import React from 'react';
import { Helmet } from 'react-helmet';
import { graphql, useStaticQuery } from 'gatsby';
import { metaPropTypes } from '~utils';
// ─────────────────────────────────────────────────────────────────────────────
// component
// ─────────────────────────────────────────────────────────────────────────────
export default function SEOContainer({ meta: { title, description, permalink, ogImage } }) {
const {
site: {
siteMetadata: { siteUrl, siteTitle },
},
} = useStaticQuery(graphql`
{
site {
siteMetadata {
siteUrl
siteTitle
}
}
}
`);
return (
<Helmet
title={title}
titleTemplate={`%s | ${siteTitle}`}
meta={[
{ name: 'description', content: description },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:site', content: '@mrozilla' },
{ name: 'twitter:title', content: title },
{ name: 'twitter:description', content: description },
{ name: 'twitter:creator', content: '@mrozilla' },
{
name: 'twitter:image',
content: `${siteUrl}${ogImage.childImageSharp.resize.src}`,
},
{ property: 'og:title', content: `${title}` },
{ property: 'og:type', content: 'website' },
{ property: 'og:url', content: `${siteUrl}${permalink}` },
{
property: 'og:image',
content: `${siteUrl}${ogImage.childImageSharp.resize.src}`,
},
{ property: 'og:description', content: description },
{ property: 'fb:app_id', content: process.env.GATSBY_FB_APP_ID },
]}
link={[
{
rel: 'canonical',
href: `${siteUrl}${permalink}`,
},
]}
htmlAttributes={{ lang: 'en' }}
/>
);
}
SEOContainer.propTypes = metaPropTypes;