forked from shuding/nextra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
section for code highlighting languages
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
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,26 @@ | ||
# Code Highlighting | ||
|
||
`nextra-theme-docs` uses [Prism](https://prismjs.com) and [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer) | ||
to highlight the code blocks. This section covers how you can customze it. | ||
|
||
## More Languages | ||
|
||
To keep the bundle small, only a [subset of languages](https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js) | ||
are included in the syntax highlighter. If you want to add more languages, you can do the following: | ||
|
||
1. Run `yarn add prismjs prism-react-renderer` to add dependencies to your Nextra project. | ||
2. Add the following code to your `pages/_app.js`: | ||
|
||
```jsx | ||
import Prism from 'prism-react-renderer/prism' | ||
|
||
(typeof global !== "undefined" ? global : window).Prism = Prism | ||
|
||
require("prismjs/components/prism-kotlin") | ||
require("prismjs/components/prism-csharp") | ||
``` | ||
|
||
Restart your app and you will have Kotlin and C# code highlighting supported. | ||
You can find the full list of available languages [here](https://github.com/PrismJS/prism/tree/master/components). | ||
|
||
{/*## Custom Themes*/} |
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,3 @@ | ||
{ | ||
"code-highlighting": "Code Highlighting" | ||
} |
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