This repository has been archived by the owner on Jul 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added _document.js w/ support for a language prop
- Loading branch information
1 parent
9113e61
commit 2117b6e
Showing
3 changed files
with
33 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Document, { Head, Main, NextScript } from 'next/document' | ||
import flush from 'styled-jsx/server' | ||
|
||
export default class MyDocument extends Document { | ||
static getInitialProps({ renderPage }) { | ||
const { html, head, errorHtml, chunks } = renderPage() | ||
const styles = flush() | ||
return { html, head, errorHtml, chunks, styles } | ||
} | ||
|
||
render() { | ||
/** | ||
* Here we use _document.js to add a "lang" propery to the HTML object if | ||
* one is set on the page. | ||
**/ | ||
return ( | ||
<html lang={this.props.__NEXT_DATA__.props.lang || 'en'}> | ||
<Head> | ||
</Head> | ||
<body> | ||
{this.props.customValue} | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</html> | ||
) | ||
} | ||
} |
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