|
- import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document'
-
- class MyDocument extends Document {
-
- static async getInitialProps(ctx) {
- const initialProps = await Document.getInitialProps(ctx);
- return { ...initialProps }
- }
-
- render() {
- const {locale} = this.props.__NEXT_DATA__
- const dir = locale === 'ar' ? 'rtl' : 'ltr';
- return (
- <Html>
- <Head>
- <script
- async
- src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
- />
- <script
- dangerouslySetInnerHTML={{
- __html: `
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
- gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
- page_path: window.location.pathname,
- });
- `,
- }}
- />
- <link href='#' rel="icon" type="image/png" href="/images/favicon.png"></link>
- </Head>
- <body dir={dir} lang={locale}>
- <Main />
- <NextScript />
- </body>
- </Html>
- )
- }
- }
-
- export default MyDocument;
|