git ssb

0+

Rômulo Alves / website



Commit 04f1928b97e35d5d5fe0cd9c216f1e431a121f33

improve css loading

romuloalves committed on 4/17/2021, 10:15:32 PM
Parent: 37c280147b9bc6348d2d1dcb7f850fd2b2330581

Files changed

data/index.tschanged
package-lock.jsonchanged
package.jsonchanged
pages/_document.tsxchanged
.babelrcadded
data/index.tsView
@@ -35,11 +35,10 @@
3535 href: 'https://nodejs.org/'
3636 },
3737 {
3838 expression: 'go-lang',
39- text: 'Go',
40- href: 'https://golang.org/',
41- title: 'Golang'
39 + text: 'Golang',
40 + href: 'https://golang.org/'
4241 },
4342 {
4443 expression: 'sql-server',
4544 text: 'SQL Server',
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 94414 bytes
New file size: 108009 bytes
package.jsonView
@@ -18,12 +18,15 @@
1818 "next": "^10.1.3",
1919 "next-seo": "^4.24.0",
2020 "react": "^17.0.2",
2121 "react-dom": "^17.0.2",
22 + "styled-components": "^5.2.3",
2223 "styled-jsx": "^3.4.4"
2324 },
2425 "devDependencies": {
2526 "@types/node": "^14.14.37",
2627 "@types/react": "^17.0.3",
28 + "@types/styled-components": "^5.1.9",
29 + "babel-plugin-styled-components": "^1.12.0",
2730 "typescript": "^4.2.4"
2831 }
2932 }
pages/_document.tsxView
@@ -1,10 +1,33 @@
11 import Document, { Html, Head, Main, NextScript } from 'next/document';
2 +import { ServerStyleSheet } from 'styled-components';
23
34 class MyDocument extends Document {
45 static async getInitialProps(ctx) {
6 + const sheet = new ServerStyleSheet();
7 + const originalRenderPage = ctx.renderPage;
58 const initialProps = await Document.getInitialProps(ctx);
69
10 + try {
11 + ctx.renderPage = () =>
12 + originalRenderPage({
13 + enhanceApp: App => props => sheet.collectStyles(<App {...props} />),
14 + })
15 +
16 + const initialProps = await Document.getInitialProps(ctx)
17 + return {
18 + ...initialProps,
19 + styles: (
20 + <>
21 + {initialProps.styles}
22 + {sheet.getStyleElement()}
23 + </>
24 + ),
25 + }
26 + } finally {
27 + sheet.seal()
28 + }
29 +
730 return {
831 ...initialProps
932 };
1033 }
@@ -22,5 +45,6 @@
2245 )
2346 }
2447 }
2548
26-export default MyDocument
49 +export default MyDocument;
50 +
.babelrcView
@@ -1,0 +1,4 @@
1 +{
2 + "presets": ["next/babel"],
3 + "plugins": [["styled-components", { "ssr": true }]]
4 +}

Built with git-ssb-web