Skip to content

Commit 0df6033

Browse files
authored
Merge pull request #485 from reactjs/sync-5e9d673c
Sync with reactjs.org @ 5e9d673
2 parents d3a878f + e81a541 commit 0df6033

File tree

231 files changed

+11963
-5163
lines changed

Some content is hidden

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

231 files changed

+11963
-5163
lines changed

.circleci/config.yml

-20
This file was deleted.

.github/workflows/analyze.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
node-version: "14.x"
2020

2121
- name: Install dependencies
22-
uses: bahmutov/npm-install@v1.6.0
22+
uses: bahmutov/npm-install@v1.7.10
2323
with:
2424
working-directory: 'beta'
2525

.github/workflows/beta_site_lint.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: Beta Site Lint
1+
name: Beta Site Lint / Heading ID check
22

33
on:
4+
push:
5+
branches:
6+
- main # change this if your default branch is named differently
47
pull_request:
58
types: [opened, synchronize, reopened]
69

@@ -18,7 +21,7 @@ jobs:
1821
node-version: 12.x
1922

2023
- name: Install deps and build (with cache)
21-
uses: bahmutov/npm-install@v1.6.0
24+
uses: bahmutov/npm-install@v1.7.10
2225
with:
2326
working-directory: 'beta'
2427

.github/workflows/nodejs.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: Build
1+
name: Lint / Flow check
22

33
on:
4+
push:
5+
branches:
6+
- main # change this if your default branch is named differently
47
pull_request:
58
types: [opened, synchronize, reopened]
69

@@ -18,7 +21,7 @@ jobs:
1821
node-version: 12.x
1922

2023
- name: Install deps and build (with cache)
21-
uses: bahmutov/npm-install@v1.6.0
24+
uses: bahmutov/npm-install@v1.7.10
2225

2326
- name: Lint codebase
2427
run: yarn ci-check

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The documentation is divided into several sections with a different tone and pur
5555
1. `git push my-fork-name the-name-of-my-branch`
5656
1. Go to the [ja.reactjs.org repo](https://github.com/reactjs/ja.reactjs.org) and you should see recently pushed branches.
5757
1. Follow GitHub's instructions.
58-
1. If possible, include screenshots of visual changes. A [Netlify](https://www.netlify.com/) build will also be automatically created once you make your PR so other people can see your change.
58+
1. If possible, include screenshots of visual changes. A preview build is triggered after your changes are pushed to GitHub.
5959

6060
## Translation
6161

beta/.env.development

-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
NEXT_PUBLIC_HJ_SITE_ID = 2411683
2-
NEXT_PUBLIC_HJ_SITE_V = 6

beta/.env.production

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
NEXT_PUBLIC_HJ_SITE_ID = 2411651
2-
NEXT_PUBLIC_HJ_SITE_V = 6
1+
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'

beta/.eslintrc

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"root": true,
3-
"extends": "next",
3+
"extends": "next/core-web-vitals",
4+
"rules": {
5+
"no-unused-vars": "warn"
6+
},
47
"env": {
58
"node": true,
69
"commonjs": true,
710
"browser": true,
811
"es6": true
912
}
10-
}
13+
}

beta/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# misc
1919
.DS_Store
2020
*.pem
21+
tsconfig.tsbuildinfo
2122

2223
# debug
2324
npm-debug.log*

beta/.husky/pre-commit

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
. "$(dirname "$0")/_/husky.sh"
33

44
cd beta
5-
# yarn generate-ids
6-
# git add -u src/pages/**/*.md
7-
yarn prettier
8-
yarn lint:fix
5+
yarn lint-staged

beta/.prettierrc

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,19 @@
33
"singleQuote": true,
44
"bracketSameLine": true,
55
"trailingComma": "es5",
6-
"printWidth": 80
6+
"printWidth": 80,
7+
"overrides": [
8+
{
9+
"files": "*.css",
10+
"options": {
11+
"parser": "css"
12+
}
13+
},
14+
{
15+
"files": "*.md",
16+
"options": {
17+
"parser": "mdx"
18+
}
19+
}
20+
]
721
}

beta/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The documentation is divided into sections to cater to different learning styles
2020

