-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): prepare for release v1.3.0
- Loading branch information
Showing
7 changed files
with
208 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,85 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Examples | ||
|
||
The documentation for this library is a working example. | ||
|
||
This file, for example, has a diagram using the component and code block. | ||
|
||
## Component | ||
|
||
```jsx title="Component example" | ||
import { Mermaid } from 'mdx-mermaid/Mermaid' | ||
|
||
<Mermaid chart={`sequenceDiagram | ||
participant Alice | ||
participant Bob | ||
Alice->>John: Hello John, how are you? | ||
loop Healthcheck | ||
John->>John: Fight against hypochondria | ||
end | ||
Note right of John: Rational thoughts <br/>prevail! | ||
John-->>Alice: Great! | ||
John->>Bob: How about you? | ||
Bob-->>John: Jolly good!`} /> | ||
``` | ||
|
||
<Mermaid chart={`sequenceDiagram | ||
participant Alice | ||
participant Bob | ||
Alice->>John: Hello John, how are you? | ||
loop Healthcheck | ||
John->>John: Fight against hypochondria | ||
end | ||
Note right of John: Rational thoughts <br/>prevail! | ||
John-->>Alice: Great! | ||
John->>Bob: How about you? | ||
Bob-->>John: Jolly good!`} /> | ||
|
||
## Code block | ||
|
||
The component doesn't need to be imported as this will be auto inserted. | ||
|
||
````md title="Code block example" | ||
```mermaid | ||
gantt | ||
dateFormat YYYY-MM-DD | ||
title Adding GANTT diagram to mermaid | ||
excludes weekdays 2014-01-10 | ||
|
||
section A section | ||
Completed task :done, des1, 2014-01-06,2014-01-08 | ||
Active task :active, des2, 2014-01-09, 3d | ||
Future task : des3, after des2, 5d | ||
Future task2 : des4, after des3, 5d | ||
``` | ||
```` | ||
|
||
```mermaid | ||
gantt | ||
dateFormat YYYY-MM-DD | ||
title Adding GANTT diagram to mermaid | ||
excludes weekdays 2014-01-10 | ||
section A section | ||
Completed task :done, des1, 2014-01-06,2014-01-08 | ||
Active task :active, des2, 2014-01-09, 3d | ||
Future task : des3, after des2, 5d | ||
Future task2 : des4, after des3, 5d | ||
``` | ||
|
||
## Mermaid Config | ||
|
||
Mermaid config can be configured through the plugin config: | ||
|
||
```js title=docusaurus.config.js | ||
remarkPlugins: [[await import('mdx-mermaid').default, { mermaid: { theme: 'dark' } }]], | ||
``` | ||
|
||
:::caution | ||
|
||
When passing config to the `<Mermaid>` component only the first instance should have the config passed to it. | ||
If no config is passed to any component then Mermaid will not initialize. | ||
This is not an issue when using in `.mdx` files as the parser will handle this. |
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,75 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Tutorial | ||
|
||
Setup mdx-mermaid in Docusaurus. | ||
|
||
## Installing | ||
|
||
Use your preferred package manager to install. | ||
|
||
```shell title=NPM | ||
npm i mdx-mermaid@^1.3.0 mermaid | ||
``` | ||
|
||
```shell title=Yarn | ||
yarn add mdx-mermaid@^1.3.0 mermaid | ||
``` | ||
|
||
```shell title=PNPM | ||
pnpm add mdx-mermaid@^1.3.0 mermaid | ||
``` | ||
|
||
## Configure in Docusaurus | ||
|
||
Import the module and pass it to `remarkPlugins`: | ||
|
||
```js title=docusaurus.config.js | ||
|
||
async function createConfig() { | ||
const mdxMermaid = await import('mdx-mermaid') | ||
|
||
return { | ||
presets: [ | ||
[ | ||
'classic', | ||
{ | ||
docs: { | ||
remarkPlugins: [mdxMermaid.default], | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
|
||
module.exports = createConfig; | ||
``` | ||
|
||
## Add a Diagram | ||
|
||
Add a Mermaid diagram to a `.md` or `.mdx` file. | ||
|
||
````md title="Example Mermaid diagram" | ||
```mermaid | ||
graph TD; | ||
A-->B; | ||
A-->C; | ||
B-->D; | ||
C-->D; | ||
``` | ||
```` | ||
|
||
## Admire your diagram | ||
|
||
Take the time to appreciate your diagram. | ||
|
||
```mermaid | ||
graph TD; | ||
A-->B; | ||
A-->C; | ||
B-->D; | ||
C-->D; | ||
``` |
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,11 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Supported Mermaid versions | ||
|
||
This library supports Mermaid versions `>= 8.11.0` | ||
|
||
The version needs to be at least `8.11.0` due to this issue: https://github.com/sjwall/mdx-mermaid/issues/20 | ||
|
||
To use Mermaid versions `>=8.12.0` ESM must be used, due to the `d3` version upgrade to modules https://github.com/mermaid-js/mermaid/issues/2559 |
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,27 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Theme | ||
|
||
The theme can be changed between dark and light themes by setting `theme` values in the configuration: | ||
|
||
```js title=docusaurus.config.js | ||
remarkPlugins: [[await import('mdx-mermaid'), { | ||
theme: { light: 'neutral', dark: 'forest' } | ||
}]], | ||
``` | ||
|
||
Toggle the theme in the top right corner to change this diagrams theme between `neutral` and `forest`: | ||
|
||
<Mermaid chart={`sequenceDiagram | ||
participant Alice | ||
participant Bob | ||
Alice->>John: Hello John, how are you? | ||
loop Healthcheck | ||
John->>John: Fight against hypochondria | ||
end | ||
Note right of John: Rational thoughts <br/>prevail! | ||
John-->>Alice: Great! | ||
John->>Bob: How about you? | ||
Bob-->>John: Jolly good!`} config={ { theme: { light: 'neutral', dark: 'forest' } } } /> |
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,8 @@ | ||
{ | ||
"tutorialSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "." | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[ | ||
"1.3.0", | ||
"1.2.3" | ||
] |
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