* start SidebarNav, enable dark mode * wip: sidebarnav, fix primer components theme rendering * feat: ProductSiteTree, useFeatureFlag * feat: add new product site tree (untested) * wire up HomepageVersionPicker, run lint * fix: remove re-render logic, fix homepage version picker to be natural width * fix: support css + primer/components color modes * fix: rename categoryId -> productId * feat: ProductSiteTree and AllArticlesProduct * fix: cleanup warnings * fix: use next links on ProductSiteTreeNew * fix: use next Link on AllArticlesProduct * fix: add tooltip to ScrollButton, remove stylesheet dependency * feat: ProductArticlesList component * fix: convert color_mode value from cookie when necessary * remove comments * replace liquid with jsx Co-authored-by: Rachael Sewell <rachmari@github.com>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import Document, { DocumentContext, Html, Head, Main, NextScript } from 'next/document'
|
|
|
|
import { ServerStyleSheet } from 'styled-components'
|
|
|
|
import { getThemeProps } from 'components/lib/getThemeProps'
|
|
|
|
export default class MyDocument extends Document {
|
|
static async getInitialProps(ctx: DocumentContext) {
|
|
const sheet = new ServerStyleSheet()
|
|
const originalRenderPage = ctx.renderPage
|
|
|
|
try {
|
|
ctx.renderPage = () =>
|
|
originalRenderPage({
|
|
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
|
})
|
|
|
|
const initialProps = await Document.getInitialProps(ctx)
|
|
return {
|
|
...initialProps,
|
|
cssThemeProps: getThemeProps(ctx.req, 'css'),
|
|
themeProps: getThemeProps(ctx.req),
|
|
styles: (
|
|
<>
|
|
{initialProps.styles}
|
|
{sheet.getStyleElement()}
|
|
</>
|
|
),
|
|
}
|
|
} finally {
|
|
sheet.seal()
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { colorMode, nightScheme, dayScheme } = (this.props as any).cssThemeProps
|
|
return (
|
|
<Html>
|
|
<Head />
|
|
<body
|
|
data-color-mode={colorMode}
|
|
data-dark-theme={nightScheme}
|
|
data-light-theme={dayScheme}
|
|
>
|
|
<Main />
|
|
<NextScript />
|
|
</body>
|
|
</Html>
|
|
)
|
|
}
|
|
}
|