|
11 | 11 |
|
12 | 12 | import {Html, Head, Main, NextScript} from 'next/document'; |
13 | 13 | import {siteConfig} from '../siteConfig'; |
| 14 | +import {SharedRootBody, SharedRootHead} from '../components/_/root-layout'; |
14 | 15 |
|
15 | 16 | const MyDocument = () => { |
16 | 17 | return ( |
17 | 18 | <Html lang={siteConfig.languageCode} dir={siteConfig.isRTL ? 'rtl' : 'ltr'}> |
18 | 19 | <Head /> |
19 | | - <link |
20 | | - rel="apple-touch-icon" |
21 | | - sizes="180x180" |
22 | | - href="/apple-touch-icon.png" |
23 | | - /> |
24 | | - <link |
25 | | - rel="icon" |
26 | | - type="image/png" |
27 | | - sizes="32x32" |
28 | | - href="/favicon-32x32.png" |
29 | | - /> |
30 | | - <link |
31 | | - rel="icon" |
32 | | - type="image/png" |
33 | | - sizes="16x16" |
34 | | - href="/favicon-16x16.png" |
35 | | - /> |
36 | | - <link rel="manifest" href="/site.webmanifest" /> |
37 | | - <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#404756" /> |
38 | | - <meta name="msapplication-TileColor" content="#2b5797" /> |
39 | | - <meta name="theme-color" content="#23272f" /> |
40 | | - <script |
41 | | - async |
42 | | - src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_TRACKING_ID}`} |
43 | | - /> |
44 | | - <script |
45 | | - dangerouslySetInnerHTML={{ |
46 | | - __html: `window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '${process.env.NEXT_PUBLIC_GA_TRACKING_ID}');`, |
47 | | - }} |
48 | | - /> |
49 | | - <body className="font-text font-medium antialiased text-lg bg-wash dark:bg-wash-dark text-secondary dark:text-secondary-dark leading-base"> |
50 | | - <script |
51 | | - dangerouslySetInnerHTML={{ |
52 | | - __html: ` |
53 | | - (function () { |
54 | | - try { |
55 | | - let logShown = false; |
56 | | - function setUwu(isUwu) { |
57 | | - try { |
58 | | - if (isUwu) { |
59 | | - localStorage.setItem('uwu', true); |
60 | | - document.documentElement.classList.add('uwu'); |
61 | | - if (!logShown) { |
62 | | - console.log('uwu mode! turn off with ?uwu=0'); |
63 | | - console.log('logo credit to @sawaratsuki1004 via https://github.com/SAWARATSUKI/ServiceLogos'); |
64 | | - logShown = true; |
65 | | - } |
66 | | - } else { |
67 | | - localStorage.removeItem('uwu'); |
68 | | - document.documentElement.classList.remove('uwu'); |
69 | | - console.log('uwu mode off. turn on with ?uwu'); |
70 | | - } |
71 | | - } catch (err) { } |
72 | | - } |
73 | | - window.__setUwu = setUwu; |
74 | | - function checkQueryParam() { |
75 | | - const params = new URLSearchParams(window.location.search); |
76 | | - const value = params.get('uwu'); |
77 | | - switch(value) { |
78 | | - case '': |
79 | | - case 'true': |
80 | | - case '1': |
81 | | - return true; |
82 | | - case 'false': |
83 | | - case '0': |
84 | | - return false; |
85 | | - default: |
86 | | - return null; |
87 | | - } |
88 | | - } |
89 | | - function checkLocalStorage() { |
90 | | - try { |
91 | | - return localStorage.getItem('uwu') === 'true'; |
92 | | - } catch (err) { |
93 | | - return false; |
94 | | - } |
95 | | - } |
96 | | - const uwuQueryParam = checkQueryParam(); |
97 | | - if (uwuQueryParam != null) { |
98 | | - setUwu(uwuQueryParam); |
99 | | - } else if (checkLocalStorage()) { |
100 | | - document.documentElement.classList.add('uwu'); |
101 | | - } |
102 | | - } catch (err) { } |
103 | | - })(); |
104 | | - `, |
105 | | - }} |
106 | | - /> |
107 | | - <script |
108 | | - dangerouslySetInnerHTML={{ |
109 | | - __html: ` |
110 | | - (function () { |
111 | | - function setTheme(newTheme) { |
112 | | - window.__theme = newTheme; |
113 | | - if (newTheme === 'dark') { |
114 | | - document.documentElement.classList.add('dark'); |
115 | | - } else if (newTheme === 'light') { |
116 | | - document.documentElement.classList.remove('dark'); |
117 | | - } |
118 | | - } |
119 | | -
|
120 | | - var preferredTheme; |
121 | | - try { |
122 | | - preferredTheme = localStorage.getItem('theme'); |
123 | | - } catch (err) { } |
124 | | -
|
125 | | - window.__setPreferredTheme = function(newTheme) { |
126 | | - preferredTheme = newTheme; |
127 | | - setTheme(newTheme); |
128 | | - try { |
129 | | - localStorage.setItem('theme', newTheme); |
130 | | - } catch (err) { } |
131 | | - }; |
132 | | -
|
133 | | - var initialTheme = preferredTheme; |
134 | | - var darkQuery = window.matchMedia('(prefers-color-scheme: dark)'); |
135 | | -
|
136 | | - if (!initialTheme) { |
137 | | - initialTheme = darkQuery.matches ? 'dark' : 'light'; |
138 | | - } |
139 | | - setTheme(initialTheme); |
140 | | -
|
141 | | - darkQuery.addEventListener('change', function (e) { |
142 | | - if (!preferredTheme) { |
143 | | - setTheme(e.matches ? 'dark' : 'light'); |
144 | | - } |
145 | | - }); |
146 | | -
|
147 | | - // Detect whether the browser is Mac to display platform specific content |
148 | | - // An example of such content can be the keyboard shortcut displayed in the search bar |
149 | | - document.documentElement.classList.add( |
150 | | - window.navigator.platform.includes('Mac') |
151 | | - ? "platform-mac" |
152 | | - : "platform-win" |
153 | | - ); |
154 | | - })(); |
155 | | - `, |
156 | | - }} |
157 | | - /> |
| 20 | + <SharedRootHead /> |
| 21 | + <SharedRootBody> |
158 | 22 | <Main /> |
159 | 23 | <NextScript /> |
160 | | - </body> |
| 24 | + </SharedRootBody> |
161 | 25 | </Html> |
162 | 26 | ); |
163 | 27 | }; |
|
0 commit comments