mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 02:37:59 +02:00
docs: add mdx-code-block around tabs; use JS example for magic comments (#7307)
This commit is contained in:
parent
0466dbcf3f
commit
977ef7121b
1 changed files with 14 additions and 14 deletions
|
@ -282,6 +282,7 @@ Below, we will introduce how the magic comment system can be extended to define
|
||||||
|
|
||||||
You can declare custom magic comments through theme config. For example, you can register another magic comment that adds a `code-block-error-line` class name:
|
You can declare custom magic comments through theme config. For example, you can register another magic comment that adds a `code-block-error-line` class name:
|
||||||
|
|
||||||
|
`````mdx-code-block
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value="docusaurus.config.js">
|
<TabItem value="docusaurus.config.js">
|
||||||
|
|
||||||
|
@ -325,32 +326,31 @@ module.exports = {
|
||||||
<TabItem value="myDoc.md">
|
<TabItem value="myDoc.md">
|
||||||
|
|
||||||
````md
|
````md
|
||||||
In TypeScript, types help prevent runtime errors.
|
In JavaScript, trying to access properties on `null` will error.
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
function greet(name: string) {
|
const name = null;
|
||||||
// This will error
|
// This will error
|
||||||
console.log(name.toUpper());
|
console.log(name.toUpperCase());
|
||||||
// .toUpper doesn't exist on string
|
// Uncaught TypeError: Cannot read properties of null (reading 'toUpperCase')
|
||||||
}
|
|
||||||
```
|
```
|
||||||
````
|
````
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
`````
|
||||||
|
|
||||||
````mdx-code-block
|
````mdx-code-block
|
||||||
<BrowserWindow>
|
<BrowserWindow>
|
||||||
|
|
||||||
In TypeScript, types help prevent runtime errors.
|
In JavaScript, trying to access properties on `null` will error.
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
function greet(name: string) {
|
const name = null;
|
||||||
// This will error
|
// This will error
|
||||||
console.log(name.toUpper());
|
console.log(name.toUpperCase());
|
||||||
// .toUpper doesn't exist on string
|
// Uncaught TypeError: Cannot read properties of null (reading 'toUpperCase')
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</BrowserWindow>
|
</BrowserWindow>
|
||||||
|
|
Loading…
Add table
Reference in a new issue