Skip to content

Commit 571fd38

Browse files
authored
Merge branch 'canary' into cms-builder-io-example
2 parents e6bbc07 + 0d5baf2 commit 571fd38

File tree

153 files changed

+1700
-1937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+1700
-1937
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ node_modules
22
**/.next/**
33
**/_next/**
44
**/dist/**
5-
e2e-tests/**
65
examples/with-typescript-eslint-jest/**
76
examples/with-kea/**
87
packages/next/bundles/webpack/packages/*.runtime.js
@@ -17,5 +16,4 @@ packages/next-codemod/**/*.js
1716
packages/next-codemod/**/*.d.ts
1817
packages/next-env/**/*.d.ts
1918
test/integration/async-modules/**
20-
test/integration/eslint/**
2119
test-timings.json

docs/advanced-features/codemods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ npx @next/codemod withamp-to-config
132132

133133
### `url-to-withrouter`
134134

135-
Transforms the deprecated automatically injected `url` property on top level pages to using `withRouter` and the `router` property it injects. Read more here: [err.sh/next.js/url-deprecated](https://err.sh/next.js/url-deprecated)
135+
Transforms the deprecated automatically injected `url` property on top level pages to using `withRouter` and the `router` property it injects. Read more here: [https://nextjs.org/docs/messages/url-deprecated](https://nextjs.org/docs/messages/url-deprecated)
136136

137137
For example:
138138

docs/advanced-features/customizing-babel-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description: Extend the babel preset added by Next.js with your own configs.
1313

1414
Next.js includes the `next/babel` preset to your app, which includes everything needed to compile React applications and server-side code. But if you want to extend the default Babel configs, it's also possible.
1515

16-
To start, you only need to define a `.babelrc` file at the top of your app. If such a file is found, it will be considered as the _source of truth_, and therefore it needs to define what Next.js needs as well, which is the `next/babel` preset.
16+
To start, you only need to define a `.babelrc` file (or `babel.config.js`) at the top of your app. If such a file is found, it will be considered as the _source of truth_, and therefore it needs to define what Next.js needs as well, which is the `next/babel` preset.
1717

1818
Here's an example `.babelrc` file:
1919

docs/api-reference/next.config.js/eslint-warnings-errors.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

docs/api-reference/next.config.js/headers.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ module.exports = {
4343

4444
- `source` is the incoming request path pattern.
4545
- `headers` is an array of header objects with the `key` and `value` properties.
46+
- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
47+
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
48+
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
49+
50+
Headers are checked before the filesystem which includes pages and `/public` files.
4651

4752
## Header Overriding Behavior
4853

docs/api-reference/next.config.js/redirects.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ module.exports = {
3838
- `source` is the incoming request path pattern.
3939
- `destination` is the path you want to route to.
4040
- `permanent` if the redirect is permanent or not.
41+
- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
42+
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
43+
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
44+
45+
Redirects are checked before the filesystem which includes pages and `/public` files.
4146

4247
## Path Matching
4348

docs/api-reference/next.config.js/rewrites.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Rewrites allow you to map an incoming request path to a different destination pa
1717

1818
Rewrites are only available on the Node.js environment and do not affect client-side routing.
1919

20-
Rewrites are not able to override public files or routes in the pages directory as these have higher priority than rewrites. For example, if you have `pages/index.js` you are not able to rewrite `/` to another location unless you rename the `pages/index.js` file.
21-
2220
To use rewrites you can use the `rewrites` key in `next.config.js`:
2321

2422
```js
@@ -36,8 +34,48 @@ module.exports = {
3634

3735
`rewrites` is an async function that expects an array to be returned holding objects with `source` and `destination` properties:
3836

39-
- `source` is the incoming request path pattern.
40-
- `destination` is the path you want to route to.
37+
- `source`: `String` - is the incoming request path pattern.
38+
- `destination`: `String` is the path you want to route to.
39+
- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
40+
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
41+
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
42+
43+
Rewrites are applied after checking the filesystem (pages and `/public` files) and before dynamic routes by default. This behavior can be changed by instead returning an object instead of an array from the `rewrites` function:
44+
45+
```js
46+
module.exports = {
47+
async rewrites() {
48+
return {
49+
beforeFiles: [
50+
// These rewrites are checked after headers/redirects
51+
// and before pages/public files which allows overriding
52+
// page files
53+
{
54+
source: '/some-page',
55+
destination: '/somewhere-else',
56+
has: [{ type: 'query', key: 'overrideMe' }],
57+
},
58+
],
59+
afterFiles: [
60+
// These rewrites are checked after pages/public files
61+
// are checked but before dynamic routes
62+
{
63+
source: '/non-existent',
64+
destination: '/somewhere-else',
65+
},
66+
],
67+
fallback: [
68+
// These rewrites are checked after both pages/public files
69+
// and dynamic routes are checked
70+
{
71+
source: '/:path*',
72+
destination: 'https://my-old-site.com',
73+
},
74+
],
75+
}
76+
},
77+
}
78+
```
4179

4280
## Rewrite parameters
4381

docs/api-reference/next/router.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function ActiveLink({ children, href }) {
1717
const router = useRouter()
1818
const style = {
1919
marginRight: 10,
20-
color: router.pathname === href ? 'red' : 'black',
20+
color: router.asPath === href ? 'red' : 'black',
2121
}
2222

2323
const handleClick = (e) => {

docs/basic-features/eslint.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

docs/basic-features/static-file-serving.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ This folder is also useful for `robots.txt`, `favicon.ico`, Google Site Verifica
2626
2727
> **Note**: Be sure to not have a static file with the same name as a file in the `pages/` directory, as this will result in an error.
2828
>
29-
> Read more: <http://err.sh/next.js/conflicting-public-file-page>
29+
> Read more: <https://nextjs.org/docs/messages/conflicting-public-file-page>
3030
3131
> **Note**: Only assets that are in the `public` directory at [build time](/docs/api-reference/cli.md#build) will be served by Next.js. Files added at runtime won't be available. We recommend using a third party service like [AWS S3](https://aws.amazon.com/s3/) for persistent file storage.

0 commit comments

Comments
 (0)