-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathseo.jsx
More file actions
261 lines (251 loc) · 7.7 KB
/
seo.jsx
File metadata and controls
261 lines (251 loc) · 7.7 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
* SEO component that queries for data with
* Gatsby's useStaticQuery React hook
*
* See: https://www.gatsbyjs.org/docs/use-static-query/
*/
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import { useStaticQuery, graphql } from 'gatsby';
import favicon from './../images/favicon.ico';
function SEO({
lang,
meta,
title,
slug,
canonical,
metadesc,
keywords,
social_share_summary,
social_share_desc,
social_share_image,
noindex,
}) {
const { site } = useStaticQuery(
graphql`
query {
site {
siteMetadata {
title
description
author
}
}
}
`
);
const isIndexed = !noindex ? 'index,follow' : 'noindex,nofollow';
let loadGTM = false;
if (typeof window !== 'undefined') {
loadGTM =
window.location.href.includes('testsigma.com') ||
window.location.href.includes('https://www.testsigma.com/') ||
window.location.href.includes('https://testsigma.com/');
}
useEffect(() => {
if (loadGTM) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = `
(function(w,d,s,l,i){
w[l]=w[l]||[];
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5F8HTVT');
`;
document.head.appendChild(script);
}
}, []);
return (
<>
<Helmet
htmlAttributes={{
lang,
}}
title={title}
titleTemplate={`%s | ${site.siteMetadata.title}`}
meta={[
{
name: 'description',
content: metadesc,
},
{
name: 'keywords',
content: keywords,
},
{
name: 'google-site-verification',
content: '58TM3lGyGn6c2Bj0PvPQSNzrd9_yBsHs2BjJ6KMHlRU',
},
{
property: 'og:title',
content: title,
},
{
property: 'og:description',
content: social_share_desc,
},
{
property: 'og:image',
content: social_share_image,
},
{
property: 'og:url',
content: `https://testsigma.com${slug}`,
},
{
property: 'og:type',
content: 'website',
},
{
property: 'og:site_name',
content: 'Testsigma Tutorials',
},
{
name: 'twitter:creator',
content: site.siteMetadata.author,
},
{
name: 'twitter:card',
content: social_share_summary,
},
{
name: 'twitter:title',
content: title,
},
{
property: 'twitter:description',
content: social_share_desc,
},
{
property: 'twitter:image',
content: social_share_image,
},
{
property: 'twitter:domain',
content: `https://testsigma.com${slug}`,
},
{
property: 'twitter:site',
content: '@testsigmainc',
},
{
name: 'robots',
content: isIndexed,
},
].concat(meta)}
>
{/* fav icon */}
<link rel='icon' href={favicon} />
<link
rel='apple-touch-icon'
sizes='144x144'
href={'./../images/favicons/apple-touch-icon.png'}
/>
<link
rel='icon'
type='image/png'
sizes='48x48'
href={'./../images/favicons/favicon-48x48.png'}
/>
<link
rel='icon'
type='image/png'
sizes='32x32'
href={'./../images/favicons/favicon-32x32.png'}
/>
<link
rel='icon'
type='image/png'
sizes='16x16'
href={'./../images/favicons/favicon-16x16.png'}
/>
<link rel='manifest' href={'./../images/favicons/site.webmanifest'} />
<link
rel='mask-icon'
href={'./../images/favicons/safari-pinned-tab.svg'}
color='#00B2BD'
/>
{/* fonts */}
<link rel='dns-prefetch' href='https://fonts.gstatic.com' />
<link rel='dns-prefetch' href='https://fonts.googleapis.com' />
<link crossOrigin rel='preconnect' href='https://fonts.gstatic.com' />
<link
href='https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400&display=swap'
rel='stylesheet'
/>
<link
href='https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400&display=swap'
rel='stylesheet'
/>
{/* <link href="https://fonts.googleapis.com/css?family=Roboto:400,500&display=swap" rel="stylesheet" /> */}
{/* <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap" rel="stylesheet" /> */}
{/* Bootstrap */}
{/* <link rel="dns-prefetch" href="https://stackpath.bootstrapcdn.com" /> */}
{/* <link crossOrigin rel="preconnect" href="https://stackpath.bootstrapcdn.com" /> */}
{/* <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossOrigin="anonymous" /> */}
{/* canonical */}
{canonical ? (
<link rel='canonical' href={canonical} />
) : (
<link rel='canonical' href={`https://testsigma.com${slug}`} />
)}
{/* Algolia Instantsearch IE11 support v3 */}
{/* <script src="https://polyfill.io/v3/polyfill.min.js?features=default,Array.prototype.find,Array.prototype.includes" /> */}
{/* */}
{/* Algolia Instantsearch IE11 support v4 */}
<link rel='dns-prefetch' href='https://polyfill.io' />
<link crossOrigin rel='preconnect' href='https://polyfill.io' />
<script src='https://polyfill.io/v3/polyfill.min.js?features=default%2CArray.prototype.find%2CArray.prototype.includes%2CPromise%2CObject.assign%2CObject.entries' />
{/* Algolia API v4 IE11 support */}
<script src='https://polyfill.io/v3/polyfill.min.js?features=Promise%2CObject.entries%2CObject.assign' />
<script
async
defer
type='text/javascript'
charSet='utf-8'
src='https://js.hsforms.net/forms/embed/v2.js'
/>
<script
type='text/javascript'
id='hs-script-loader'
async
defer
src='//js.hs-scripts.com/23341221.js'
></script>
</Helmet>
{loadGTM && (
<>
<noscript>
{`
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5F8HTVT"
height="0" width="0" style="display:none;visibility:hidden">
</iframe>
`}
</noscript>
</>
)}
</>
);
}
SEO.defaultProps = {
lang: 'en',
meta: [],
};
SEO.propTypes = {
lang: PropTypes.string,
meta: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string.isRequired,
canonical: PropTypes.string,
metadesc: PropTypes.string,
keywords: PropTypes.string,
social_share_summary: PropTypes.string,
social_share_desc: PropTypes.string,
social_share_image: PropTypes.string,
noindex: PropTypes.bool,
};
export default SEO;