mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 10:17:55 +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:
|
||||
|
||||
`````mdx-code-block
|
||||
<Tabs>
|
||||
<TabItem value="docusaurus.config.js">
|
||||
|
||||
|
@ -325,32 +326,31 @@ module.exports = {
|
|||
<TabItem value="myDoc.md">
|
||||
|
||||
````md
|
||||
In TypeScript, types help prevent runtime errors.
|
||||
In JavaScript, trying to access properties on `null` will error.
|
||||
|
||||
```ts
|
||||
function greet(name: string) {
|
||||
// This will error
|
||||
console.log(name.toUpper());
|
||||
// .toUpper doesn't exist on string
|
||||
}
|
||||
```js
|
||||
const name = null;
|
||||
// This will error
|
||||
console.log(name.toUpperCase());
|
||||
// Uncaught TypeError: Cannot read properties of null (reading 'toUpperCase')
|
||||
```
|
||||
````
|
||||
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
`````
|
||||
|
||||
````mdx-code-block
|
||||
<BrowserWindow>
|
||||
|
||||
In TypeScript, types help prevent runtime errors.
|
||||
In JavaScript, trying to access properties on `null` will error.
|
||||
|
||||
```ts
|
||||
function greet(name: string) {
|
||||
// This will error
|
||||
console.log(name.toUpper());
|
||||
// .toUpper doesn't exist on string
|
||||
}
|
||||
```js
|
||||
const name = null;
|
||||
// This will error
|
||||
console.log(name.toUpperCase());
|
||||
// Uncaught TypeError: Cannot read properties of null (reading 'toUpperCase')
|
||||
```
|
||||
|
||||
</BrowserWindow>
|
||||
|
|
Loading…
Add table
Reference in a new issue