From 1260d4666fcc7a72cb6d15646775bb608e1b74fb Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 19 Oct 2022 19:00:21 +0200 Subject: [PATCH 1/2] [beta] Ensure compat of Prettier and remark-header-custom-ids --- beta/plugins/remark-header-custom-ids.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beta/plugins/remark-header-custom-ids.js b/beta/plugins/remark-header-custom-ids.js index 356de1bf136..55a10911ed9 100644 --- a/beta/plugins/remark-header-custom-ids.js +++ b/beta/plugins/remark-header-custom-ids.js @@ -39,7 +39,7 @@ module.exports = ({icon = svgIcon, className = `anchor`} = {}) => { id ); } - id = id.slice(2, id.length - 2); + id = id.slice(2, id.length - 2).trim(); if (id !== toSlug(id)) { throw Error( 'Expected header ID to be a valid slug. You specified: {/*' + From 4d65abaf783793fe036ba1957be22ae45b161f3c Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 19 Oct 2022 19:06:06 +0200 Subject: [PATCH 2/2] Example --- .../content/learn/add-react-to-a-website.md | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/beta/src/content/learn/add-react-to-a-website.md b/beta/src/content/learn/add-react-to-a-website.md index dc313e1718c..bd1e2f95589 100644 --- a/beta/src/content/learn/add-react-to-a-website.md +++ b/beta/src/content/learn/add-react-to-a-website.md @@ -10,19 +10,19 @@ You don't have to build your whole website with React. Adding React to HTML does -* How to add React to an HTML page in one minute -* What is the JSX syntax and how to quickly try it -* How to set up a JSX preprocessor for production +- How to add React to an HTML page in one minute +- What is the JSX syntax and how to quickly try it +- How to set up a JSX preprocessor for production -## Add React in one minute {/*add-react-in-one-minute*/} +## Add React in one minute {/* add-react-in-one-minute */} React has been designed from the start for gradual adoption. Most websites aren't (and don't need to be) fully built with React. This guide shows how to add some “sprinkles of interactivity” to an existing HTML page. Try this out with your own website or [an empty HTML file.](https://gist.github.com/gaearon/edf814aeee85062bc9b9830aeaf27b88/archive/3b31c3cdcea7dfcfd38a81905a0052dd8e5f71ec.zip) All you need is an internet connection and a text editor like Notepad or VSCode. (Here's [how to configure your editor](/learn/editor-setup/) for syntax highlighting!) -### Step 1: Add a root HTML tag {/*step-1-add-a-root-html-tag*/} +### Step 1: Add a root HTML tag {/* step-1-add-a-root-html-tag */} First, open the HTML page you want to edit. Add an empty `
` tag to mark the spot where you want to display something with React. Give this `
` a unique `id` attribute value. For example: @@ -38,7 +38,7 @@ It's called a "root" because it's where the React tree will start. You can place You may have as many root HTML tags as you need on one page. -### Step 2: Add the script tags {/*step-2-add-the-script-tags*/} +### Step 2: Add the script tags {/* step-2-add-the-script-tags */} In the HTML page, right before the closing `` tag, add three ` - + + ``` -## Try React with JSX {/*try-react-with-jsx*/} +## Try React with JSX {/* try-react-with-jsx */} 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: @@ -147,7 +151,7 @@ These two code snippets are equivalent. JSX is popular syntax for describing mar > 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.17) -### Try JSX {/*try-jsx*/} +### Try JSX {/* try-jsx */} The quickest way to try JSX is to add the Babel compiler as a `