Skip to content

Commit c9fadc8

Browse files
committed
Merge branch 'canary' of github.com:vercel/next.js into cms-builder-io-example
* 'canary' of github.com:vercel/next.js: [chore] Update `deta` version in examples (vercel#30204) fix: typescript example supporting strict w/ version >= 4.4 (vercel#33042) Avoid page double render with emotion vanilla (vercel#30541) converted the old tailwind css example to typescript (vercel#32808) fix(examples/cms-contentful): add correct Content-Type + missing closing tag for html (vercel#30321) Ensure NODE_ENV is not inlined for next/jest (vercel#33032) Rename api in with-redis example (vercel#33016) Remove unused turbo remote cache env vars (vercel#33030) v12.0.8-canary.17 Re-enable turbo caching for swc build jobs (vercel#32617) feat(cli): introduce `next info` CLI command (vercel#32972) fix(examples): add missing dependencies wo (vercel#32977) Updated wrong link to example of gtag init in measuring-performance.md (vercel#32974) v12.0.8-canary.16 Revert "Reduce install size for linux glibc/musl (vercel#32850)" (vercel#32973) Ensure middleware is output in standalone mode (vercel#32967) v12.0.8-canary.15 Reduce install size for linux glibc/musl (vercel#32850) Fixes issue with makeStylesheetInert (vercel#32027) Ensure setImmediate and punycode are polyfilled (vercel#32768)
2 parents af81be9 + 551c9d6 commit c9fadc8

File tree

66 files changed

+755
-280
lines changed

Some content is hidden

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

66 files changed

+755
-280
lines changed

.github/ISSUE_TEMPLATE/1.bug_report.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ body:
1414
- type: markdown
1515
attributes:
1616
value: 'next@canary is the beta version of Next.js. It includes all features and fixes that are pending to land on the stable release line.'
17+
- type: textarea
18+
attributes:
19+
label: Run `next info` (available from version 12.0.8 and up)
20+
description: Please run `next info` in the root directory of your project and paste the results. You might need to use `npx --no-install next info` if next is not in the current PATH.
21+
validations:
22+
required: false
1723
- type: input
1824
attributes:
1925
label: What version of Next.js are you using?

.github/workflows/build_test_deploy.yml

Lines changed: 141 additions & 142 deletions
Large diffs are not rendered by default.

docs/advanced-features/measuring-performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export function reportWebVitals(metric) {
164164
> ```js
165165
> export function reportWebVitals({ id, name, label, value }) {
166166
> // Use `window.gtag` if you initialized Google Analytics as this example:
167-
> // https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics/pages/_document.js
167+
> // https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics/pages/_app.js
168168
> window.gtag('event', name, {
169169
> event_category:
170170
> label === 'web-vital' ? 'Web Vitals' : 'Next.js custom metric',

docs/api-reference/cli.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Usage
2121
$ next <command>
2222

2323
Available commands
24-
build, start, export, dev, lint, telemetry
24+
build, start, export, dev, lint, telemetry, info
2525

2626
Options
2727
--version, -v Version number
@@ -125,3 +125,36 @@ Next.js collects **completely anonymous** telemetry data about general usage.
125125
Participation in this anonymous program is optional, and you may opt-out if you'd not like to share any information.
126126

127127
To learn more about Telemetry, [please read this document](https://nextjs.org/telemetry/).
128+
129+
## Info
130+
131+
`next info` prints relevant details about the current system which can be used to report Next.js bugs.
132+
This information includes Operating System platform/arch/version, Binaries (Node.js, npm, Yarn, pnpm) and npm package versions (`next`, `react`, `react-dom`).
133+
134+
Running the following in your project's root directory:
135+
136+
```bash
137+
next info
138+
```
139+
140+
will give you information like this example:
141+
142+
```bash
143+
144+
Operating System:
145+
Platform: linux
146+
Arch: x64
147+
Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021
148+
Binaries:
149+
Node: 16.13.0
150+
npm: 8.1.0
151+
Yarn: 1.22.17
152+
pnpm: 6.24.2
153+
Relevant packages:
154+
next: 12.0.8
155+
react: 17.0.2
156+
react-dom: 17.0.2
157+
158+
```
159+
160+
This information should then be pasted into GitHub Issues.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { getPreviewPostBySlug } from '../../lib/api'
2+
3+
export default async function preview(req, res) {
4+
const { secret, slug } = req.query
5+
6+
if (secret !== process.env.CONTENTFUL_PREVIEW_SECRET || !slug) {
7+
return res.status(401).json({ message: 'Invalid token' })
8+
}
9+
10+
// Fetch the headless CMS to check if the provided `slug` exists
11+
const post = await getPreviewPostBySlug(slug)
12+
13+
// If the slug doesn't exist prevent preview mode from being enabled
14+
if (!post) {
15+
return res.status(401).json({ message: 'Invalid slug' })
16+
}
17+
18+
// Enable Preview Mode by setting the cookies
19+
res.setPreviewData({})
20+
21+
// Redirect to the path from the fetched post
22+
// We don't redirect to req.query.slug as that might lead to open redirect vulnerabilities
23+
// res.writeHead(307, { Location: `/posts/${post.slug}` })
24+
const url = `/posts/${post.slug}`
25+
res.setHeader('Content-Type', 'text/html')
26+
res.write(
27+
`<!DOCTYPE html><html><head><meta http-equiv="Refresh" content="0; url=${url}" />
28+
<script>window.location.href = '${url}'</script>
29+
</head>
30+
</html>`
31+
)
32+
res.end()
33+
}

examples/with-deta-base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "next start"
77
},
88
"dependencies": {
9-
"deta": "^0.0.8",
9+
"deta": "^1.0.1",
1010
"next": "latest",
1111
"react": "^17.0.2",
1212
"react-dom": "^17.0.2"

examples/with-emotion-vanilla/pages/_document.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import * as React from 'react'
33
import { renderStatic } from '../shared/renderer'
44
export default class AppDocument extends Document {
55
static async getInitialProps(ctx) {
6-
const page = await ctx.renderPage()
7-
const { css, ids } = await renderStatic(page.html)
86
const initialProps = await Document.getInitialProps(ctx)
7+
const { css, ids } = await renderStatic(initialProps.html)
98
return {
109
...initialProps,
1110
styles: (

examples/with-jest/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
"@testing-library/jest-dom": "5.16.1",
1818
"@testing-library/react": "12.1.2",
1919
"@testing-library/user-event": "13.5.0",
20+
"@types/react": "17.0.38",
2021
"babel-jest": "27.4.5",
2122
"eslint": "8.5.0",
2223
"eslint-config-next": "latest",
2324
"eslint-plugin-testing-library": "5.0.1",
24-
"jest": "27.4.5"
25+
"jest": "27.4.5",
26+
"typescript": "4.5.4"
2527
}
2628
}

examples/with-redis/pages/api/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid'
22

33
import redis from '../../lib/redis'
44

5-
export default async function upvote(req, res) {
5+
export default async function create(req, res) {
66
const { title } = req.body
77

88
if (!title) {

examples/with-redis/pages/api/features.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import redis from '../../lib/redis'
22

3-
export default async function upvote(req, res) {
3+
export default async function getAllFeatures(req, res) {
44
const features = (await redis.hvals('features'))
55
.map((entry) => JSON.parse(entry))
66
.sort((a, b) => b.score - a.score)

0 commit comments

Comments
 (0)