Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

43 rader
1.5 KiB

  1. import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document'
  2. class MyDocument extends Document {
  3. static async getInitialProps(ctx) {
  4. const initialProps = await Document.getInitialProps(ctx);
  5. return { ...initialProps }
  6. }
  7. render() {
  8. const {locale} = this.props.__NEXT_DATA__
  9. const dir = locale === 'ar' ? 'rtl' : 'ltr';
  10. return (
  11. <Html>
  12. <Head>
  13. <script
  14. async
  15. src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
  16. />
  17. <script
  18. dangerouslySetInnerHTML={{
  19. __html: `
  20. window.dataLayer = window.dataLayer || [];
  21. function gtag(){dataLayer.push(arguments);}
  22. gtag('js', new Date());
  23. gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
  24. page_path: window.location.pathname,
  25. });
  26. `,
  27. }}
  28. />
  29. <link href='#' rel="icon" type="image/png" href="/images/favicon.png"></link>
  30. </Head>
  31. <body dir={dir} lang={locale}>
  32. <Main />
  33. <NextScript />
  34. </body>
  35. </Html>
  36. )
  37. }
  38. }
  39. export default MyDocument;