dumi 2.1.3 → 2.1.4
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/dist/client/theme-api/types.d.ts +2 -2
- package/dist/features/derivative.js +3 -0
- package/dist/features/meta.js +11 -4
- package/dist/features/tabs.d.ts +2 -2
- package/dist/features/tabs.js +11 -8
- package/dist/loaders/markdown/transformer/rehypeDemo.js +8 -7
- package/dist/types.d.ts +6 -6
- package/package.json +2 -2
- package/theme-default/slots/ContentTabs/index.js +3 -3
|
@@ -109,6 +109,9 @@ var derivative_default = (api) => {
|
|
|
109
109
|
});
|
|
110
110
|
api.modifyConfig((memo) => {
|
|
111
111
|
var _a;
|
|
112
|
+
if (api.userConfig.mfsu === true) {
|
|
113
|
+
memo.mfsu = {};
|
|
114
|
+
}
|
|
112
115
|
if ((_a = api.userConfig.alias) == null ? void 0 : _a["@"]) {
|
|
113
116
|
memo.alias["@"] = api.userConfig.alias["@"];
|
|
114
117
|
} else {
|
package/dist/features/meta.js
CHANGED
|
@@ -119,10 +119,17 @@ export const patchRoutes = ({ routes }) => {
|
|
|
119
119
|
route.meta = deepmerge(route.meta, filesMeta[route.id]);
|
|
120
120
|
|
|
121
121
|
// apply real tab data from id
|
|
122
|
-
route.meta.tabs = route.meta.tabs?.map(id =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
route.meta.tabs = route.meta.tabs?.map((id) => {
|
|
123
|
+
const meta = {
|
|
124
|
+
frontmatter: { title: tabs[id].title },
|
|
125
|
+
toc: [],
|
|
126
|
+
texts: [],
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
...tabs[id],
|
|
130
|
+
meta: filesMeta[id] || meta,
|
|
131
|
+
}
|
|
132
|
+
});
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
});
|
package/dist/features/tabs.d.ts
CHANGED
package/dist/features/tabs.js
CHANGED
|
@@ -86,8 +86,8 @@ var tabs_default = (api) => {
|
|
|
86
86
|
index: tabs.length + index,
|
|
87
87
|
key: tab.key,
|
|
88
88
|
id: tab.id,
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
title: tab.title || import_plugin_utils.lodash.startCase(import_path.default.parse(tab.component).name),
|
|
90
|
+
titleIntlId: tab.titleIntlId,
|
|
91
91
|
file: tab.component
|
|
92
92
|
})));
|
|
93
93
|
return routes;
|
|
@@ -101,11 +101,14 @@ var tabs_default = (api) => {
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
tabs.forEach((tab) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const isFromPlugin = tabsFromPlugins.some((item) => item.id === tab.id);
|
|
105
|
+
if (!isFromPlugin) {
|
|
106
|
+
metaFiles.push({
|
|
107
|
+
id: tab.id,
|
|
108
|
+
file: tab.file,
|
|
109
|
+
index: metaFiles.length
|
|
110
|
+
});
|
|
111
|
+
}
|
|
109
112
|
});
|
|
110
113
|
return metaFiles;
|
|
111
114
|
}
|
|
@@ -120,7 +123,7 @@ import * as tab{{{index}}} from '{{{file}}}';
|
|
|
120
123
|
|
|
121
124
|
export const tabs = {
|
|
122
125
|
{{#tabs}}
|
|
123
|
-
'{{{id}}}': { key: '{{{key}}}',
|
|
126
|
+
'{{{id}}}': { key: '{{{key}}}', title: '{{{title}}}', titleIntlId: '{{{titleIntlId}}}', components: tab{{{index}}} },
|
|
124
127
|
{{/tabs}}
|
|
125
128
|
}
|
|
126
129
|
`, { tabs })
|
|
@@ -163,6 +163,12 @@ function rehypeDemo(opts) {
|
|
|
163
163
|
"snapshot",
|
|
164
164
|
"keywords"
|
|
165
165
|
];
|
|
166
|
+
const techStackOpts = {
|
|
167
|
+
type: codeType,
|
|
168
|
+
mdAbsPath: opts.fileAbsPath,
|
|
169
|
+
fileAbsPath: codeType === "external" ? parseOpts.fileAbsPath : void 0,
|
|
170
|
+
entryPointCode: parseOpts.entryPointCode
|
|
171
|
+
};
|
|
166
172
|
Object.keys(restAttrs).forEach((key) => {
|
|
167
173
|
if (restAttrs[key] === "")
|
|
168
174
|
restAttrs[key] = true;
|
|
@@ -179,12 +185,7 @@ function rehypeDemo(opts) {
|
|
|
179
185
|
component
|
|
180
186
|
};
|
|
181
187
|
}
|
|
182
|
-
Object.assign(previewerProps, await ((_b = techStack.generatePreviewerProps) == null ? void 0 : _b.call(techStack, originalProps,
|
|
183
|
-
type: codeType,
|
|
184
|
-
mdAbsPath: opts.fileAbsPath,
|
|
185
|
-
fileAbsPath: codeType === "external" ? parseOpts.fileAbsPath : void 0,
|
|
186
|
-
entryPointCode: parseOpts.entryPointCode
|
|
187
|
-
})) || originalProps);
|
|
188
|
+
Object.assign(previewerProps, await ((_b = techStack.generatePreviewerProps) == null ? void 0 : _b.call(techStack, originalProps, techStackOpts)) || originalProps);
|
|
188
189
|
if (previewerProps.description) {
|
|
189
190
|
const { unified } = await import("unified");
|
|
190
191
|
const { default: remarkParse } = await import("remark-parse");
|
|
@@ -201,7 +202,7 @@ function rehypeDemo(opts) {
|
|
|
201
202
|
return {
|
|
202
203
|
id: asset.id,
|
|
203
204
|
component,
|
|
204
|
-
asset: techStack.generateMetadata ? await techStack.generateMetadata(asset) : asset,
|
|
205
|
+
asset: techStack.generateMetadata ? await techStack.generateMetadata(asset, techStackOpts) : asset,
|
|
205
206
|
sources
|
|
206
207
|
};
|
|
207
208
|
}));
|
package/dist/types.d.ts
CHANGED
|
@@ -71,16 +71,16 @@ export declare abstract class IDumiTechStack {
|
|
|
71
71
|
/**
|
|
72
72
|
* generator for return asset metadata
|
|
73
73
|
*/
|
|
74
|
-
abstract generateMetadata?(asset: ExampleBlockAsset
|
|
75
|
-
/**
|
|
76
|
-
* generator for return previewer props
|
|
77
|
-
*/
|
|
78
|
-
abstract generatePreviewerProps?(props: IDumiDemoProps['previewerProps'], opts: {
|
|
74
|
+
abstract generateMetadata?(asset: ExampleBlockAsset, opts: {
|
|
79
75
|
type: Parameters<IDumiTechStack['transformCode']>[1]['type'];
|
|
80
76
|
mdAbsPath: string;
|
|
81
77
|
fileAbsPath?: string;
|
|
82
78
|
entryPointCode?: string;
|
|
83
|
-
}): Promise<
|
|
79
|
+
}): Promise<ExampleBlockAsset> | ExampleBlockAsset;
|
|
80
|
+
/**
|
|
81
|
+
* generator for return previewer props
|
|
82
|
+
*/
|
|
83
|
+
abstract generatePreviewerProps?(props: IDumiDemoProps['previewerProps'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IDumiDemoProps['previewerProps']> | IDumiDemoProps['previewerProps'];
|
|
84
84
|
}
|
|
85
85
|
export declare type IApi = IUmiApi & {
|
|
86
86
|
config: IDumiConfig & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"prism-themes": "^1.9.0",
|
|
108
108
|
"prismjs": "^1.29.0",
|
|
109
109
|
"raw-loader": "^4.0.2",
|
|
110
|
-
"rc-tabs": "12.
|
|
110
|
+
"rc-tabs": "^12.5.6",
|
|
111
111
|
"react-copy-to-clipboard": "^5.1.0",
|
|
112
112
|
"react-error-boundary": "^3.1.4",
|
|
113
113
|
"react-intl": "^6.1.1",
|
|
@@ -28,9 +28,9 @@ var ContentTabs = function ContentTabs(_ref) {
|
|
|
28
28
|
"data-active": key === tab.key || undefined
|
|
29
29
|
}, /*#__PURE__*/React.createElement("button", {
|
|
30
30
|
type: "button"
|
|
31
|
-
}, tab.
|
|
32
|
-
id: tab.
|
|
33
|
-
}) : tab.
|
|
31
|
+
}, tab.titleIntlId ? intl.formatMessage({
|
|
32
|
+
id: tab.titleIntlId
|
|
33
|
+
}) : tab.meta.frontmatter.title));
|
|
34
34
|
})) : null;
|
|
35
35
|
};
|
|
36
36
|
|