1
0
mirror of synced 2026-01-09 06:03:09 -05:00
Files
docs/pages/_app.tsx
Grace Park 27aa5d92ea Remove FEATURE_NEXTJS Flag Part 1 (#20176)
* cleanup FEATURE_NEXTJS

* fixing some server tests

* updating article a for server tests

* update h2 to h4 map topic tests

* data off on TOCs

* updating dropdown article versions links

* Update so markdown renders in intros

* updating typo and all server tests are now passing

* remove nextjs feature flag

* head.js tests pass

* updating article-version-picker

* remove nextjs feature flag browser test

* update header.js tests

* fix page-titles.js test

* fix deprecated-enterprise versions

* adding early access

* testing

* getting childTocItem

* fixing table of contents to show child toc items

* updated to 2 because the sidebar article also has the same link

* remove comment

* updating pick

* Update TocLandingContext.tsx

* update package.json and change className to h4 for h2

* updating with mikes feedback

* remove a.active test

* React clean up: Delete unnecessary layouts/includes Part 2 (#20143)

* Delete unnecessary layouts

* setting back tests failing :(

* update layouts

* delete unnecessary includes

* remove github-ae-release-notes and updating layouts

* remove a.active test
2021-07-16 14:54:25 -07:00

70 lines
2.1 KiB
TypeScript

import React, { useEffect } from 'react'
import App from 'next/app'
import type { AppProps, AppContext } from 'next/app'
import Head from 'next/head'
import { useTheme, ThemeProvider } from '@primer/components'
import { defaultThemeProps, getThemeProps } from 'components/lib/getThemeProps'
import '../stylesheets/index.scss'
import events from 'javascripts/events'
import experiment from 'javascripts/experiment'
type MyAppProps = AppProps & { csrfToken: string; themeProps: typeof defaultThemeProps }
const MyApp = ({ Component, pageProps, csrfToken, themeProps }: MyAppProps) => {
useEffect(() => {
events()
experiment()
}, [])
return (
<>
<Head>
<meta charSet="utf-8" />
<title>GitHub Documentation</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="alternate icon" type="image/png" href="/assets/images/site/favicon.png" />
<link rel="icon" type="image/svg+xml" href="/assets/images/site/favicon.svg" />
<meta
name="google-site-verification"
content="OgdQc0GZfjDI52wDv1bkMT-SLpBUo_h5nn9mI9L22xQ"
/>
<meta
name="google-site-verification"
content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"
/>
<meta name="csrf-token" content={csrfToken} />
</Head>
<ThemeProvider>
<SetTheme themeProps={themeProps} />
<Component {...pageProps} />
</ThemeProvider>
</>
)
}
MyApp.getInitialProps = async (appContext: AppContext) => {
const { ctx } = appContext
// calls page's `getInitialProps` and fills `appProps.pageProps`
const appProps = await App.getInitialProps(appContext)
const req: any = ctx.req
return { ...appProps, themeProps: getThemeProps(req), csrfToken: req?.csrfToken?.() || '' }
}
const SetTheme = ({ themeProps }: { themeProps: typeof defaultThemeProps }) => {
// Cause primer/components to re-evaluate the 'auto' color mode on client side render
const { setColorMode } = useTheme()
useEffect(() => {
setTimeout(() => {
setColorMode(themeProps.colorMode as any)
})
}, [])
return null
}
export default MyApp