From afba2fc65e6561b11b58cb19d7df3e653bdb0e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Sospedra?= Date: Tue, 28 Apr 2020 07:17:18 +0200 Subject: [PATCH 1/3] Add next.js SSG clarification comment --- examples/nextjs/pages/_document.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/nextjs/pages/_document.js b/examples/nextjs/pages/_document.js index c77f4e323228cc..1f56b9e1d474a6 100644 --- a/examples/nextjs/pages/_document.js +++ b/examples/nextjs/pages/_document.js @@ -24,6 +24,8 @@ export default class MyDocument extends Document { } } +// Note that this `getInitialProps` belongs to `_document` (instead of `_app`). +// Hence it works with next.js recommended Static Generation (SSG) MyDocument.getInitialProps = async (ctx) => { // Resolution order // From db7a0b940faebd3ec51dd3df999b57b62899f068 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 28 Apr 2020 11:30:14 +0200 Subject: [PATCH 2/3] Update _document.js --- examples/nextjs/pages/_document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/nextjs/pages/_document.js b/examples/nextjs/pages/_document.js index 1f56b9e1d474a6..c6094517c7ec69 100644 --- a/examples/nextjs/pages/_document.js +++ b/examples/nextjs/pages/_document.js @@ -24,8 +24,8 @@ export default class MyDocument extends Document { } } -// Note that this `getInitialProps` belongs to `_document` (instead of `_app`). -// Hence it works with next.js recommended Static Generation (SSG) +// `getInitialProps` belongs to `_document` (instead of `_app`), +// it's compatible with server-side generation (SSG). MyDocument.getInitialProps = async (ctx) => { // Resolution order // From d5453b2e487dae690f6b3f3b13b0db07c56b1992 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 28 Apr 2020 11:31:36 +0200 Subject: [PATCH 3/3] update typescipt example --- examples/nextjs-with-typescript/pages/_document.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/nextjs-with-typescript/pages/_document.tsx b/examples/nextjs-with-typescript/pages/_document.tsx index c77f4e323228cc..c6094517c7ec69 100644 --- a/examples/nextjs-with-typescript/pages/_document.tsx +++ b/examples/nextjs-with-typescript/pages/_document.tsx @@ -24,6 +24,8 @@ export default class MyDocument extends Document { } } +// `getInitialProps` belongs to `_document` (instead of `_app`), +// it's compatible with server-side generation (SSG). MyDocument.getInitialProps = async (ctx) => { // Resolution order //