1
|
|
|
import { useStaticQuery, graphql } from "gatsby" |
2
|
|
|
import React, { PropsWithChildren } from "react" |
3
|
|
|
import { Helmet } from "react-helmet" |
4
|
|
|
|
5
|
|
|
import { SeoClassProps } from "../Types/Seo" |
6
|
|
|
import { useSiteMetaData } from "../hooks/use-site-metadata" |
7
|
|
|
|
8
|
|
|
import defaultOgImage from "../images/logo-flat.png" |
9
|
|
|
|
10
|
|
|
export const Seo = ({ title, description, keywords, image, path, children }: PropsWithChildren<SeoClassProps>) => { |
11
|
|
|
const { |
12
|
|
|
title: defaultTitle, |
13
|
|
|
subTitle, |
14
|
|
|
description: defaultDescription, |
15
|
|
|
siteUrl, |
16
|
|
|
author, |
17
|
|
|
twitterHandle, |
18
|
|
|
fbAppId, |
19
|
|
|
} = useSiteMetaData() |
20
|
|
|
|
21
|
|
|
const seo = { |
22
|
|
|
title: `${title || subTitle} | ${defaultTitle}`, |
23
|
|
|
description: description || defaultDescription || ``, |
24
|
|
|
image: image || { width: 567, height: 567, src: defaultOgImage }, |
25
|
|
|
url: `${siteUrl}${path || ``}`, |
26
|
|
|
fbAppId: fbAppId || ``, |
27
|
|
|
author: author || ``, |
28
|
|
|
twitterHandle: twitterHandle || ``, |
29
|
|
|
keywords: keywords?.join(`, `) || ``, |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
return ( |
33
|
|
|
<> |
34
|
|
|
<title>{seo.title}</title> |
35
|
|
|
|
36
|
|
|
<link rel="canonical" href={seo.url} /> |
37
|
|
|
|
38
|
|
|
<meta name="description" content={seo.description} /> |
39
|
|
|
|
40
|
|
|
<meta name="fb:app_id" content={seo.fbAppId} /> |
41
|
|
|
|
42
|
|
|
<meta name="og:title" content={seo.title} /> |
43
|
|
|
<meta name="og:description" content={seo.description} /> |
44
|
|
|
<meta name="og:type" content="website" /> |
45
|
|
|
<meta name="og:url" content={seo.url} /> |
46
|
|
|
|
47
|
|
|
<meta name="og:image" content={seo.image?.src} /> |
48
|
|
|
<meta name="og:image:width" content={seo.image?.width.toString()} /> |
49
|
|
|
<meta name="og:image:type" content="image/png" /> |
50
|
|
|
<meta name="og:image:height" content={seo.image?.height.toString()} /> |
51
|
|
|
<meta name="og:image:title" content={seo.title} /> |
52
|
|
|
<meta name="og:image:alt" content={seo.title} /> |
53
|
|
|
|
54
|
|
|
<meta name="twitter:creator" content={seo.author} /> |
55
|
|
|
<meta name="twitter:title" content={seo.title} /> |
56
|
|
|
<meta name="twitter:description" content={seo.description} /> |
57
|
|
|
|
58
|
|
|
<meta name="twitter:card" content="summary_large_image" /> |
59
|
|
|
|
60
|
|
|
{keywords && <meta name="keywords" content={seo.keywords} />} |
61
|
|
|
|
62
|
|
|
{children} |
63
|
|
|
</> |
64
|
|
|
) |
65
|
|
|
} |
66
|
|
|
|