Repository navigation
Expand file tree
/
Copy path_app.tsx
More file actions
53 lines (48 loc) · 1.65 KB
/
Copy path_app.tsx
File metadata and controls
53 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import * as React from 'react';
import {AppProps} from 'next/app';
import '@docsearch/css';
import '../styles/fonts.css';
import '../styles/algolia.css';
import '../styles/index.css';
import '../styles/sandpack.css';
import '@codesandbox/sandpack-react/dist/index.css';
import Script from 'next/script';
import {hotjar} from 'utils/hotjar';
if (typeof window !== 'undefined') {
hotjar(process.env.NEXT_PUBLIC_HJ_SITE_ID, process.env.NEXT_PUBLIC_HJ_SITE_V);
}
const EmptyAppShell: React.FC = ({children}) => <>{children}</>;
export default function MyApp({Component, pageProps}: AppProps) {
let AppShell = (Component as any).appShell || EmptyAppShell;
// In order to make sidebar scrolling between pages work as expected
// we need to access the underlying MDX component.
if ((Component as any).isMDXComponent) {
AppShell = (Component as any)({}).props.originalType.appShell;
}
return (
<AppShell>
<Component {...pageProps} />
{process.env.NODE_ENV === 'production' && (
<>
<Script
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_TRACKING_ID}`}
/>
<Script id="google-analytics" strategy="lazyOnload">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GA_TRACKING_ID}', {
page_path: window.location.pathname,
});
`}
</Script>
</>
)}
</AppShell>
);
}