forked from nilbuild/developer-roadmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelmet.tsx
More file actions
165 lines (152 loc) · 4.68 KB
/
helmet.tsx
File metadata and controls
165 lines (152 loc) · 4.68 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
import NextHead from 'next/head';
import siteConfig from '../content/site.json';
import { RoadmapType } from '../lib/roadmap';
import { roadmapTheme } from '../styles/theme';
type HelmetProps = {
title?: string;
keywords?: string[];
canonical?: string;
description?: string;
roadmap?: RoadmapType;
};
function getRichSnippetJson(roadmap: RoadmapType) {
return {
'@context': 'https://schema.org',
'@type': 'Article',
mainEntityOfPage: {
'@type': 'WebPage',
'@id': `https://roadmap.sh/${roadmap.id}`,
},
headline: roadmap.seo.title,
description: roadmap.seo.description,
image: roadmap.jsonUrl
? `https://roadmap.sh/roadmaps/${roadmap.id}.png`
: undefined,
author: {
'@type': 'Person',
name: 'Kamran Ahmed',
url: 'https://twitter.com/kamranahmedse',
},
publisher: {
'@type': 'Organization',
name: 'roadmap.sh',
logo: {
'@type': 'ImageObject',
url: 'https://roadmap.sh/brand-square.png',
},
},
};
}
const Helmet = (props: HelmetProps) => {
const { roadmap, title, canonical, description, keywords } = props;
return (
<NextHead>
<meta charSet="UTF-8" />
<title>{title || siteConfig.title}</title>
<meta
name="description"
content={description || siteConfig.description}
/>
<meta name="author" content={siteConfig.author} />
<meta
name="keywords"
content={keywords ? keywords.join(',') : siteConfig.keywords.join(',')}
/>
<meta
name="viewport"
content="width=device-width, user-scalable=yes, initial-scale=1.0, maximum-scale=3.0, minimum-scale=1.0"
/>
{canonical && <link rel="canonical" href={canonical} />}
<meta httpEquiv="Content-Language" content="en" />
<meta property="og:title" content={title || siteConfig.title} />
<meta
property="og:description"
content={description || siteConfig.description}
/>
<meta
property="og:image"
content={`${siteConfig.url.web}${siteConfig.logoSquare}`}
/>
<meta property="og:url" content={siteConfig.url.web} />
<meta property="og:type" content="website" />
<meta
property="article:publisher"
content={`https://facebook.com/${siteConfig.facebook}`}
/>
<meta property="og:site_name" content={siteConfig.name} />
<meta property="article:author" content={siteConfig.author} />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content={`@${siteConfig.twitter}`} />
<meta name="twitter:title" content={title || siteConfig.title} />
<meta
name="twitter:description"
content={description || siteConfig.description}
/>
<meta
name="twitter:image"
content={`${siteConfig.url.web}${siteConfig.logoSquare}`}
/>
<meta name="twitter:image:alt" content="roadmap.sh" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="/manifest/apple-touch-icon.png"
/>
<meta name="msapplication-TileColor" content="#101010" />
<meta name="theme-color" content="#848a9a" />
<link rel="manifest" href="/manifest/manifest.json" />
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/manifest/icon32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/manifest/icon16.png"
/>
<link
rel="shortcut icon"
href="/manifest/favicon.ico"
type="image/x-icon"
/>
<link rel="icon" href="/manifest/favicon.ico" type="image/x-icon" />
{roadmap?.id && (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(getRichSnippetJson(roadmap)),
}}
/>
)}
{/* Global Site Tag (gtag.js) - Google Analytics */}
{process.env.GA_SECRET && (
<>
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GA_SECRET}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.GA_SECRET}');
`,
}}
/>
</>
)}
</NextHead>
);
};
export default Helmet;