-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sets up scripts to place pseudo nonces to be transformed by revproxy. #787
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8455959
Sets up scripts to place pseudo nonces to be transformed by revproxy.
timcosgrove 3122931
Add the dev env vars. (#785)
timcosgrove e0cef79
Removed show all times after it is clicked (#777)
mreed101 ea178d1
PR: QA Fixes #783,#784, #19413 (#788)
ttran-Therisa 293d903
Merge branch 'main' into tcosgrove_nonce
timcosgrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,148 @@ | ||
import { Html, Main, NextScript, Head } from 'next/document' | ||
import Document, { Html, Main, NextScript, Head } from 'next/document' | ||
import { GTM_ID } from '@/lib/analytics' | ||
import Script from 'next/script' | ||
import React from 'react' | ||
|
||
const Document = () => { | ||
const ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL || '/generated/' | ||
class CustomHead extends Head { | ||
getScripts(files) { | ||
const originalScripts = super.getScripts(files) | ||
return originalScripts.map((script) => { | ||
return React.cloneElement(script, { | ||
'data-nb-nonce': '**CSP_NONCE**', | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
class CustomDocument extends Document { | ||
#ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL || '/generated/' | ||
#nonce = '**CSP_NONCE**' | ||
|
||
return ( | ||
<Html lang="en" dir="ltr"> | ||
<Head> | ||
<meta charSet="utf-8" /> | ||
<link | ||
href={`${ASSETS_URL}static-pages.css`} | ||
data-entry-name="static-pages.css" | ||
rel="stylesheet" | ||
/> | ||
<link rel="stylesheet" href={`${ASSETS_URL}style.css`} /> | ||
render() { | ||
return ( | ||
<Html lang="en" dir="ltr"> | ||
<CustomHead> | ||
<meta charSet="utf-8" /> | ||
<link | ||
href={`${this.#ASSETS_URL}static-pages.css`} | ||
data-entry-name="static-pages.css" | ||
rel="stylesheet" | ||
/> | ||
<link rel="stylesheet" href={`${this.#ASSETS_URL}style.css`} /> | ||
|
||
<Script | ||
id="web-components" | ||
strategy="beforeInteractive" | ||
src={`${ASSETS_URL}web-components.entry.js`} | ||
/> | ||
<Script | ||
id="web-components" | ||
strategy="beforeInteractive" | ||
src={`${this.#ASSETS_URL}web-components.entry.js`} | ||
data-nb-nonce={this.#nonce} | ||
/> | ||
|
||
{/* Add vendor file */} | ||
<Script | ||
id="vendor" | ||
strategy="beforeInteractive" | ||
src={`${ASSETS_URL}vendor.entry.js`} | ||
/> | ||
{/* Add vendor file */} | ||
<Script | ||
id="vendor" | ||
strategy="beforeInteractive" | ||
src={`${this.#ASSETS_URL}vendor.entry.js`} | ||
data-nb-nonce={this.#nonce} | ||
/> | ||
|
||
{/* Preconnect to google tag manager domain */} | ||
<link rel="preconnect" href="https://www.googletagmanager.com" /> | ||
{/* Preconnect to google tag manager domain */} | ||
<link rel="preconnect" href="https://www.googletagmanager.com" /> | ||
|
||
{/* Preload main fonts */} | ||
<link | ||
rel="preload" | ||
href={`${ASSETS_URL}sourcesanspro-bold-webfont.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
<link | ||
rel="preload" | ||
href={`${ASSETS_URL}sourcesanspro-regular-webfont.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
<link | ||
rel="preload" | ||
href={`${ASSETS_URL}bitter-bold.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
<link | ||
rel="preload" | ||
href={`${ASSETS_URL}fa-solid-900.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
{/* Preload main fonts */} | ||
<link | ||
rel="preload" | ||
href={`${this.#ASSETS_URL}sourcesanspro-bold-webfont.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
<link | ||
rel="preload" | ||
href={`${this.#ASSETS_URL}sourcesanspro-regular-webfont.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
<link | ||
rel="preload" | ||
href={`${this.#ASSETS_URL}bitter-bold.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
<link | ||
rel="preload" | ||
href={`${this.#ASSETS_URL}fa-solid-900.woff2`} | ||
as="font" | ||
type="font/woff2" | ||
crossOrigin="anonymous" | ||
/> | ||
|
||
{/* Load Icons */} | ||
<link | ||
href="/img/design/icons/apple-touch-icon.png" | ||
rel="apple-touch-icon-precomposed" | ||
/> | ||
<link | ||
href="/img/design/icons/apple-touch-icon-72x72.png" | ||
rel="apple-touch-icon-precomposed" | ||
sizes="72x72" | ||
/> | ||
<link | ||
href="/img/design/icons/apple-touch-icon-114x114.png" | ||
rel="apple-touch-icon-precomposed" | ||
sizes="114x114" | ||
/> | ||
<link | ||
href="/img/design/icons/apple-touch-icon-152x152.png" | ||
rel="apple-touch-icon-precomposed" | ||
sizes="144x144" | ||
/> | ||
<link | ||
rel="shortcut icon" | ||
sizes="any" | ||
href="/img/design/icons/favicon.ico" | ||
/> | ||
{/* Load Icons */} | ||
<link | ||
href="/img/design/icons/apple-touch-icon.png" | ||
rel="apple-touch-icon-precomposed" | ||
/> | ||
<link | ||
href="/img/design/icons/apple-touch-icon-72x72.png" | ||
rel="apple-touch-icon-precomposed" | ||
sizes="72x72" | ||
/> | ||
<link | ||
href="/img/design/icons/apple-touch-icon-114x114.png" | ||
rel="apple-touch-icon-precomposed" | ||
sizes="114x114" | ||
/> | ||
<link | ||
href="/img/design/icons/apple-touch-icon-152x152.png" | ||
rel="apple-touch-icon-precomposed" | ||
sizes="144x144" | ||
/> | ||
<link | ||
rel="shortcut icon" | ||
sizes="any" | ||
href="/img/design/icons/favicon.ico" | ||
/> | ||
|
||
{/* Add web components */} | ||
<link rel="stylesheet" href={`${ASSETS_URL}web-components.css`} /> | ||
{/* Add web components */} | ||
<link | ||
rel="stylesheet" | ||
href={`${this.#ASSETS_URL}web-components.css`} | ||
/> | ||
|
||
{/* Add polyfills */} | ||
<Script | ||
id="polyfills" | ||
noModule | ||
strategy="afterInteractive" | ||
src={`${ASSETS_URL}polyfills.entry.js`} | ||
/> | ||
{/* Add polyfills */} | ||
<Script | ||
id="polyfills" | ||
noModule | ||
strategy="afterInteractive" | ||
src={`${this.#ASSETS_URL}polyfills.entry.js`} | ||
data-nb-nonce={this.#nonce} | ||
/> | ||
|
||
{/* We participate in the US government’s analytics program. See the data at analytics.usa.gov. https://github.com/digital-analytics-program/gov-wide-code */} | ||
<Script | ||
src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=VA" | ||
id="_fed_an_ua_tag" | ||
strategy="afterInteractive" | ||
async | ||
/> | ||
</Head> | ||
<body className="merger"> | ||
<noscript> | ||
<iframe | ||
src={`https://www.googletagmanager.com/ns.html?id=${GTM_ID}`} | ||
height="0" | ||
width="0" | ||
style={{ display: 'none', visibility: 'hidden' }} | ||
{/* We participate in the US government’s analytics program. See the data at analytics.usa.gov. https://github.com/digital-analytics-program/gov-wide-code */} | ||
<Script | ||
src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=VA" | ||
id="_fed_an_ua_tag" | ||
strategy="afterInteractive" | ||
async | ||
data-nb-nonce={this.#nonce} | ||
/> | ||
</noscript> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
</CustomHead> | ||
<body className="merger"> | ||
<noscript> | ||
<iframe | ||
src={`https://www.googletagmanager.com/ns.html?id=${GTM_ID}`} | ||
height="0" | ||
width="0" | ||
style={{ display: 'none', visibility: 'hidden' }} | ||
/> | ||
</noscript> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} | ||
} | ||
|
||
export default Document | ||
export default CustomDocument |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very old and should probably be removed.