Passed
Push — feature/full-redesign ( b5fb42...274ace )
by Kevin Van
04:16 queued 16s
created

src/components/Seo.tsx   A

Complexity

Total Complexity 2
Complexity/F 0

Size

Lines of Code 54
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 32
mnd 2
bc 2
fnc 0
dl 0
loc 54
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { useStaticQuery, graphql } from "gatsby"
2
import React from "react"
3
import { Helmet } from "react-helmet"
4
5
export const Seo = ({ title, path }: SeoClassProps) => {
6
  const {
7
    site: {
8
      siteMetadata: { description, siteUrl, title: titleTpl, subTitle },
9
    },
10
  }: SeoStaticSiteData = useStaticQuery(graphql`
11
    {
12
      site {
13
        siteMetadata {
14
          description
15
          siteUrl
16
          title
17
          subTitle
18
        }
19
      }
20
    }
21
  `)
22
  const canonicalUrl = path ? `${siteUrl}${path}` : null
23
  const metaDescription = description || description
24
25
  return (
26
    <Helmet
27
      htmlAttributes={{ lang: `nl-BE` }}
28
      title={title}
29
      titleTemplate={`%s | ${titleTpl}`}
30
      link={canonicalUrl ? [{ rel: `canonical`, href: canonicalUrl }] : []}
31
      // TODO: METADATA
32
    ></Helmet>
33
  )
34
}
35
36
type SeoStaticSiteData = {
37
  site: {
38
    siteMetadata: {
39
      description?: string
40
      siteUrl?: string
41
      title: string
42
      subTitle?: string
43
      author?: string
44
      fbAppId?: string
45
    }
46
  }
47
}
48
49
type SeoClassProps = {
50
  title: string
51
  path: string
52
  description?: string
53
}
54