rspress-plugin-mermaid 0.1.1 → 0.1.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# rspress-plugin-mermaid 
|
|
2
2
|
|
|
3
|
+
[简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
3
5
|
Rspress plugin to render mermaid diagrams in markdown files.
|
|
4
6
|
|
|
5
7
|
Write mermaid as code blocks in markdown files and they will be rendered as SVGs:
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# rspress-plugin-mermaid 
|
|
2
|
+
|
|
3
|
+
为 Rspress 支持基于 [Mermaid](hhttps://mermaid.js.org/#/) 的流程图、时序图等图表。
|
|
4
|
+
|
|
5
|
+
编写 Mermaid 图表时,只需使用 `mermaid` 代码块,插件会自动将其转换为 SVG。
|
|
6
|
+
|
|
7
|
+
````markdown
|
|
8
|
+
```mermaid
|
|
9
|
+
flowchart TD
|
|
10
|
+
A[Christmas] -->|Get money| B(Go shopping)
|
|
11
|
+
B --> C{Let me think}
|
|
12
|
+
C -->|One| D[Laptop]
|
|
13
|
+
C -->|Two| E[iPhone]
|
|
14
|
+
C -->|Three| F[fa:fa-car Car]
|
|
15
|
+
```
|
|
16
|
+
````
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<img src="./image.png" alt="sample" width="400" height="560" />
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
## 使用
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm i rspress-plugin-mermaid
|
|
26
|
+
pnpm add rspress-plugin-mermaid
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import * as path from 'path';
|
|
31
|
+
import { defineConfig } from 'rspress/config';
|
|
32
|
+
import mermaid from 'rspress-plugin-mermaid';
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
root: path.join(__dirname, 'docs'),
|
|
36
|
+
plugins: [mermaid()],
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 配置
|
|
41
|
+
|
|
42
|
+
### mermaidConfig
|
|
43
|
+
|
|
44
|
+
Mermaid 配置选项,将传递给 `mermaid.initialize` 函数。查看 [mermaid 文档](https://mermaid.js.org/config/schema-docs/config.html) 了解更多细节。
|
|
45
|
+
|
|
46
|
+
- Type: `object`
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import * as path from 'path';
|
|
50
|
+
import { defineConfig } from 'rspress/config';
|
|
51
|
+
import mermaid from 'rspress-plugin-mermaid';
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
root: path.join(__dirname, 'docs'),
|
|
55
|
+
plugins: [
|
|
56
|
+
mermaid({
|
|
57
|
+
mermaidConfig: {
|
|
58
|
+
theme: 'forest',
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"id":0,"title":"RSPress x Mermaid","content":"#\n\n","routePath":"/","lang":"","toc":[],"domain":"","frontmatter":{},"version":""}]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspress-plugin-mermaid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-beta.0",
|
|
4
4
|
"description": "Rspress plugin to render mermaid diagrams",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rspress",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@rspress/shared": "^1.17.1",
|
|
27
27
|
"mermaid": "^10.9.0",
|
|
28
|
-
"rspress-plugin-devkit": "^0.1.
|
|
28
|
+
"rspress-plugin-devkit": "^0.1.2-beta.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.12.5",
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import {
|
|
4
4
|
PresetConfigMutator,
|
|
5
5
|
RemarkCodeBlockToGlobalComponentPluginFactory,
|
|
6
|
+
getCompatComponentPath,
|
|
6
7
|
} from 'rspress-plugin-devkit';
|
|
7
8
|
|
|
8
9
|
import type { RspressPlugin } from '@rspress/shared';
|
|
@@ -22,7 +23,11 @@ export default function rspressPluginMermaid(
|
|
|
22
23
|
components: [
|
|
23
24
|
{
|
|
24
25
|
lang: 'mermaid',
|
|
25
|
-
componentPath: path.join(
|
|
26
|
+
componentPath: path.join(
|
|
27
|
+
__dirname,
|
|
28
|
+
'./components',
|
|
29
|
+
getCompatComponentPath(__dirname, 'MermaidRender.tsx'),
|
|
30
|
+
),
|
|
26
31
|
childrenProvider() {
|
|
27
32
|
return [];
|
|
28
33
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"id":0,"title":"RSPress x Mermaid","content":"#\n\nMERMAID\n\nflowchart TD\n\nA[Christmas] -->|Get money| B(Go shopping)\n\nB --> C{Let me think}\n\nC -->|One| D[Laptop]\n\nC -->|Two| E[iPhone]\n\nC -->|Three| F[fa:fa-car Car]","routePath":"/","lang":"","toc":[],"domain":"","frontmatter":{},"version":""}]
|