MCPcopy Create free account
hub / github.com/editablejs/editable / App

Function App

apps/docs/src/pages/_app.tsx:11–54  ·  view source on GitHub ↗
({ Component, pageProps }: AppProps)

Source from the content-addressed store, hash-verified

9import '../i18n'
10
11export default function App({ Component, pageProps }: AppProps) {
12 const router = useRouter()
13
14 i18n.changeLanguage(router.locale)
15
16 React.useEffect(() => {
17 // Taken from StackOverflow. Trying to detect both Safari desktop and mobile.
18 const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
19 if (isSafari) {
20 // This is kind of a lie.
21 // We still rely on the manual Next.js scrollRestoration logic.
22 // However, we *also* don't want Safari grey screen during the back swipe gesture.
23 // Seems like it doesn't hurt to enable auto restore *and* Next.js logic at the same time.
24 history.scrollRestoration = 'auto'
25 } else {
26 // For other browsers, let Next.js set scrollRestoration to 'manual'.
27 // It seems to work better for Chrome and Firefox which don't animate the back swipe.
28 }
29 }, [])
30
31 React.useEffect(() => {
32 const handleRouteChange = (url: string) => {
33 // ga('set', 'page', url)
34 // ga('send', 'pageview')
35 }
36 router.events.on('routeChangeComplete', handleRouteChange)
37 return () => {
38 router.events.off('routeChangeComplete', handleRouteChange)
39 }
40 }, [router.events])
41
42 return (
43 <>
44 <GlobalStyles />
45 <Head>
46 <meta
47 name="viewport"
48 content="viewport-fit=cover,width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
49 />
50 </Head>
51 <Component {...pageProps} />
52 </>
53 )
54}

Callers

nothing calls this directly

Calls 2

onMethod · 0.80
offMethod · 0.80

Tested by

no test coverage detected