Passed
Push — master ( 7aa1e4...a37cc0 )
by Kevin Van
05:30
created

src/components/Seo.tsx   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 62
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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