-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: upgrade deps 作者: Jellli <[email protected]> * feat: add twoslash transformer * feat: update plugins to fit rehype-pretty-code's updates * fix: prevent the crash from not receiving the style prop * feat: handle when classname is a array * feat: fix darkmode support * feat: update snapshot * docs: add twoslash support document * update * prettier * prettier * more * more * more * more * aa * Update .changeset/rich-apricots-bake.md --------- Co-authored-by: Dimitri POSTOLOV <[email protected]> Co-authored-by: Dimitri POSTOLOV <[email protected]>
- Loading branch information
1 parent
9f55bd1
commit 3043826
Showing
7 changed files
with
379 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'nextra-theme-blog': minor | ||
'nextra-theme-docs': minor | ||
'nextra': minor | ||
--- | ||
|
||
add shikiji twoslash | ||
|
||
Demo feature: https://nextra-v2-na3obnhub-shuding1.vercel.app/docs/guide/twoslash-support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Twoslash Support | ||
|
||
Twoslash provides an inline type hove inside the code block. | ||
|
||
## Basic usage | ||
|
||
You can enable twoslash to your code blocks by adding a `twoslash` metadata: | ||
|
||
````md copy=false filename="Markdown" | ||
```ts twoslash | ||
// @errors: 2540 | ||
interface Todo { | ||
title: string | ||
} | ||
|
||
const todo: Readonly<Todo> = { | ||
title: 'Delete inactive users'.toUpperCase() | ||
// ^? | ||
} | ||
|
||
todo.title = 'Hello' | ||
|
||
Number.parseInt('123', 10) | ||
// ^| | ||
``` | ||
```` | ||
|
||
Renders: | ||
|
||
```ts twoslash | ||
// @errors: 2540 | ||
interface Todo { | ||
title: string | ||
} | ||
|
||
const todo: Readonly<Todo> = { | ||
title: 'Delete inactive users'.toUpperCase() | ||
// ^? | ||
} | ||
|
||
todo.title = 'Hello' | ||
|
||
Number.parseInt('123', 10) | ||
// ^| | ||
``` | ||
|
||
## Custom log message | ||
|
||
You can add log message to your code by adding: | ||
|
||
- `@log: <message>` Custom log message | ||
- `@error: <message>` Custom error message | ||
- `@warn: <message>` Custom warn message | ||
- `@annotate: <message>` Custom annotate message | ||
|
||
```ts twoslash | ||
// @log: Custom log message | ||
const a = 1 | ||
// @error: Custom error message | ||
const b = 1 | ||
// @warn: Custom warning message | ||
const c = 1 | ||
// @annotate: Custom annotation message | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.