Skip to content

Commit

Permalink
Merge branch 'canary' into swc-up-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 10, 2022
2 parents eddf795 + 320986a commit b697033
Show file tree
Hide file tree
Showing 42 changed files with 7,577 additions and 6,816 deletions.
11 changes: 2 additions & 9 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,8 @@ In general, all warnings and errors added should have these links attached.

Below are the steps to add a new link:

1. Create a new markdown file under the `errors` directory based on
`errors/template.md`:

```shell
cp errors/template.md errors/<error-file-name>.md
```

2. Add the newly added file to `errors/manifest.json`
3. Add the following url to your warning/error:
1. Run `yarn new-error` which will create the error document and update the manifest automatically.
2. Add the following url to your warning/error:
`https://nextjs.org/docs/messages/<file-path-without-dotmd>`.

For example, to link to `errors/api-routes-static-export.md` you use the url:
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-features/using-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Checkout my React component:
<MyComponent/>
export default = ({ children }) => <MyLayoutComponent meta={meta}>{children}</MyLayoutComponent>
export default ({ children }) => <MyLayoutComponent meta={meta}>{children}</MyLayoutComponent>
```
### Custom Elements
Expand Down
2 changes: 1 addition & 1 deletion errors/template.md → errors/template.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <!-- INSERT TITLE HERE -->
# {{title}}

#### Why This Error Occurred

Expand Down
8 changes: 4 additions & 4 deletions examples/cms-contentful/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ After setting up the content model (either manually or by running `npm run setup

**Content model overview**

![Content model overview](./docs/content-model-overview.jpg)
![Content model overview](./docs/content-model-overview.png)

### Step 4. Populate Content

Expand All @@ -158,7 +158,7 @@ Next, create another entry with the content type **Post**:

**Important:** For each entry and asset, you need to click on **Publish**. If not, the entry will be in draft state.

![Published content entry](./docs/content-entry-publish.jpg)
![Published content entry](./docs/content-entry-publish.png)

### Step 5. Set up environment variables

Expand Down Expand Up @@ -212,15 +212,15 @@ http://localhost:3000/api/preview?secret=<CONTENTFUL_PREVIEW_SECRET>&slug={entry

Replace `<CONTENTFUL_PREVIEW_SECRET>` with its respective value in `.env.local`.

![Content preview setup](./docs/content-preview-setup.jpg)
![Content preview setup](./docs/content-preview-setup.png)

Once saved, go to one of the posts you've created and:

- **Update the title**. For example, you can add `[Draft]` in front of the title.
- The state of the post will switch to **CHANGED** automatically. **Do not** publish it. By doing this, the post will be in draft state.
- In the sidebar, you will see the **Open preview** button. Click on it!

![Content entry overview](./docs/content-entry-preview.jpg)
![Content entry overview](./docs/content-entry-preview.png)

You will now be able to see the updated title. To exit preview mode, you can click on **Click here to exit preview mode** at the top of the page.

Expand Down
18 changes: 17 additions & 1 deletion examples/cms-contentful/components/post-body.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { documentToReactComponents } from '@contentful/rich-text-react-renderer'
import { BLOCKS } from '@contentful/rich-text-types'
import markdownStyles from './markdown-styles.module.css'
import RichTextAsset from './rich-text-asset'

const customMarkdownOptions = (content) => ({
renderNode: {
[BLOCKS.EMBEDDED_ASSET]: (node) => (
<RichTextAsset
id={node.data.target.sys.id}
assets={content.links.assets.block}
/>
),
},
})

export default function PostBody({ content }) {
return (
<div className="max-w-2xl mx-auto">
<div className={markdownStyles['markdown']}>
{documentToReactComponents(content.json)}
{documentToReactComponents(
content.json,
customMarkdownOptions(content)
)}
</div>
</div>
)
Expand Down
11 changes: 11 additions & 0 deletions examples/cms-contentful/components/rich-text-asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Image from 'next/image'

export default function RichTextAsset({ id, assets }) {
const asset = assets?.find((asset) => asset.sys.id === id)

if (asset?.url) {
return <Image src={asset.url} layout="fill" alt={asset.description} />
}

return null
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions examples/cms-contentful/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ author {
excerpt
content {
json
links {
assets {
block {
sys {
id
}
url
description
}
}
}
}
`

Expand Down
2 changes: 1 addition & 1 deletion examples/cms-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@contentful/rich-text-react-renderer": "^15.4.0",
"classnames": "2.3.1",
"date-fns": "2.22.1",
"date-fns": "2.28.0",
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.0.8-canary.18"
"version": "12.0.8-canary.19"
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"packages/*"
],
"scripts": {
"new-error": "plop error",
"new-test": "plop test",
"clean": "yarn lerna clean -y && yarn lerna bootstrap && yarn lerna exec 'rm -rf ./dist'",
"build": "yarn prepublish",
"lerna": "lerna",
Expand Down Expand Up @@ -128,6 +130,7 @@
"nprogress": "0.2.0",
"pixrem": "5.0.0",
"playwright-chromium": "1.14.1",
"plop": "3.0.5",
"postcss-nested": "4.2.1",
"postcss-pseudoelements": "5.0.0",
"postcss-short-size": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"keywords": [
"react",
"next",
Expand Down
4 changes: 3 additions & 1 deletion packages/create-next-app/templates/typescript/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
const nextConfig = {
reactStrictMode: true,
}

module.exports = nextConfig
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "12.0.8-canary.18",
"@next/eslint-plugin-next": "12.0.8-canary.19",
"@rushstack/eslint-patch": "^1.0.8",
"@typescript-eslint/parser": "^5.0.0",
"eslint-import-resolver-node": "^0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "12.0.8-canary.18",
"version": "12.0.8-canary.19",
"private": true,
"scripts": {
"build-native": "napi build --platform --cargo-name next_swc_napi native",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ export async function copyTracedFiles(
for (const page of pageKeys) {
if (MIDDLEWARE_ROUTE.test(page)) {
const { files } =
middlewareManifest.middleware[page.replace(/\/_middleware$/, '')]
middlewareManifest.middleware[page.replace(/\/_middleware$/, '') || '/']

for (const file of files) {
const originalPath = path.join(distDir, file)
Expand Down
Loading

0 comments on commit b697033

Please sign in to comment.