2121
**[Learn React](https://beta.reactjs.org/learn)** is designed to introduce fundamental concepts in a step-by-step way. Each individual article in Learn React builds on the knowledge from the previous ones, so make sure not to add any "cyclical dependencies" between them. It is important that the reader can start with the first article and work their way to the last Learn React article without ever having to "look ahead" for a definition. This explains some ordering choices (e.g. that state is explained before events, or that "thinking in React" doesn't use refs). Learn React also serves as a reference manual for React concepts, so it is important to be very strict about their definitions and relationships between them.
2222

23-
**[API Reference](https://reactjs.org/reference)** is organized by APIs rather than concepts. It is intended to be exhaustive. Any corner cases or recommendations that were skipped for brevity in Learn React should be mentioned in the reference documentation for the corresponding APIs.
23+
**[API Reference](https://reactjs.org/apis)** is organized by APIs rather than concepts. It is intended to be exhaustive. Any corner cases or recommendations that were skipped for brevity in Learn React should be mentioned in the reference documentation for the corresponding APIs.
2424

2525
**Try to follow your own instructions.**
2626

beta/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The documentation is divided into several sections with a different tone and pur
5656
1. `git push my-fork-name the-name-of-my-branch`
5757
1. Go to the [reactjs.org repo](https://github.com/reactjs/reactjs.org) and you should see recently pushed branches.
5858
1. Follow GitHub's instructions.
59-
1. If possible, include screenshots of visual changes. A [Netlify](https://www.netlify.com/) build will also be automatically created once you make your PR so other people can see your change.
59+
1. If possible, include screenshots of visual changes. A preview build is triggered after your changes are pushed to GitHub.
6060

6161
## Translation
6262

beta/next-env.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference types="next" />
2-
/// <reference types="next/types/global" />
32
/// <reference types="next/image-types/global" />
43

54
// NOTE: This file should not be edited

beta/next.config.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@ module.exports = {
1111
experimental: {
1212
plugins: true,
1313
// TODO: this doesn't work because https://github.com/vercel/next.js/issues/30714
14-
// concurrentFeatures: true,
14+
concurrentFeatures: false,
1515
scrollRestoration: true,
1616
},
1717
async redirects() {
1818
return redirects.redirects;
1919
},
20-
env: {
21-
// @todo Remove when https://github.com/vercel/next.js/pull/16529 lands
22-
GA_TRACKING_ID: 'XXXX',
23-
NEXT_PUBLIC_GA_TRACKING_ID: 'XXX',
24-
},
2520
rewrites() {
2621
return [
2722
{
@@ -32,7 +27,7 @@ module.exports = {
3227
},
3328
webpack: (config, {dev, isServer, ...options}) => {
3429
if (process.env.ANALYZE) {
35-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
30+
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
3631
config.plugins.push(
3732
new BundleAnalyzerPlugin({
3833
analyzerMode: 'static',

beta/package.json

+21-15
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,38 @@
66
"scripts": {
77
"analyze": "ANALYZE=true next build",
88
"dev": "next",
9-
"build": "next build && node ./scripts/generateRSS.js",
9+
"build": "next build && node ./scripts/generateRSS.js && node ./scripts/generateRedirects.js",
1010
"lint": "next lint",
1111
"lint:fix": "next lint --fix",
12-
"format:source": "prettier --config .prettierrc --write \"{plugins,src}/**/*.{js,ts,jsx,tsx}\"",
13-
"nit:source": "prettier --config .prettierrc --list-different \"{plugins,src}/**/*.{js,ts,jsx,tsx}\"",
12+
"format:source": "prettier --config .prettierrc --write \"{plugins,src}/**/*.{js,ts,jsx,tsx,css}\"",
13+
"nit:source": "prettier --config .prettierrc --list-different \"{plugins,src}/**/*.{js,ts,jsx,tsx,css}\"",
1414
"prettier": "yarn format:source",
1515
"prettier:diff": "yarn nit:source",
16-
"generate-ids": "node scripts/generateHeadingIDs.js src/pages/",
17-
"ci-check": "npm-run-all prettier:diff --parallel lint tsc",
16+
"lint-heading-ids": "node scripts/headingIdLinter.js",
17+
"fix-headings": "node scripts/headingIdLinter.js --fix",
18+
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids",
1819
"tsc": "tsc --noEmit",
1920
"start": "next start",
20-
"postinstall": "is-ci || (cd .. && husky install beta/.husky)",
21+
"postinstall": "patch-package && (is-ci || (cd .. && husky install beta/.husky))",
2122
"check-all": "npm-run-all prettier lint:fix tsc"
2223
},
2324
"dependencies": {
24-
"@codesandbox/sandpack-react": "^0.1.20",
25+
"@codesandbox/sandpack-react": "v0.14.3-experimental.1",
2526
"@docsearch/css": "3.0.0-alpha.41",
2627
"@docsearch/react": "3.0.0-alpha.41",
2728
"@headlessui/react": "^1.3.0",
2829
"@mdx-js/react": "^1.6.16",
29-
"@next/plugin-google-analytics": "^10.0.6",
3030
"body-scroll-lock": "^3.1.3",
3131
"classnames": "^2.2.6",
3232
"date-fns": "^2.16.1",
3333
"debounce": "^1.2.1",
34+
"ga-lite": "^2.1.4",
3435
"github-slugger": "^1.3.0",
35-
"next": "^12.0.3-canary.2",
36+
"next": "^12.0.10",
3637
"parse-numeric-range": "^1.2.0",
37-
"react": "18.0.0-alpha-930c9e7ee-20211015",
38+
"react": "experimental",
3839
"react-collapsed": "3.1.0",
39-
"react-dom": "18.0.0-alpha-930c9e7ee-20211015",
40+
"react-dom": "experimental",
4041
"scroll-into-view-if-needed": "^2.2.25"
4142
},
4243
"devDependencies": {
@@ -52,7 +53,7 @@
5253
"@typescript-eslint/eslint-plugin": "2.x",
5354
"@typescript-eslint/parser": "2.x",
5455
"asyncro": "^3.0.0",
55-
"autoprefixer": "^10.3.1",
56+
"autoprefixer": "^10.4.2",
5657
"babel-eslint": "10.x",
5758
"eslint": "7.x",
5859
"eslint-config-next": "12.0.3",
@@ -67,13 +68,14 @@
6768
"gray-matter": "^4.0.2",
6869
"husky": "^7.0.4",
6970
"is-ci": "^3.0.1",
71+
"lint-staged": ">=10",
7072
"mdast-util-to-string": "^1.1.0",
7173
"npm-run-all": "^4.1.5",
7274
"patch-package": "^6.2.2",
73-
"postcss": "^8.3.6",
75+
"postcss": "^8.4.5",
7476
"postcss-flexbugs-fixes": "4.2.1",
7577
"postcss-preset-env": "^6.7.0",
76-
"prettier": "^2.1.1",
78+
"prettier": "^2.5.1",
7779
"reading-time": "^1.2.0",
7880
"remark": "^12.0.1",
7981
"remark-external-links": "^7.0.0",
@@ -84,7 +86,7 @@
8486
"retext": "^7.0.1",
8587
"retext-smartypants": "^4.0.0",
8688
"rss": "^1.2.2",
87-
"tailwindcss": "^2.2.7",
89+
"tailwindcss": "^3.0.22",
8890
"typescript": "^4.0.2",
8991
"unist-util-visit": "^2.0.3",
9092
"webpack-bundle-analyzer": "^4.5.0"
@@ -96,5 +98,9 @@
9698
"budget": null,
9799
"budgetPercentIncreaseRed": 10,
98100
"showDetails": true
101+
},
102+
"lint-staged": {
103+
"*.{js,ts,jsx,tsx,css}": "yarn prettier",
104+
"src/**/*.md": "yarn fix-headings"
99105
}
100106
}

beta/patches/@next+plugin-google-analytics+9.5.2.patch

-35
This file was deleted.

beta/plugins/md-layout-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = async function (src) {
2323
const layoutMap = {
2424
blog: 'Post',
2525
learn: 'Learn',
26-
reference: 'API',
26+
apis: 'API',
2727
};
2828
const layout = layoutMap[pageParentDir] || 'Home';
2929
const code =

beta/plugins/remark-header-custom-ids.js

+18-24
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,26 @@ module.exports = ({
3232
visit(tree, 'heading', (node) => {
3333
const children = node.children;
3434
let tail = children[children.length - 1];
35-
36-
// A bit weird: this is to support MDX 2 comments in expressions,
37-
// while we’re still on MDX 1, which doesn’t support them.
38-
if (!tail || tail.type !== 'text' || tail.value !== '/}') {
39-
return;
35+
// Generate slugs on the fly (even if not specified in markdown)
36+
// so that it's possible to copy anchor links in newly written content.
37+
let id = slugs.slug(toString(node), maintainCase);
38+
// However, for committed docs, we'll extract slug from the headers.
39+
if (tail && tail.type === 'text' && tail.value === '/}') {
40+
tail = children[children.length - 2];
41+
if (tail && tail.type === 'emphasis') {
42+
// Use custom ID instead.
43+
id = toString(tail);
44+
// Until we're on MDX 2, we need to "cut off" the comment syntax.
45+
tail = children[children.length - 3];
46+
if (tail && tail.type === 'text' && tail.value.endsWith('{/')) {
47+
// Remove the emphasis and trailing `/}`
48+
children.splice(children.length - 2, 2);
49+
// Remove the `{/`
50+
tail.value = tail.value.replace(/[ \t]*\{\/$/, '');
51+
}
52+
}
4053
}
4154

42-
tail = children[children.length - 2];
43-
44-
if (!tail && tail.type !== 'emphasis') {
45-
return;
46-
}
47-
48-
const id = toString(tail);
49-
50-
tail = children[children.length - 3];
51-
52-
if (!tail || tail.type !== 'text' || !tail.value.endsWith('{/')) {
53-
return;
54-
}
55-
56-
// Remove the emphasis and trailing `/}`
57-
children.splice(children.length - 2, 2);
58-
// Remove the `{/`
59-
tail.value = tail.value.replace(/[ \t]*\{\/$/, '');
60-
6155
const data = patch(node, 'data', {});
6256

6357
patch(data, 'id', id);
9.65 KB
Binary file not shown.
-188 KB
Binary file not shown.

0 commit comments

Comments
 (0)