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.
@@ -115,8 +115,8 @@ export interface IRouteMeta {
115
115
  }[];
116
116
  tabs?: {
117
117
  key: string;
118
- name?: string;
119
- nameIntlId?: string;
118
+ title?: string;
119
+ titleIntlId?: string;
120
120
  components: {
121
121
  default: ComponentType;
122
122
  Extra: ComponentType;
@@ -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 {
@@ -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
- ...tabs[id],
124
- meta: filesMeta[id],
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
  });
@@ -3,8 +3,8 @@ export interface IContentTab {
3
3
  key: string;
4
4
  id?: string;
5
5
  test?: RegExp;
6
- name?: string;
7
- nameIntlId?: string;
6
+ title?: string;
7
+ titleIntlId?: string;
8
8
  component: string;
9
9
  }
10
10
  export declare function isTabRouteFile(file: string): boolean;
@@ -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
- name: tab.name,
90
- nameIntlId: tab.nameIntlId,
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
- metaFiles.push({
105
- id: tab.id,
106
- file: tab.file,
107
- index: metaFiles.length
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}}}', name: '{{{name}}}', nameIntlId: '{{{nameIntlId}}}', components: tab{{{index}}} },
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): Promise<ExampleBlockAsset> | 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<IDumiDemoProps['previewerProps']> | IDumiDemoProps['previewerProps'];
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",
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.1.0-alpha.1",
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.nameIntlId ? intl.formatMessage({
32
- id: tab.nameIntlId
33
- }) : tab.name || tab.meta.frontmatter.title));
31
+ }, tab.titleIntlId ? intl.formatMessage({
32
+ id: tab.titleIntlId
33
+ }) : tab.meta.frontmatter.title));
34
34
  })) : null;
35
35
  };
36
36