-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
471f134
commit 787787a
Showing
3 changed files
with
61 additions
and
28 deletions.
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,28 +1,62 @@ | ||
import { Html, Head, Main, NextScript } from 'next/document'; | ||
import Document, { Html, Head, Main, NextScript } from 'next/document'; | ||
import { ServerStyleSheet } from 'styled-components'; | ||
|
||
export default function Document() { | ||
return ( | ||
<Html lang='en'> | ||
<Head> | ||
<link rel="shortcut icon" href='./static/push.png' /> | ||
<meta | ||
name="description" | ||
content="push protocol analytics dashboard" | ||
/> | ||
<meta | ||
name="keywords" | ||
content="Push,Communication,Notification,Chat" | ||
/> | ||
<meta name="author" content="Push Protocol" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
/> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
class MyDocument extends Document { | ||
static async getInitialProps(ctx) { | ||
const sheet = new ServerStyleSheet(); | ||
const originalRenderPage = ctx.renderPage; | ||
|
||
try { | ||
// Collect styles from all components rendered | ||
ctx.renderPage = () => | ||
originalRenderPage({ | ||
enhanceApp: (App) => (props) => | ||
sheet.collectStyles(<App {...props} />), | ||
}); | ||
|
||
// Fetch initial props for the document | ||
const initialProps = await Document.getInitialProps(ctx); | ||
|
||
return { | ||
...initialProps, | ||
styles: ( | ||
<> | ||
{initialProps.styles} | ||
{sheet.getStyleElement()} | ||
</> | ||
), | ||
}; | ||
} finally { | ||
sheet.seal(); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<Html lang="en"> | ||
<Head> | ||
<link rel="shortcut icon" href="./static/push.png" /> | ||
<meta | ||
name="description" | ||
content="push protocol analytics dashboard" | ||
/> | ||
<meta | ||
name="keywords" | ||
content="Push,Communication,Notification,Chat" | ||
/> | ||
<meta name="author" content="Push Protocol" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
/> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} | ||
|
||
export default MyDocument; |
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