@alauda/doom 0.8.5 → 0.9.1
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/lib/cli/load-config.js +20 -8
- package/lib/plugins/mermaid/index.d.ts +2 -0
- package/lib/plugins/mermaid/index.js +9 -0
- package/lib/plugins/mermaid/remark-mermaid.d.ts +3 -0
- package/lib/plugins/mermaid/remark-mermaid.js +22 -0
- package/lib/plugins/shiki/transformers/callouts.js +1 -0
- package/lib/runtime/components/Mermaid.d.ts +7 -0
- package/lib/runtime/components/Mermaid.js +23 -0
- package/lib/runtime/components/index.d.ts +1 -0
- package/lib/runtime/components/index.js +1 -0
- package/package.json +9 -8
package/lib/cli/load-config.js
CHANGED
|
@@ -10,6 +10,7 @@ import { normalizeVersion } from '../shared/index.js';
|
|
|
10
10
|
import { pkgResolve, resolveStaticConfig, } from '../utils/index.js';
|
|
11
11
|
import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
12
12
|
import { replacePlugin } from '../plugins/replace/index.js';
|
|
13
|
+
import { mermaidPlugin } from '../plugins/mermaid/index.js';
|
|
13
14
|
const DEFAULT_LOGO = '/logo.svg';
|
|
14
15
|
const zhLocaleConfig = {
|
|
15
16
|
searchPlaceholderText: '搜索文档',
|
|
@@ -20,13 +21,13 @@ const zhLocaleConfig = {
|
|
|
20
21
|
nextPageText: '下一页',
|
|
21
22
|
};
|
|
22
23
|
const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force) => {
|
|
23
|
-
const fallbackToZh = 'lang' in config && config.lang
|
|
24
|
+
const fallbackToZh = 'lang' in config && !config.lang;
|
|
24
25
|
const root = resolveDocRoot(CWD, cliRoot, config.root);
|
|
25
26
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
26
27
|
const excludeRoutes = (ignore && config.internalRoutes) || [];
|
|
27
28
|
return {
|
|
28
29
|
root,
|
|
29
|
-
lang: fallbackToZh ? 'zh' : config.lang,
|
|
30
|
+
lang: fallbackToZh ? 'zh' : config.lang || 'en',
|
|
30
31
|
title: '',
|
|
31
32
|
route: {
|
|
32
33
|
exclude: [
|
|
@@ -73,6 +74,7 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force
|
|
|
73
74
|
sites: config.sites,
|
|
74
75
|
version,
|
|
75
76
|
}),
|
|
77
|
+
mermaidPlugin(),
|
|
76
78
|
replacePlugin({
|
|
77
79
|
root,
|
|
78
80
|
lang: fallbackToZh ? null : (config.lang ?? 'en'),
|
|
@@ -82,16 +84,26 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force
|
|
|
82
84
|
releaseNotes: config.releaseNotes,
|
|
83
85
|
}),
|
|
84
86
|
shikiPlugin({
|
|
85
|
-
langs: ['dockerfile', 'html', 'go', 'jsonc'],
|
|
87
|
+
langs: ['dockerfile', 'html', 'go', 'jsonc', 'mermaid'],
|
|
86
88
|
transformers: [
|
|
87
89
|
// builtin transformers
|
|
88
90
|
transformerMetaHighlight(),
|
|
89
91
|
transformerMetaWordHighlight(),
|
|
90
|
-
transformerNotationDiff(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
transformerNotationDiff({
|
|
93
|
+
matchAlgorithm: 'v3',
|
|
94
|
+
}),
|
|
95
|
+
transformerNotationErrorLevel({
|
|
96
|
+
matchAlgorithm: 'v3',
|
|
97
|
+
}),
|
|
98
|
+
transformerNotationFocus({
|
|
99
|
+
matchAlgorithm: 'v3',
|
|
100
|
+
}),
|
|
101
|
+
transformerNotationHighlight({
|
|
102
|
+
matchAlgorithm: 'v3',
|
|
103
|
+
}),
|
|
104
|
+
transformerNotationWordHighlight({
|
|
105
|
+
matchAlgorithm: 'v3',
|
|
106
|
+
}),
|
|
95
107
|
transformerRemoveNotationEscape(),
|
|
96
108
|
// custom transformers
|
|
97
109
|
createTransformerCallouts(),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
export const remarkMermaid = function () {
|
|
3
|
+
return (root) => {
|
|
4
|
+
visit(root, 'code', (node, index, parent) => {
|
|
5
|
+
if (!parent || node.lang !== 'mermaid') {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
parent.children.splice(index, 1, {
|
|
9
|
+
type: 'mdxJsxFlowElement',
|
|
10
|
+
name: 'Mermaid',
|
|
11
|
+
attributes: [
|
|
12
|
+
{
|
|
13
|
+
type: 'mdxJsxAttribute',
|
|
14
|
+
name: 'children',
|
|
15
|
+
value: node.value,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
children: [],
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useDark } from '@rspress/core/runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import mermaid from 'mermaid';
|
|
5
|
+
import { useEffect, useId, useRef } from 'react';
|
|
6
|
+
export const Mermaid = ({ className, children }) => {
|
|
7
|
+
const id = useId();
|
|
8
|
+
const isDark = useDark();
|
|
9
|
+
const containerRef = useRef(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const container = containerRef.current;
|
|
12
|
+
mermaid.initialize({ theme: isDark ? 'dark' : 'default' });
|
|
13
|
+
const render = async () => {
|
|
14
|
+
const { svg, diagramType, bindFunctions } = await mermaid.render(`mermaid-${id.slice(1, -1)}`, children);
|
|
15
|
+
container.classList.add(diagramType);
|
|
16
|
+
container.innerHTML = svg;
|
|
17
|
+
bindFunctions?.(container);
|
|
18
|
+
};
|
|
19
|
+
void render();
|
|
20
|
+
}, [children, isDark]);
|
|
21
|
+
return (_jsx("div", { ref: containerRef, id: id, className: clsx('doom-mermaid', className) }));
|
|
22
|
+
};
|
|
23
|
+
export default Mermaid;
|
|
@@ -10,6 +10,7 @@ export * from './ExternalSiteLink.js';
|
|
|
10
10
|
export * from './JsonViewer.js';
|
|
11
11
|
export * from './K8sCrd.js';
|
|
12
12
|
export * from './LinkCard.js';
|
|
13
|
+
export * from './Mermaid.js';
|
|
13
14
|
export * from './Overview.js';
|
|
14
15
|
export * from './OpenAPIRef.js';
|
|
15
16
|
export * from './OpenAPIPath.js';
|
|
@@ -10,6 +10,7 @@ export * from './ExternalSiteLink.js';
|
|
|
10
10
|
export * from './JsonViewer.js';
|
|
11
11
|
export * from './K8sCrd.js';
|
|
12
12
|
export * from './LinkCard.js';
|
|
13
|
+
export * from './Mermaid.js';
|
|
13
14
|
export * from './Overview.js';
|
|
14
15
|
export * from './OpenAPIRef.js';
|
|
15
16
|
export * from './OpenAPIPath.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -41,12 +41,13 @@
|
|
|
41
41
|
"@inquirer/prompts": "^7.2.3",
|
|
42
42
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
43
43
|
"@rspress/core": "1.40.0",
|
|
44
|
-
"@shikijs/transformers": "^1.
|
|
44
|
+
"@shikijs/transformers": "^2.1.0",
|
|
45
45
|
"chokidar": "^4.0.3",
|
|
46
46
|
"clsx": "^2.1.1",
|
|
47
|
-
"commander": "^
|
|
47
|
+
"commander": "^13.1.0",
|
|
48
48
|
"ejs": "^3.1.10",
|
|
49
49
|
"es-toolkit": "^1.31.0",
|
|
50
|
+
"mermaid": "^11.4.1",
|
|
50
51
|
"openapi-types": "^12.1.3",
|
|
51
52
|
"picomatch": "^4.0.2",
|
|
52
53
|
"react-markdown": "^8.0.7",
|
|
@@ -54,23 +55,23 @@
|
|
|
54
55
|
"remark-directive": "^2.0.1",
|
|
55
56
|
"remark-frontmatter": "^4.0.1",
|
|
56
57
|
"remark-gfm": "^3.0.1",
|
|
57
|
-
"shiki": "^1.
|
|
58
|
+
"shiki": "^2.1.0",
|
|
58
59
|
"simple-git": "^3.27.0",
|
|
59
60
|
"swagger2openapi": "^7.0.8",
|
|
60
61
|
"tinyglobby": "^0.2.10",
|
|
61
|
-
"type-fest": "^4.
|
|
62
|
+
"type-fest": "^4.33.0",
|
|
62
63
|
"yaml": "^2.7.0",
|
|
63
64
|
"yoctocolors": "^2.1.1"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@eslint/js": "^9.18.0",
|
|
67
68
|
"@swc-node/register": "^1.10.9",
|
|
68
|
-
"@swc/core": "1.10.
|
|
69
|
+
"@swc/core": "1.10.9",
|
|
69
70
|
"@types/ejs": "^3.1.5",
|
|
70
71
|
"@types/eslint__js": "^8.42.3",
|
|
71
72
|
"@types/fs-extra": "^11.0.4",
|
|
72
73
|
"@types/node": "^18.19.71",
|
|
73
|
-
"@types/picomatch": "^3.0.
|
|
74
|
+
"@types/picomatch": "^3.0.2",
|
|
74
75
|
"@types/react-dom": "^18.3.5",
|
|
75
76
|
"@types/swagger2openapi": "^7.0.4",
|
|
76
77
|
"@unts/patch-package": "^8.0.0",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"prettier-plugin-pkg": "^0.18.1",
|
|
82
83
|
"simple-git-hooks": "^2.11.1",
|
|
83
84
|
"typescript": "^5.7.3",
|
|
84
|
-
"typescript-eslint": "^8.
|
|
85
|
+
"typescript-eslint": "^8.21.0"
|
|
85
86
|
},
|
|
86
87
|
"publishConfig": {
|
|
87
88
|
"access": "public"
|