Passed
Pull Request — master (#425)
by Huu-Phat
04:16
created

pages/_document.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 99
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 72
mnd 0
bc 0
fnc 2
dl 0
loc 99
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import React from 'react'
2
import Document, { Html, Head, Main, NextScript } from 'next/document'
3
/*
4
 * Some notes:
5
 * 1) _document.js will load on server side -> all this meta tag will be fetched by Scraper of Facebook, Linkedin, ...
6
 * 2) og:image need to be change name in order for FB to reload the new preview image
7
 * 3) sharing on staging env wont work, because og:url is set to main page
8
 */
9
class MyDocument extends Document {
10
  static async getInitialProps(ctx) {
11
    const initialProps = await Document.getInitialProps(ctx)
12
    return { ...initialProps }
13
  }
14
15
  render() {
16
    return (
17
      <Html lang="en">
18
        <Head>
19
          <meta
20
            name="viewport"
21
            content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
22
          />
23
          <meta property="og:title" content="DeKal | Portfolio" />
24
          <meta property="og:type" content="website" />
25
          <meta
26
            property="og:description"
27
            content="Dekal's Portfolio and Blog"
28
          />
29
          <meta
30
            property="og:image"
31
            content="https://phatho-folio.now.sh/images/cover-img.png"
32
          />
33
          <meta
34
            property="og:image:secure_url"
35
            content="https://phatho-folio.now.sh/images/cover-img.png"
36
          />
37
          <meta property="og:url" content="https://phatho-folio.now.sh/" />
38
          <meta property="og:site_name" content="DeKal Portfolio" />
39
          <meta property="og:image:alt" content="DeKal Portfolio" />
40
          <meta
41
            name="google-site-verification"
42
            content="ofwBFRuFL3aycSJjDcrhc8hWEPKuJ7LkNCLUrsB0Sj4"
43
          />
44
          <meta name="robots" content="index,follow" />
45
          <meta name="googlebot" content="index,follow" />
46
          <meta name="theme-color" content="#ffffff" />
47
          <link rel="icon" href="/favicon.ico" />
48
          <link rel="apple-touch-icon" href="/icons/Icon-64.png" />
49
          <link
50
            rel="preload"
51
            href="fonts/ip/font/ip.woff"
52
            as="font"
53
            crossOrigin=""
54
          />
55
          <link
56
            href="/icons/Icon-32.png"
57
            rel="icon"
58
            type="image/png"
59
            sizes="32x32"
60
          />
61
          <link
62
            href="/icons/Icon-64.png"
63
            rel="icon"
64
            type="image/png"
65
            sizes="64x64"
66
          />
67
68
          <link rel="canonical" href="https://phatho-folio.now.sh/" />
69
          <link rel="manifest" href="/manifest.json" />
70
71
          <script
72
            async
73
            defer
74
            src="https://www.googletagmanager.com/gtag/js?id=UA-172952138-1"
75
          />
76
77
          <script
78
            dangerouslySetInnerHTML={{
79
              __html: `
80
              window.dataLayer = window.dataLayer || [];
81
              function gtag(){dataLayer.push(arguments);}
82
              gtag('js', new Date());
83
            
84
              gtag('config', 'UA-172952138-1');
85
              `
86
            }}
87
          />
88
        </Head>
89
        <body>
90
          <Main />
91
          <NextScript />
92
        </body>
93
      </Html>
94
    )
95
  }
96
}
97
98
export default MyDocument
99