-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSEO.js
More file actions
49 lines (44 loc) · 1.85 KB
/
Copy pathSEO.js
File metadata and controls
49 lines (44 loc) · 1.85 KB
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
import React from 'react'
import Helmet from 'react-helmet'
import { withPrefix } from 'gatsby'
import siteConfig from '../../data/siteConfig'
class SEO extends React.Component {
render() {
const { isBlogPost, path = '', lang = 'en' } = this.props
const title = this.props.title
? `${this.props.title} | ${siteConfig.siteTitle}`
: siteConfig.siteTitle
const formatedSiteUrl = siteConfig.siteUrl.substring(
0,
siteConfig.siteUrl.length - 1
)
const imagePath =
this.props.imageFb || this.props.cover || withPrefix(siteConfig.siteCover)
const imagePathTwitter =
this.props.imageTw || this.props.cover || withPrefix(siteConfig.siteCover)
const image = `${formatedSiteUrl}${imagePath}`
const imageTwitter = `${formatedSiteUrl}${imagePathTwitter}`
const description = this.props.description || siteConfig.siteDescription
return (
<Helmet title={title}>
{/* General tags */}
<html lang={lang} />
<meta name="description" content={description} />
<link rel="canonical" href={formatedSiteUrl + withPrefix(path)} />
{/* OpenGraph tags */}
<meta property="og:url" content={formatedSiteUrl + withPrefix(path)} />
<meta property="og:type" content={isBlogPost ? 'article' : 'website'} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={image} />
{/* Twitter Card tags */}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:creator" content={siteConfig.twitterUsername} />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={imageTwitter} />
</Helmet>
)
}
}
export default SEO