Skip to content

Instantly share code, notes, and snippets.

@MaxMEllon
Last active July 30, 2020 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaxMEllon/022d1679c9772b6e80c887e67d172375 to your computer and use it in GitHub Desktop.
Save MaxMEllon/022d1679c9772b6e80c887e67d172375 to your computer and use it in GitHub Desktop.
export default class MyDocument extends Document<{ tracking?: boolean; nonce: string }> {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)
const dnt = ctx?.req?.headers['DNT'] ?? '0'
const tracking = dnt !== '1'
return { ...initialProps, tracking, nonce }
}
render() {
return (
<html lang="ja">
<Head>
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content={colors.brand} />
<meta name="description" content="令和2年度補正家賃支援給付金事務事業" />
{this.props.tracking && <script src={analyticsScript} async />}
</Head>
<body>
<Main />
<NextScript nonce={this.props.nonce} />
</body>
</html>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment