From ce04002840efa56bf43ada1d36a6355943b3c7c9 Mon Sep 17 00:00:00 2001 From: molebox Date: Wed, 12 Jan 2022 22:06:23 +0100 Subject: [PATCH 1/3] Changed data fetching file name to overview to fix meta data title --- docs/advanced-features/custom-app.md | 4 ++-- docs/advanced-features/custom-document.md | 2 +- docs/advanced-features/preview-mode.md | 4 ++-- docs/api-reference/data-fetching/get-initial-props.md | 2 +- .../data-fetching/get-server-side-props.md | 2 +- docs/api-reference/data-fetching/get-static-props.md | 2 +- docs/api-reference/next/router.md | 2 +- docs/authentication.md | 4 ++-- .../data-fetching/{index.md => overview.md} | 2 +- docs/basic-features/environment-variables.md | 2 +- docs/basic-features/pages.md | 2 +- docs/faq.md | 2 +- docs/getting-started.md | 2 +- docs/manifest.json | 10 +++++++++- docs/migrating/from-create-react-app.md | 2 +- docs/migrating/from-gatsby.md | 4 ++-- 16 files changed, 28 insertions(+), 20 deletions(-) rename docs/basic-features/data-fetching/{index.md => overview.md} (93%) diff --git a/docs/advanced-features/custom-app.md b/docs/advanced-features/custom-app.md index 73d65f5666a9721..cf8a8fd1fee3332 100644 --- a/docs/advanced-features/custom-app.md +++ b/docs/advanced-features/custom-app.md @@ -38,14 +38,14 @@ export default MyApp The `Component` prop is the active `page`, so whenever you navigate between routes, `Component` will change to the new `page`. Therefore, any props you send to `Component` will be received by the `page`. -`pageProps` is an object with the initial props that were preloaded for your page by one of our [data fetching methods](/docs/basic-features/data-fetching/index.md), otherwise it's an empty object. +`pageProps` is an object with the initial props that were preloaded for your page by one of our [data fetching methods](/docs/basic-features/data-fetching/overview.md), otherwise it's an empty object. ### Caveats - If your app is running and you added a custom `App`, you'll need to restart the development server. Only required if `pages/_app.js` didn't exist before. - Adding a custom [`getInitialProps`](/docs/api-reference/data-fetching/get-initial-props.md) in your `App` will disable [Automatic Static Optimization](/docs/advanced-features/automatic-static-optimization.md) in pages without [Static Generation](/docs/basic-features/data-fetching/get-static-props.md). - When you add `getInitialProps` in your custom app, you must `import App from "next/app"`, call `App.getInitialProps(appContext)` inside `getInitialProps` and merge the returned object into the return value. -- `App` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/index.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). +- `App` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/overview.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). ### TypeScript diff --git a/docs/advanced-features/custom-document.md b/docs/advanced-features/custom-document.md index 3ec0e856bee7b28..b6af8d8b18b1e9b 100644 --- a/docs/advanced-features/custom-document.md +++ b/docs/advanced-features/custom-document.md @@ -54,7 +54,7 @@ The `ctx` object is equivalent to the one received in [`getInitialProps`](/docs/ - `Document` is only rendered in the server, event handlers like `onClick` won't work. - React components outside of `
` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), take a look at the [`App`](/docs/advanced-features/custom-app.md) component instead. - `Document`'s `getInitialProps` function is not called during client-side transitions, nor when a page is [statically optimized](/docs/advanced-features/automatic-static-optimization.md). -- `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/index.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). +- `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/overview.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). ## Customizing `renderPage` diff --git a/docs/advanced-features/preview-mode.md b/docs/advanced-features/preview-mode.md index a5b7ac69c3e6594..4d467c9e07401fa 100644 --- a/docs/advanced-features/preview-mode.md +++ b/docs/advanced-features/preview-mode.md @@ -27,7 +27,7 @@ description: Next.js has the preview mode for statically generated pages. You ca -In the [Pages documentation](/docs/basic-features/pages.md) and the [Data Fetching documentation](/docs/basic-features/data-fetching/index.md), we talked about how to pre-render a page at build time (**Static Generation**) using `getStaticProps` and `getStaticPaths`. +In the [Pages documentation](/docs/basic-features/pages.md) and the [Data Fetching documentation](/docs/basic-features/data-fetching/overview.md), we talked about how to pre-render a page at build time (**Static Generation**) using `getStaticProps` and `getStaticPaths`. Static Generation is useful when your pages fetch data from a headless CMS. However, it’s not ideal when you’re writing a draft on your headless CMS and want to **preview** the draft immediately on your page. You’d want Next.js to render these pages at **request time** instead of build time and fetch the draft content instead of the published content. You’d want Next.js to bypass Static Generation only for this specific case. @@ -230,7 +230,7 @@ This ensures that the bypass cookie can’t be guessed. The following pages might also be useful.
- + Data Fetching: Learn more about data fetching in Next.js. diff --git a/docs/api-reference/data-fetching/get-initial-props.md b/docs/api-reference/data-fetching/get-initial-props.md index f8295dbda52c225..004ba283a4ff5f5 100644 --- a/docs/api-reference/data-fetching/get-initial-props.md +++ b/docs/api-reference/data-fetching/get-initial-props.md @@ -119,7 +119,7 @@ export default class Page extends React.Component { For more information on what to do next, we recommend the following sections:
- + Data Fetching: Learn more about data fetching in Next.js. diff --git a/docs/api-reference/data-fetching/get-server-side-props.md b/docs/api-reference/data-fetching/get-server-side-props.md index 10b469ae282175c..87bb5891f5267c5 100644 --- a/docs/api-reference/data-fetching/get-server-side-props.md +++ b/docs/api-reference/data-fetching/get-server-side-props.md @@ -144,7 +144,7 @@ export default Page For more information on what to do next, we recommend the following sections:
- + Data Fetching: Learn more about data fetching in Next.js. diff --git a/docs/api-reference/data-fetching/get-static-props.md b/docs/api-reference/data-fetching/get-static-props.md index 23c0e7090098116..f66828e036c2c33 100644 --- a/docs/api-reference/data-fetching/get-static-props.md +++ b/docs/api-reference/data-fetching/get-static-props.md @@ -237,7 +237,7 @@ export default Blog For more information on what to do next, we recommend the following sections:
- + Data Fetching: Learn more about data fetching in Next.js. diff --git a/docs/api-reference/next/router.md b/docs/api-reference/next/router.md index d595c3ac54703ca..69cacb1e66974ac 100644 --- a/docs/api-reference/next/router.md +++ b/docs/api-reference/next/router.md @@ -42,7 +42,7 @@ export default ActiveLink The following is the definition of the `router` object returned by both [`useRouter`](#useRouter) and [`withRouter`](#withRouter): - `pathname`: `String` - Current route. That is the path of the page in `/pages`, the configured `basePath` or `locale` is not included. -- `query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching/index.md). Defaults to `{}` +- `query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching/overview.md). Defaults to `{}` - `asPath`: `String` - The path (including the query) shown in the browser without the configured `basePath` or `locale`. - `isFallback`: `boolean` - Whether the current page is in [fallback mode](/docs/api-reference/data-fetching/get-static-paths.md#fallback-pages). - `basePath`: `String` - The active [basePath](/docs/api-reference/next.config.js/basepath.md) (if enabled). diff --git a/docs/authentication.md b/docs/authentication.md index 45dc5bbe185a421..9291c06c51767c3 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -8,7 +8,7 @@ Authentication verifies who a user is, while authorization controls what a user ## Authentication Patterns -The first step to identifying which authentication pattern you need is understanding the [data-fetching strategy](/docs/basic-features/data-fetching/index.md) you want. We can then determine which authentication providers support this strategy. There are two main patterns: +The first step to identifying which authentication pattern you need is understanding the [data-fetching strategy](/docs/basic-features/data-fetching/overview.md) you want. We can then determine which authentication providers support this strategy. There are two main patterns: - Use [static generation](/docs/basic-features/pages.md#static-generation-recommended) to server-render a loading state, followed by fetching user data client-side. - Fetch user data [server-side](/docs/basic-features/pages.md#server-side-rendering) to eliminate a flash of unauthenticated content. @@ -154,7 +154,7 @@ For more information on what to do next, we recommend the following sections:
- + Data Fetching: Learn more about data fetching in Next.js. diff --git a/docs/basic-features/data-fetching/index.md b/docs/basic-features/data-fetching/overview.md similarity index 93% rename from docs/basic-features/data-fetching/index.md rename to docs/basic-features/data-fetching/overview.md index d414515f11ad86c..290e189dbe45f64 100644 --- a/docs/basic-features/data-fetching/index.md +++ b/docs/basic-features/data-fetching/overview.md @@ -1,5 +1,5 @@ --- -description: 'Data fetching in Next.js allows you to render your content in different ways, depending on your applications use case. These include pre-rendering with server-side rendering or static-site generation, and incremental static regeneration. Learn how to manage your application data in Next.js.' +description: 'Next.js allows you to fetch data in multiple ways, with pre-rendering, server-side rendering or static-site generation, and incremental static regeneration. Learn how to manage your application data in Next.js.' --- # Data Fetching Overview diff --git a/docs/basic-features/environment-variables.md b/docs/basic-features/environment-variables.md index 4e9211bc2f9f353..91182cbb2f3f963 100644 --- a/docs/basic-features/environment-variables.md +++ b/docs/basic-features/environment-variables.md @@ -30,7 +30,7 @@ DB_USER=myuser DB_PASS=mypassword ``` -This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in [Next.js data fetching methods](/docs/basic-features/data-fetching/index.md) and [API routes](/docs/api-routes/introduction.md). +This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in [Next.js data fetching methods](/docs/basic-features/data-fetching/overview.md) and [API routes](/docs/api-routes/introduction.md). For example, using [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md): diff --git a/docs/basic-features/pages.md b/docs/basic-features/pages.md index ad46f39e5913ae7..0f436f91465c763 100644 --- a/docs/basic-features/pages.md +++ b/docs/basic-features/pages.md @@ -262,7 +262,7 @@ We've discussed two forms of pre-rendering for Next.js. We recommend you to read the following sections next:
- + Data Fetching: Learn more about data fetching in Next.js. diff --git a/docs/faq.md b/docs/faq.md index 187f8836762c33a..96025209501f57f 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -39,7 +39,7 @@ description: Get to know more about Next.js with the frequently asked questions.
How do I fetch data? -

