@@ -2,14 +2,15 @@ import '~/styles/globals.css'
2
2
import type { AppProps } from 'next/app'
3
3
4
4
import { jetBrainsMono , manrope } from '~/styles/fonts'
5
- import React , { useRef } from 'react'
5
+ import React , { useMemo } from 'react'
6
6
import cx from 'classnames'
7
7
import { CodingLanguageProvider } from '~/contexts/CodingLanguage'
8
8
import Script from 'next/script'
9
9
import { generateJsonLd } from '~/utils/jsonLd'
10
10
import { useRouter } from 'next/router'
11
11
import { getAbsoluteURL } from '~/utils'
12
12
import Head from 'next/head'
13
+ import { metaThemeColor } from '~/config/theme'
13
14
14
15
const isProd = process . env . NODE_ENV === 'production'
15
16
@@ -19,42 +20,54 @@ gtag('js', new Date());
19
20
gtag('config', 'G-Y678D4CC1J');`
20
21
21
22
export default function App ( { Component, pageProps } : AppProps ) {
22
- const ref = useRef < HTMLElement > ( null )
23
-
24
23
const router = useRouter ( )
25
-
26
24
const route = router . asPath
27
25
28
- let jsonLdData = [
29
- generateJsonLd ( 'breadcrumb' , {
30
- items : [
31
- { name : 'Home' , url : 'https://rushdb.com/' } ,
32
- ...route
33
- . split ( '/' )
34
- . filter ( ( p ) => p )
35
- . map ( ( p , index , arr ) => ( {
36
- name : p . charAt ( 0 ) . toUpperCase ( ) + p . slice ( 1 ) . replace ( '-' , ' ' ) ,
37
- url : getAbsoluteURL ( `/${ arr . slice ( 0 , index + 1 ) . join ( '/' ) } ` )
38
- } ) )
39
- ]
40
- } )
41
- ]
42
- if ( route === '/' ) {
43
- jsonLdData . push ( generateJsonLd ( 'homepage' , { } ) )
44
- } else if ( route === '/blog' ) {
45
- jsonLdData . push ( generateJsonLd ( 'blogRoot' , { } ) )
46
- } else if ( route === '/pricing' ) {
47
- jsonLdData . push ( generateJsonLd ( 'pricing' , { } ) )
48
- } else if ( route === '/privacy-policy' ) {
49
- jsonLdData . push ( generateJsonLd ( 'legal' , { url : getAbsoluteURL ( route ) , name : 'Privacy Policy' } ) )
50
- } else if ( route === '/terms-of-service' ) {
51
- jsonLdData . push ( generateJsonLd ( 'legal' , { url : getAbsoluteURL ( route ) , name : 'Terms of Service' } ) )
52
- }
26
+ const jsonLdData = useMemo ( ( ) => {
27
+ const items = route
28
+ . split ( '/' )
29
+ . filter ( Boolean )
30
+ . map ( ( p , index , arr ) => ( {
31
+ name : p . charAt ( 0 ) . toUpperCase ( ) + p . slice ( 1 ) . replace ( '-' , ' ' ) ,
32
+ url : getAbsoluteURL ( `/${ arr . slice ( 0 , index + 1 ) . join ( '/' ) } ` )
33
+ } ) )
34
+
35
+ const data = [
36
+ generateJsonLd ( 'breadcrumb' , { items : [ { name : 'Home' , url : 'https://rushdb.com/' } , ...items ] } )
37
+ ]
38
+
39
+ if ( route === '/' ) {
40
+ data . push ( generateJsonLd ( 'homepage' , { } ) )
41
+ } else if ( route === '/blog' ) {
42
+ data . push ( generateJsonLd ( 'blogRoot' , { } ) )
43
+ } else if ( route === '/pricing' ) {
44
+ data . push ( generateJsonLd ( 'pricing' , { } ) )
45
+ } else if ( route === '/privacy-policy' ) {
46
+ data . push ( generateJsonLd ( 'legal' , { url : getAbsoluteURL ( route ) , name : 'Privacy Policy' } ) )
47
+ } else if ( route === '/terms-of-service' ) {
48
+ data . push ( generateJsonLd ( 'legal' , { url : getAbsoluteURL ( route ) , name : 'Terms of Service' } ) )
49
+ }
50
+
51
+ return data
52
+ } , [ route ] )
53
53
54
54
return (
55
55
< >
56
56
< Head >
57
+ < link rel = "icon" type = "image/svg+xml" href = "/favicon.svg" />
58
+ < link rel = "icon" type = "image/png" href = "/favicon.png" />
59
+ < link rel = "apple-touch-icon" sizes = "180x180" href = "/apple-touch-icon.png" />
60
+ < link rel = "icon" type = "image/png" sizes = "32x32" href = "/favicon-32x32.png" />
61
+ < link rel = "icon" type = "image/png" sizes = "16x16" href = "/favicon-16x16.png" />
62
+ < link rel = "manifest" href = "/site.webmanifest" />
63
+ < meta name = "msapplication-TileColor" content = { metaThemeColor } />
64
+ < meta name = "theme-color" content = { metaThemeColor } />
65
+ < link rel = "preconnect" href = "https://fonts.googleapis.com" crossOrigin = "anonymous" />
66
+ < link rel = "preconnect" href = "https://fonts.gstatic.com" crossOrigin = "anonymous" />
67
+
57
68
< script type = "application/ld+json" dangerouslySetInnerHTML = { { __html : JSON . stringify ( jsonLdData ) } } />
69
+
70
+ < meta name = "referrer" content = "strict-origin-when-cross-origin" />
58
71
</ Head >
59
72
< style jsx global > { `
60
73
html,
@@ -71,7 +84,7 @@ export default function App({ Component, pageProps }: AppProps) {
71
84
</ >
72
85
) }
73
86
74
- < main className = { cx ( jetBrainsMono . variable , manrope . variable ) } ref = { ref } >
87
+ < main className = { cx ( jetBrainsMono . variable , manrope . variable ) } >
75
88
< CodingLanguageProvider >
76
89
< Component { ...pageProps } />
77
90
</ CodingLanguageProvider >
0 commit comments