Update documentation links (#19502)
- Updated some links in docs that don't have the `.md` extension. Not required for our live docs but useful for the GitHub view. - Updated links that go to https://nextjs.org/docs to a relative path, that way they'll work for versioned docs - Updated the `Regex Path Matching` example to be consistent with the paragraph above and with the official example in /examples.
This commit is contained in:
parent
d640590907
commit
0ed8152858
5 changed files with 12 additions and 12 deletions
|
@ -152,13 +152,13 @@ When `localeDetection` is set to `false` Next.js will no longer automatically re
|
|||
|
||||
## Accessing the locale information
|
||||
|
||||
You can access the locale information via the Next.js router. For example, using the [`useRouter()`](https://nextjs.org/docs/api-reference/next/router#userouter) hook the following properties are available:
|
||||
You can access the locale information via the Next.js router. For example, using the [`useRouter()`](/docs/api-reference/next/router.md#userouter) hook the following properties are available:
|
||||
|
||||
- `locale` contains the currently active locale.
|
||||
- `locales` contains all configured locales.
|
||||
- `defaultLocale` contains the configured default locale.
|
||||
|
||||
When [pre-rendering](/docs/basic-features/pages#static-generation-recommended) pages with `getStaticProps` or `getServerSideProps`, the locale information is provided in [the context](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation) provided to the function.
|
||||
When [pre-rendering](/docs/basic-features/pages.md#static-generation-recommended) pages with `getStaticProps` or `getServerSideProps`, the locale information is provided in [the context](/docs/basic-features/data-fetching.md#getstaticprops-static-generation) provided to the function.
|
||||
|
||||
When leveraging `getStaticPaths`, the configured locales are provided in the context parameter of the function under `locales` and the configured defaultLocale under `defaultLocale`.
|
||||
|
||||
|
@ -255,7 +255,7 @@ export async function getStaticProps({ locale }) {
|
|||
|
||||
### Dynamic getStaticProps Pages
|
||||
|
||||
For dynamic `getStaticProps` pages, any locale variants of the page that is desired to be prerendered needs to be returned from [`getStaticPaths`](/docs/basic-features/data-fetching#getstaticpaths-static-generation). Along with the `params` object that can be returned for the `paths`, you can also return a `locale` field specifying which locale you want to render. For example:
|
||||
For dynamic `getStaticProps` pages, any locale variants of the page that is desired to be prerendered needs to be returned from [`getStaticPaths`](/docs/basic-features/data-fetching.md#getstaticpaths-static-generation). Along with the `params` object that can be returned for the `paths`, you can also return a `locale` field specifying which locale you want to render. For example:
|
||||
|
||||
```js
|
||||
// pages/blog/[slug].js
|
||||
|
|
|
@ -72,4 +72,4 @@ By default, `next export` will generate an `out` directory, which can be served
|
|||
- [API Routes](/docs/api-routes/introduction.md) are not supported by this method because they can't be prerendered to HTML.
|
||||
- [`getServerSideProps`](/docs/basic-features/data-fetching.md#getserversideprops-server-side-rendering) cannot be used within pages because the method requires a server. Consider using [`getStaticProps`](/docs/basic-features/data-fetching.md#getstaticprops-static-generation) instead.
|
||||
- [Internationalized Routing](/docs/advanced-features/i18n-routing.md) is not supported as it requires Next.js' server-side routing.
|
||||
- The [`next/image`](/docs/api-reference/next/image) component's default loader is not supported when using `next export`. However, other [loader](https://nextjs.org/docs/basic-features/image-optimization#loader) options will work.
|
||||
- The [`next/image`](/docs/api-reference/next/image.md) component's default loader is not supported when using `next export`. However, other [loader](/docs/basic-features/image-optimization.md#loader) options will work.
|
||||
|
|
|
@ -77,15 +77,15 @@ module.exports = {
|
|||
|
||||
### Regex Path Matching
|
||||
|
||||
To match a regex path you can wrap the regex in parenthesis after a parameter, for example `/blog/:slug(\\d{1,})` will match `/blog/123` but not `/blog/abc`:
|
||||
To match a regex path you can wrap the regex in parenthesis after a parameter, for example `/post/:slug(\\d{1,})` will match `/post/123` but not `/post/abc`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
async redirects() {
|
||||
return [
|
||||
{
|
||||
source: '/old-blog/:post(\\d{1,})',
|
||||
destination: '/blog/:post', // Matched parameters can be used in the destination
|
||||
source: '/post/:slug(\\d{1,})',
|
||||
destination: '/news/:slug', // Matched parameters can be used in the destination
|
||||
permanent: false,
|
||||
},
|
||||
]
|
||||
|
|
|
@ -44,8 +44,8 @@ The following is the definition of the `router` object returned by both [`useRou
|
|||
- `pathname`: `String` - Current route. That is the path of the page in `/pages`
|
||||
- `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.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/basic-features/data-fetching#fallback-pages).
|
||||
- `basePath`: `String` - The active [basePath](/docs/api-reference/next.config.js/basepath) (if enabled).
|
||||
- `isFallback`: `boolean` - Whether the current page is in [fallback mode](/docs/basic-features/data-fetching.md#fallback-pages).
|
||||
- `basePath`: `String` - The active [basePath](/docs/api-reference/next.config.js/basepath.md) (if enabled).
|
||||
- `locale`: `String` - The active locale (if enabled).
|
||||
- `locales`: `String[]` - All supported locales (if enabled).
|
||||
- `defaultLocale`: `String` - The current default locale (if enabled).
|
||||
|
|
|
@ -20,15 +20,15 @@ npm install next@latest
|
|||
|
||||
#### Production Deployment on Vercel
|
||||
|
||||
If you previously configured `routes` in your `vercel.json` file for dynamic routes, these rules can be removed when leveraging Next.js 9's new [Dynamic Routing feature](https://nextjs.org/docs/routing/dynamic-routes).
|
||||
If you previously configured `routes` in your `vercel.json` file for dynamic routes, these rules can be removed when leveraging Next.js 9's new [Dynamic Routing feature](/docs/routing/dynamic-routes.md).
|
||||
|
||||
Next.js 9's dynamic routes are **automatically configured on [Vercel](https://vercel.com/)** and do not require any `vercel.json` customization.
|
||||
|
||||
You can read more about [Dynamic Routing here](https://nextjs.org/docs/routing/dynamic-routes).
|
||||
You can read more about [Dynamic Routing here](/docs/routing/dynamic-routes.md).
|
||||
|
||||
#### Check your Custom <App> (`pages/_app.js`)
|
||||
|
||||
If you previously copied the [Custom `<App>`](https://nextjs.org/docs/advanced-features/custom-app) example, you may be able to remove your `getInitialProps`.
|
||||
If you previously copied the [Custom `<App>`](/docs/advanced-features/custom-app.md) example, you may be able to remove your `getInitialProps`.
|
||||
|
||||
Removing `getInitialProps` from `pages/_app.js` (when possible) is important to leverage new Next.js features!
|
||||
|
||||
|
|
Loading…
Reference in a new issue