33import React from 'react' ;
44import Document , { Head , Main , NextScript } from 'next/document' ;
55import { getContext , setContext } from 'docs/src/modules/styles/context' ;
6+ import CleanCSS from 'clean-css' ;
7+
8+ const cleanCSS = new CleanCSS ( ) ;
69
710class MyDocument extends Document {
811 render ( ) {
@@ -11,6 +14,10 @@ class MyDocument extends Document {
1114 < html lang = "en" dir = "ltr" >
1215 < Head >
1316 < title > Material-UI</ title >
17+ < meta
18+ name = "description"
19+ content = "React Components that Implement Google's Material Design."
20+ />
1421 < meta charSet = "utf-8" />
1522 { /* Use minimum-scale=1 to enable GPU rasterization */ }
1623 < meta
@@ -31,18 +38,17 @@ class MyDocument extends Document {
3138 rel = "stylesheet"
3239 href = "https://fonts.googleapis.com/css?family=Roboto:300,400,500"
3340 />
34- < link
35- rel = "stylesheet"
36- href = "https://fonts.googleapis.com/icon?family=Material+Icons"
37- async
38- />
39- < link
40- id = "docsearch-styles-sheet"
41- rel = "stylesheet"
42- href = "https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"
43- async
44- defer
41+ < style id = "insertion-point-jss" />
42+ { /* Twitter */ }
43+ < meta name = "twitter:card" content = "summary_large_image" />
44+ < meta name = "twitter:site" content = "@MaterialUI" />
45+ < meta name = "twitter:title" content = "Material-UI" />
46+ < meta
47+ name = "twitter:description"
48+ content = "React Components that Implement Google's Material Design."
4549 />
50+ < meta name = "twitter:image" content = "/static/icons/512x512.png" />
51+ < link rel = "shortcut icon" href = "/static/favicon.ico" />
4652 </ Head >
4753 < body >
4854 < Main />
@@ -77,13 +83,19 @@ MyDocument.getInitialProps = ctx => {
7783 const page = ctx . renderPage ( ) ;
7884 // Get the context with the collected side effects.
7985 const context = getContext ( ) ;
86+
87+ let css = context . sheetsRegistry . toString ( ) ;
88+ if ( process . env . NODE_ENV === 'production' ) {
89+ css = cleanCSS . minify ( css ) . styles ;
90+ }
91+
8092 return {
8193 ...page ,
8294 styles : (
8395 < style
8496 id = "jss-server-side"
8597 // eslint-disable-next-line react/no-danger
86- dangerouslySetInnerHTML = { { __html : context . sheetsRegistry . toString ( ) } }
98+ dangerouslySetInnerHTML = { { __html : css } }
8799 />
88100 ) ,
89101 } ;
0 commit comments