dumi 2.3.5 → 2.3.7

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.
@@ -109,9 +109,13 @@ export var useNavData = function useNavData() {
109
109
  }, {}));
110
110
  data.forEach(function (item, i) {
111
111
  var _item$children;
112
+ // item.link => the parent link is not in routes, but has children, will use parent.title or children.title
112
113
  if (!item.link && ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) === 1) {
113
114
  // hoist nav item if only one child
114
- data[i] = item.children[0];
115
+ var first = item.children[0];
116
+ data[i] = _objectSpread(_objectSpread({}, first), {}, {
117
+ title: (item === null || item === void 0 ? void 0 : item.title) || first.title
118
+ });
115
119
  } else if (item.children) {
116
120
  // sort nav item children by order or title
117
121
  item.children.sort(sidebarDataComparer);
@@ -27,7 +27,11 @@ function getCachedRouteMeta(route) {
27
27
  var _ref, _ref$key;
28
28
  (_ref$key = (_ref = meta)[key]) !== null && _ref$key !== void 0 ? _ref$key : _ref[key] = route.meta[key];
29
29
  });
30
- meta.frontmatter = deepmerge(meta.frontmatter, route.meta.frontmatter);
30
+ meta.frontmatter = deepmerge(meta.frontmatter, route.meta.frontmatter, {
31
+ arrayMerge: function arrayMerge(_destinationArray, sourceArray) {
32
+ return sourceArray;
33
+ }
34
+ });
31
35
  }
32
36
  return meta;
33
37
  };
@@ -138,15 +138,17 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
138
138
  id: string,
139
139
  opts?: T,
140
140
  ): T extends { syncOnly: true }
141
- ? IRouteMeta | undefined
142
- : Promise<IRouteMeta> | undefined {
143
- if (filesMeta[id]) {
144
- const { frontmatter, toc, textGetter, tabs } = filesMeta[id];
145
- const routeMeta: IRouteMeta = {
146
- frontmatter,
147
- toc: toc,
141
+ ? IRouteMeta
142
+ : Promise<IRouteMeta> {
143
+ const routeMeta: IRouteMeta = {
144
+ frontmatter: {},
145
+ toc: [],
148
146
  texts: [],
149
147
  };
148
+ if (filesMeta[id]) {
149
+ const { frontmatter, toc, textGetter, tabs } = filesMeta[id];
150
+ routeMeta.frontmatter = frontmatter;
151
+ routeMeta.toc = toc;
150
152
 
151
153
  if (opts?.syncOnly) {
152
154
  if (tabs) {
@@ -174,6 +176,10 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
174
176
  });
175
177
  }
176
178
  }
179
+ if (opts?.syncOnly) {
180
+ return routeMeta;
181
+ }
182
+ return Promise.resolve(routeMeta);
177
183
  }
178
184
 
179
185
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -262,7 +262,7 @@ var API = function API(props) {
262
262
  id: 'api.component.description'
263
263
  })), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
264
264
  id: 'api.component.type'
265
- })), props.type === 'props' && /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
265
+ })), type === 'props' && /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
266
266
  id: 'api.component.default'
267
267
  })))), /*#__PURE__*/React.createElement("tbody", null, Object.keys(properties).length ? Object.entries(properties).map(function (_ref9) {
268
268
  var _definition$propsConf;
@@ -274,7 +274,7 @@ var API = function API(props) {
274
274
  }, /*#__PURE__*/React.createElement("td", null, releaseInfo[name] ? /*#__PURE__*/React.createElement(APIRelease, {
275
275
  name: name,
276
276
  info: releaseInfo[name]
277
- }) : name), /*#__PURE__*/React.createElement("td", null, prop.description || '--'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(APIType, prop)), props.type === 'props' && /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, (_definition$propsConf = definition.propsConfig.required) !== null && _definition$propsConf !== void 0 && _definition$propsConf.includes(name) ? intl.formatMessage({
277
+ }) : name), /*#__PURE__*/React.createElement("td", null, prop.description || '--'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(APIType, prop)), type === 'props' && /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, (_definition$propsConf = definition.propsConfig.required) !== null && _definition$propsConf !== void 0 && _definition$propsConf.includes(name) ? intl.formatMessage({
278
278
  id: 'api.component.required'
279
279
  }) : JSON.stringify(prop.default) || '--')));
280
280
  }) : /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {