({ Component, pageProps }: AppProps)
| 12 | require('src/migration').migration(); |
| 13 | |
| 14 | const MyApp = ({ Component, pageProps }: AppProps) => { |
| 15 | |
| 16 | useEffect(() => { |
| 17 | const preventBrowserShortcut = e => { |
| 18 | if (e.ctrlKey && 'gmi'.includes(e.key.toLowerCase())) { |
| 19 | e.preventDefault(); |
| 20 | } |
| 21 | }; |
| 22 | |
| 23 | window.addEventListener('keydown', preventBrowserShortcut); |
| 24 | |
| 25 | return () => window.removeEventListener('keydown', preventBrowserShortcut); |
| 26 | }, []); |
| 27 | |
| 28 | const { metadata } = pageProps || {}; |
| 29 | const baseURL = process.env.NEXT_PUBLIC_BASE_URL; |
| 30 | const { asPath } = useRouter(); |
| 31 | |
| 32 | const href = asPath.replace('/en', '/').replace('//', '/'); |
| 33 | |
| 34 | const direction = useLanguageDirection() |
| 35 | |
| 36 | return ( |
| 37 | <IntlProvider |
| 38 | messages={pageProps.messages} |
| 39 | locale={pageProps.lang} |
| 40 | defaultLocale={defaultLocale} |
| 41 | > |
| 42 | {metadata && ( |
| 43 | <Head> |
| 44 | <title>{metadata.title}</title> |
| 45 | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> |
| 46 | <meta name="description" content={metadata.description} /> |
| 47 | {typeof metadata.hrefLang === 'string' && |
| 48 | locales.map(locale => ( |
| 49 | <link |
| 50 | key={locale} |
| 51 | rel="alternate" |
| 52 | hrefLang={locale} |
| 53 | href={`${process.env.NEXT_PUBLIC_BASE_URL}${locale === 'en' ? '' : locale + '/'}${metadata.hrefLang |
| 54 | }`} |
| 55 | /> |
| 56 | ))} |
| 57 | {/* <!-- Facebook Meta Tags --> */} |
| 58 | <meta property="og:url" content={baseURL + href} /> |
| 59 | <meta property="og:type" content="website" /> |
| 60 | <meta property="og:title" content={metadata.title} /> |
| 61 | <meta property="og:description" content={metadata.description} /> |
| 62 | <meta property="og:image" content={baseURL + '/images/og-regexlearn-image.jpg'} /> |
| 63 | |
| 64 | {/* <!-- Twitter Meta Tags --> */} |
| 65 | <meta name="twitter:card" content="summary_large_image" /> |
| 66 | <meta property="twitter:domain" content="regexlearn.com" /> |
| 67 | <meta property="twitter:url" content={baseURL + href} /> |
| 68 | <meta name="twitter:title" content={metadata.title} /> |
| 69 | <meta name="twitter:description" content={metadata.description} /> |
| 70 | <meta name="twitter:image" content={baseURL + '/images/og-regexlearn-image.jpg'} /> |
| 71 | </Head> |
nothing calls this directly
no test coverage detected