-
-
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.
- Loading branch information
Showing
21 changed files
with
3,830 additions
and
3,729 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
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
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
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: [[require('mdx-mermaid'), { 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. |
Oops, something went wrong.