Skip to content

Commit 0b7fd7b

Browse files
authored
Add git hook to generate headings ids (#4043)
* Add git hook to generate headings ids * Fixes "Analyze Bundle" workflow
1 parent 8333b6d commit 0b7fd7b

Some content is hidden

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

45 files changed

+361
-335
lines changed

beta/.husky/pre-commit

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
cd beta
5+
yarn generate-ids
6+
git add -u src/pages/**/*.md

beta/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
"nit:source": "prettier --config .prettierrc --list-different \"{plugins,src}/**/*.{js,ts,jsx,tsx}\"",
1313
"prettier": "yarn format:source",
1414
"prettier:diff": "yarn nit:source",
15-
"generate-ids": "node scripts/generateHeadingIDs.js src/pages/docs && node scripts/generateHeadingIDs.js src/pages/blog",
15+
"generate-ids": "node scripts/generateHeadingIDs.js src/pages/",
1616
"ci-check": "npm-run-all prettier:diff --parallel lint tsc",
1717
"tsc": "tsc --noEmit",
18-
"start": "next start"
18+
"start": "next start",
19+
"postinstall": "is-ci || (cd .. && husky install beta/.husky)"
1920
},
2021
"dependencies": {
2122
"@codesandbox/sandpack-react": "^0.1.20",
@@ -66,6 +67,8 @@
6667
"fs-extra": "^9.0.1",
6768
"globby": "^11.0.1",
6869
"gray-matter": "^4.0.2",
70+
"husky": "^7.0.4",
71+
"is-ci": "^3.0.1",
6972
"mdast-util-to-string": "^1.1.0",
7073
"npm-run-all": "^4.1.5",
7174
"patch-package": "^6.2.2",

beta/src/pages/community/acknowledgements.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Acknowledgements
33
layout: Home
44
---
55

6-
## React
6+
## React {#react}
77

88
React was originally created by [Jordan Walke](https://github.com/jordwalke). Today, React has a [dedicated full-time team working on it](/community/team.html), as well as over a thousand [open source contributors](https://github.com/facebook/react/blob/main/AUTHORS). We'd like to recognize a few people who have made significant contributions to React and its documentation in the past and have helped maintain them over the years:
99

@@ -46,21 +46,21 @@ This list is not exhaustive.
4646

4747
We'd like to give special thanks to [Tom Occhino](https://github.com/tomocchino) and [Adam Wolff](https://github.com/wolffiex) for their guidance and support over the years. We are also thankful to all the volunteers who [translated React into other languages](https://translations.reactjs.org/).
4848

49-
## React Docs
49+
## React Docs {#react-docs}
5050

51-
### Documentation
51+
### Documentation {#documentation}
5252

5353
* [Rachel Nabors](https://twitter.com/RachelNabors): editing, writing, illustrating
5454
* [Dan Abramov](https://twitter.com/dan_abramov): writing, curriculum design
5555
* [Sylwia Vargas](https://twitter.com/SylwiaVargas): example code
5656

57-
### Design
57+
### Design {#design}
5858

5959
* [Dan Lebowitz](https://twitter.com/lebo): design
6060
* [Razvan Gradinar](https://dribbble.com/GradinarRazvan): design
6161
* [Maggie Appleton](https://maggieappleton.com/): diagram system
6262

63-
### Development
63+
### Development {#development}
6464

6565
* [Jared Palmer](https://twitter.com/jaredpalmer): site development
6666
* [ThisDotLabs](https://www.thisdot.co/) ([Dane Grant](https://twitter.com/danecando), [Dustin Goodman](https://twitter.com/dustinsgoodman)): site development
@@ -69,7 +69,7 @@ We'd like to give special thanks to [Tom Occhino](https://github.com/tomocchino)
6969

7070
We'd also like to thank countless alpha testers and community members who gave us feedback along the way.
7171

72-
## Additional Thanks
72+
## Additional Thanks {#additional-thanks}
7373

7474
Additionally, we're grateful to:
7575

beta/src/pages/community/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ React has a community of millions of developers. On this page we've listed some
99

1010
</Intro>
1111

12-
## Code of Conduct
12+
## Code of Conduct {#code-of-conduct}
1313

1414
Before participating in React's communities, [please read our Code of Conduct](https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md). We have adopted the [Contributor Covenant](https://www.contributor-covenant.org/) and we expect that all community members adhere to the guidelines within.
1515

16-
## Stack Overflow
16+
## Stack Overflow {#stack-overflow}
1717

1818
Stack Overflow is a popular forum to ask code-level questions or if you're stuck with a specific error. Read through the [existing questions](https://stackoverflow.com/questions/tagged/reactjs) tagged with **reactjs** or [ask your own](https://stackoverflow.com/questions/ask?tags=reactjs)!
1919

2020
<!--
2121
2222
TODO: decide on the criteria for inclusion before uncommenting.
2323
24-
## Popular Discussion Forums
24+
## Popular Discussion Forums {#popular-discussion-forums}
2525
2626
There are many online forums which are a great place for discussion about best practices and application architecture as well as the future of React. If you have an answerable code-level question, Stack Overflow is usually a better fit.
2727
@@ -34,6 +34,6 @@ Each community consists of many thousands of React users.
3434
3535
-->
3636

37-
## News
37+
## News {#news}
3838

3939
For the latest news about React, [follow **@reactjs** on Twitter](https://twitter.com/reactjs) and the [official React blog](/blog/) on this website.

beta/src/pages/community/meet-the-team.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,85 @@ React development is led by a small dedicated team working full time at Facebook
88

99
</Intro>
1010

11-
## React Core
11+
## React Core {#react-core}
1212

1313
The React Core team members work full time on the core component APIs, the engine that powers React DOM and React Native, React DevTools, and the React documentation website.
1414

1515
Current members of the React team are listed in alphabetical order below.
1616

17-
### Andrew Clark
17+
### Andrew Clark {#andrew-clark}
1818

1919
![Andrew Clark](../images/team/acdlite.jpg)
2020

2121
[@acdlite on GitHub](https://github.com/acdlite) &middot; [@acdlite on Twitter](https://twitter.com/acdlite)
2222

2323
Andrew got started with web development by making sites with WordPress, and eventually tricked himself into doing JavaScript. His favorite pastime is karaoke. Andrew is either a Disney villain or a Disney princess, depending on the day.
2424

25-
### Brian Vaughn
25+
### Brian Vaughn {#brian-vaughn}
2626

2727
![Brian Vaughn](../images/team/bvaughn.jpg)
2828

2929
[@bvaughn on GitHub](https://github.com/bvaughn) &middot; [@brian\_d\_vaughn on Twitter](https://twitter.com/brian_d_vaughn)
3030

3131
Brian studied art in college and did programming on the side to pay for his education. Eventually, he realized that he enjoys working on open source. Brian has one [one-person band](https://soundcloud.com/brianvaughn/) and two [two-person](https://soundcloud.com/pilotlessdrone) [bands](https://soundcloud.com/pinwurm). He also takes care of the cutest cat in the world.
3232

33-
### Dan Abramov
33+
### Dan Abramov {#dan-abramov}
3434

3535
![Dan Abramov](../images/team/gaearon.jpg)
3636

3737
[@gaearon on GitHub](https://github.com/gaearon) &middot; [@dan_abramov on Twitter](https://twitter.com/dan_abramov)
3838

3939
Dan got into programming after he accidentally discovered Visual Basic inside Microsoft PowerPoint. He has found his true calling in turning [Sebastian](#sebastian-markbåge)'s tweets into long-form blog posts. Dan occasionally wins at Fortnite by hiding in a bush until the game ends.
4040

41-
### Luna Ruan
41+
### Luna Ruan {#luna-ruan}
4242

4343
![Luna](../images/team/lunaruan.jpg)
4444

4545
[@lunaruan on GitHub](https://github.com/lunaruan) &middot; [@lunaruan on Twitter](https://twitter.com/lunaruan)
4646

4747
Luna learned programming because she thought it meant creating video games. Instead, she ended up working on the Pinterest web app, and now on React itself. Luna doesn't want to make video games anymore, but she plans to do creative writing if she ever gets bored.
4848

49-
### Marco Salazar
49+
### Marco Salazar {#marco-salazar}
5050

5151
![Marco](../images/team/salazarm.jpeg)
5252

5353
[@salazarm on GitHub](https://github.com/salazarm) &middot; [@BkOptimism on Twitter](https://twitter.com/BkOptimism)
5454

5555
Marco's first programming language was Assembly because he could use it to hack video games. Now online games are much more secure so he settles for playing fairly (mostly). In his spare time he plays games on his treadmill desk and makes art that he never finishes. Hopefully his PRs don't have the same fate.
5656

57-
### Rachel Nabors
57+
### Rachel Nabors {#rachel-nabors}
5858

5959
![Rachel](../images/team/rnabors.jpg)
6060

6161
[@rachelnabors on GitHub](https://github.com/rachelnabors) &middot; [@rachelnabors on Twitter](https://twitter.com/rachelnabors)
6262

6363
Rachel wrote a [book about UI animation](https://abookapart.com/products/animation-at-work) once and worked with MDN and the W3C on the web animations API. Now she is busy with education materials and community engineering on the React team. Secretly, she is an award-winning cartoonist for teenage girls. Catch her making fancy tea with lukewarm water in the microkitchen.
6464

65-
### Rick Hanlon
65+
### Rick Hanlon {#rick-hanlon}
6666

6767
![Ricky](../images/team/rickhanlonii.jpg)
6868

6969
[@rickhanlonii on GitHub](https://github.com/rickhanlonii) &middot; [@rickhanlonii on Twitter](https://twitter.com/rickhanlonii)
7070

7171
Ricky majored in theoretical math and somehow found himself on the React Native team for a couple years before joining the React team. When he's not programming you can find him snowboarding, biking, climbing, golfing, or closing GitHub issues that do not match the issue template.
7272

73-
### Sebastian Markbåge
73+
### Sebastian Markbåge {#sebastian-markbåge}
7474

7575
![Sebastian](../images/team/sebmarkbage.jpg)
7676

7777
[@sebmarkbage on GitHub](https://github.com/sebmarkbage) &middot; [@sebmarkbage on Twitter](https://twitter.com/sebmarkbage)
7878

7979
Sebastian majored in psychology. He's usually quiet. Even when he says something, it often doesn't make sense to the rest of us until a few months later. The correct way to pronounce his surname is "mark-boa-geh" but he settled for "mark-beige" out of pragmatism -- and that's how he approaches React.
8080

81-
### Seth Webster
81+
### Seth Webster {#seth-webster}
8282

8383
![Seth](../images/team/sethwebster.jpg)
8484

8585
[@sethwebster on GitHub](https://github.com/sethwebster) &middot; [@sethwebster on Twitter](https://twitter.com/sethwebster)
8686

8787
Seth started programming as a kid growing up in Tucson, AZ. After school, he was bitten by the music bug and was a touring musician for about 10 years before returning to *work*, starting with Intuit. In his spare time, he loves [taking pictures](https://www.sethwebster.com) and flying for animal rescues in the northeastern United States.
8888

89-
## Past contributors
89+
## Past contributors {#past-contributors}
9090

9191
You can find the past team members and other people who significantly contributed to React over the years on the [acknowledgements](/community/acknowledgements) page.
9292

beta/src/pages/index.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permalink: index.html
77

88
<HomepageHero />
99

10-
## What is this site?
10+
## What is this site? {#what-is-this-site}
1111

1212
We are rewriting the React documentation with a few differences:
1313

@@ -17,21 +17,21 @@ We are rewriting the React documentation with a few differences:
1717

1818
This beta website contains the current draft of the new docs.
1919

20-
## This is a work in progress!
20+
## This is a work in progress! {#this-is-a-work-in-progress}
2121

2222
This is a **beta website**. There will be bugs, performance issues, and missing content.
2323

24-
## How much content is ready?
24+
## How much content is ready? {#how-much-content-is-ready}
2525

2626
* [Learn React](/learn): ~70% finished.
2727
* [API Reference](/reference): ~5% finished.
2828

2929
You can track our progress [on GitHub](https://github.com/reactjs/reactjs.org/issues/3308).
3030

31-
## How can I provide feedback?
31+
## How can I provide feedback? {#how-can-i-provide-feedback}
3232

3333
Please use [this GitHub issue](https://github.com/reactjs/reactjs.org/issues/3308) or [this anonymous form](https://www.surveymonkey.co.uk/r/Y6GH986) for high-level feedback. Additionally, each page has a Feedback button in the corner. If you spot something that doesn't make sense, please tell us!
3434

35-
## Will this site replace the main site?
35+
## Will this site replace the main site? {#will-this-site-replace-the-main-site}
3636

3737
We aim to switch this site to be the main one once we reach content parity with the [existing React documentation](https://reactjs.org/). The old React website will be archived at a subdomain so you'll still be able to access it. Old content links will redirect to the archived subdomain, which will have a notice about outdated content.

beta/src/pages/learn/add-react-to-a-website.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ React has been designed from the start for gradual adoption, and you can use as
99

1010
</Intro>
1111

12-
## Add React in one minute
12+
## Add React in one minute {#add-react-in-one-minute}
1313

1414
You can add a React component to an existing HTML page in under a minute. Try this out with your own website or [an empty HTML file](https://gist.github.com/rachelnabors/7b33305bf33776354797a2e3c1445186/archive/859eac2f7079c9e1f0a6eb818a9684a464064d80.zip)—all you need is an internet connection and a text editor like Notepad (or VSCode—check out our guide on [how to set yours up](/learn/editor-setup/))!
1515

16-
### Step 1: Add an element to the HTML
16+
### Step 1: Add an element to the HTML {#step-1-add-an-element-to-the-html}
1717

1818
In the HTML page you want to edit, add an HTML element like an empty `<div>` tag with a unique `id` to mark the spot where you want to display something with React.
1919

@@ -27,7 +27,7 @@ You can place a "container" element like this `<div>` anywhere inside the `<body
2727
<!-- ... existing HTML ... -->
2828
```
2929

30-
### Step 2: Add the Script Tags
30+
### Step 2: Add the Script Tags {#step-2-add-the-script-tags}
3131

3232
In the HTML page, right before the closing `</body>` tag, add three `<script>` tags for the following files:
3333

@@ -49,7 +49,7 @@ When deploying, replace "development.js" with "production.min.js".
4949
</body>
5050
```
5151

52-
### Step 3: Create a React component
52+
### Step 3: Create a React component {#step-3-create-a-react-component}
5353

5454
Create a file called **like_button.js** next to your HTML page, add this code snippet, and save the file. This code defines a React component called `LikeButton`. [You can learn more about making components in our guides.](/learn/your-first-component)
5555

@@ -73,7 +73,7 @@ function LikeButton() {
7373
}
7474
```
7575

76-
### Step 4: Add your React Component to the page
76+
### Step 4: Add your React Component to the page {#step-4-add-your-react-component-to-the-page}
7777

7878
Lastly, add two lines to the bottom of **like_button.js**. These two lines of code find the `<div>` you added to your HTML in the first step and then display the "Like" button React component inside of it.
7979

@@ -87,7 +87,7 @@ ReactDOM.render(React.createElement(LikeButton), domContainer);
8787
- [View the full example source code](https://gist.github.com/rachelnabors/c64b3aeace8a191cf5ea6fb5202e66c9)
8888
- [Download the full example (2KB zipped)](https://gist.github.com/rachelnabors/c64b3aeace8a191cf5ea6fb5202e66c9/archive/7b41a88cb1027c9b5d8c6aff5212ecd3d0493504.zip)
8989

90-
#### You can reuse components!
90+
#### You can reuse components! {#you-can-reuse-components}
9191

9292
You might want to display a React component in multiple places on the same HTML page. This is most useful while React-powered parts of the page are isolated from each other. You can do this by calling `ReactDOM.render()` multiple times with multiple container elements.
9393

@@ -108,7 +108,7 @@ ReactDOM.render(
108108

109109
Check out [an example that displays the "Like" button three times and passes some data to it](https://gist.github.com/rachelnabors/c0ea05cc33fbe75ad9bbf78e9044d7f8)!
110110

111-
### Step 5: Minify JavaScript for production
111+
### Step 5: Minify JavaScript for production {#step-5-minify-javascript-for-production}
112112

113113
Unminified JavaScript can significantly slow down page load times for your users. Before deploying your website to production, it's a good idea to minify its scripts.
114114

@@ -120,7 +120,7 @@ Unminified JavaScript can significantly slow down page load times for your users
120120
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>
121121
```
122122

123-
## Try React with JSX
123+
## Try React with JSX {#try-react-with-jsx}
124124

125125
The examples above rely on features that are natively supported by browsers. This is why **like_button.js** uses a JavaScript function call to tell React what to display:
126126

@@ -138,7 +138,7 @@ These two code snippets are equivalent. JSX is popular syntax for describing mar
138138

139139
> You can play with transforming HTML markup into JSX using [this online converter](https://babeljs.io/en/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=DwIwrgLhD2B2AEcDCAbAlgYwNYF4DeAFAJTw4B88EAFmgM4B0tAphAMoQCGETBe86WJgBMAXJQBOYJvAC-RGWQBQ8FfAAyaQYuAB6cFDhkgA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.4.3).
140140
141-
### Try JSX
141+
### Try JSX {#try-jsx}
142142

143143
The quickest way to try JSX in your project is to add the Babel compiler to your page's `<head>` along with React and ReactDOM like so:
144144

@@ -193,7 +193,7 @@ Here is [an example HTML file with JSX](https://raw.githubusercontent.com/reactj
193193

194194
This approach is fine for learning and creating simple demos. However, it makes your website slow and **isn't suitable for production**. When you're ready to move forward, remove this new `<script>` tag and the `type="text/babel"` attributes you've added. Instead, in the next section you will set up a JSX preprocessor to convert all your `<script>` tags automatically.
195195

196-
### Add JSX to a project
196+
### Add JSX to a project {#add-jsx-to-a-project}
197197

198198
Adding JSX to a project doesn't require complicated tools like a [bundler](/learn/start-a-new-react-project#custom-toolchains) or a development server. Adding a JSX preprocessor is a lot like adding a CSS preprocessor.
199199

@@ -206,7 +206,7 @@ You only need npm to install the JSX preprocessor. You won't need it for anythin
206206

207207
Congratulations! You just added a **production-ready JSX setup** to your project.
208208

209-
### Run the JSX Preprocessor
209+
### Run the JSX Preprocessor {#run-the-jsx-preprocessor}
210210

211211
You can preprocess JSX so that every time you save a file with JSX in it, the transform will be re-run, converting the JSX file into a new, plain JavaScript file.
212212

0 commit comments

Comments
 (0)