It's up to you. You can use the fetch API or SWR inside your React components for remote data fetching; or use our data fetching methods for initial data population.

+

It's up to you. You can use the fetch API or SWR inside your React components for remote data fetching; or use our data fetching methods for initial data population.

diff --git a/docs/getting-started.md b/docs/getting-started.md index a9d0501b1941bef..b01d60fd909276a 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -91,7 +91,7 @@ So far, we get: - Automatic compilation and bundling (with webpack and babel) - [React Fast Refresh](https://nextjs.org/blog/next-9-4#fast-refresh) -- [Static generation and server-side rendering](/docs/basic-features/data-fetching/index.md) of [`./pages/`](/docs/basic-features/pages.md) +- [Static generation and server-side rendering](/docs/basic-features/data-fetching/overview.md) of [`./pages/`](/docs/basic-features/pages.md) - [Static file serving](/docs/basic-features/static-file-serving.md). `./public/` is mapped to `/` In addition, any Next.js application is ready for production from the start, read more in our [Deployment documentation](/docs/deployment.md). diff --git a/docs/manifest.json b/docs/manifest.json index 9e2534b1baa3da1..e4ea5939a6d4fa0 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -16,10 +16,18 @@ { "title": "Data Fetching", "path": "/docs/basic-features/data-fetching/index.md", + "redirect": { + "destination": "/docs/basic-features/data-fetching/overview.md", + "permanent": true + }, "routes": [ { "title": "Overview", - "path": "/docs/basic-features/data-fetching/index.md" + "path": "/docs/basic-features/data-fetching/index.md", + "redirect": { + "destination": "/docs/basic-features/data-fetching/overview.md", + "permanent": true + } }, { "title": "getServerSideProps", diff --git a/docs/migrating/from-create-react-app.md b/docs/migrating/from-create-react-app.md index 77697644ec1c496..54bf69da832abe4 100644 --- a/docs/migrating/from-create-react-app.md +++ b/docs/migrating/from-create-react-app.md @@ -6,7 +6,7 @@ description: Learn how to transition an existing Create React App project to Nex This guide will help you understand how to transition from an existing non-ejected Create React App project to Next.js. Migrating to Next.js will allow you to: -- Choose which [data fetching](/docs/basic-features/data-fetching/index.md) strategy you want on a per-page basis. +- Choose which [data fetching](/docs/basic-features/data-fetching/overview.md) strategy you want on a per-page basis. - Use [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) to update _existing_ pages by re-rendering them in the background as traffic comes in. - Use [API Routes](/docs/api-routes/introduction.md). diff --git a/docs/migrating/from-gatsby.md b/docs/migrating/from-gatsby.md index fa46c9819c22b71..36d27b38a8b1e95 100644 --- a/docs/migrating/from-gatsby.md +++ b/docs/migrating/from-gatsby.md @@ -6,7 +6,7 @@ description: Learn how to transition an existing Gatsby project to Next.js. This guide will help you understand how to transition from an existing Gatsby project to Next.js. Migrating to Next.js will allow you to: -- Choose which [data fetching](/docs/basic-features/data-fetching/index.md) strategy you want on a per-page basis. +- Choose which [data fetching](/docs/basic-features/data-fetching/overview.md) strategy you want on a per-page basis. - Use [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) to update _existing_ pages by re-rendering them in the background as traffic comes in. - Use [API Routes](/docs/api-routes/introduction.md). @@ -92,7 +92,7 @@ Update any import statements, switch `to` to `href`, and add an `` tag as a c The largest difference between Gatsby and Next.js is how data fetching is implemented. Gatsby is opinionated with GraphQL being the default strategy for retrieving data across your application. With Next.js, you get to choose which strategy you want (GraphQL is one supported option). -Gatsby uses the `graphql` tag to query data in the pages of your site. This may include local data, remote data, or information about your site configuration. Gatsby only allows the creation of static pages. With Next.js, you can choose on a [per-page basis](/docs/basic-features/pages.md) which [data fetching strategy](/docs/basic-features/data-fetching/index.md) you want. For example, `getServerSideProps` allows you to do server-side rendering. If you wanted to generate a static page, you'd export `getStaticProps` / `getStaticPaths` inside the page, rather than using `pageQuery`. For example: +Gatsby uses the `graphql` tag to query data in the pages of your site. This may include local data, remote data, or information about your site configuration. Gatsby only allows the creation of static pages. With Next.js, you can choose on a [per-page basis](/docs/basic-features/pages.md) which [data fetching strategy](/docs/basic-features/data-fetching/overview.md) you want. For example, `getServerSideProps` allows you to do server-side rendering. If you wanted to generate a static page, you'd export `getStaticProps` / `getStaticPaths` inside the page, rather than using `pageQuery`. For example: ```js // src/pages/[slug].js From 782856cc42f290ecd16d73708650757ca3fe1d2f Mon Sep 17 00:00:00 2001 From: Rich Haines Date: Fri, 21 Jan 2022 13:18:19 +0100 Subject: [PATCH 2/3] Update docs/api-reference/data-fetching/get-server-side-props.md Co-authored-by: Steven --- docs/api-reference/data-fetching/get-server-side-props.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-reference/data-fetching/get-server-side-props.md b/docs/api-reference/data-fetching/get-server-side-props.md index 87bb5891f5267c5..296e445aed7666d 100644 --- a/docs/api-reference/data-fetching/get-server-side-props.md +++ b/docs/api-reference/data-fetching/get-server-side-props.md @@ -144,7 +144,7 @@ export default Page For more information on what to do next, we recommend the following sections:
- + Data Fetching: Learn more about data fetching in Next.js. From 10f23a9b3a18e9bb8602ce2d786cfdcf6318ff34 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 27 Jan 2022 08:52:34 -0600 Subject: [PATCH 3/3] Update manifest and check --- docs/manifest.json | 4 ++++ scripts/check-manifests.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/manifest.json b/docs/manifest.json index 8d3336c1446fc4f..bdb700f85474163 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -24,6 +24,10 @@ "permanent": true } }, + { + "title": "Overview", + "path": "/docs/basic-features/data-fetching/overview.md" + }, { "title": "getServerSideProps", "path": "/docs/basic-features/data-fetching/get-server-side-props.md" diff --git a/scripts/check-manifests.js b/scripts/check-manifests.js index 68091d7fa6cabd0..3a1e8d929fb6a06 100755 --- a/scripts/check-manifests.js +++ b/scripts/check-manifests.js @@ -8,7 +8,7 @@ const glob = promisify(globOrig) function collectPaths(routes, paths = []) { for (const route of routes) { - if (route.path) { + if (route.path && !route.redirect) { paths.push(route.path) }