dumi 2.1.7 → 2.1.9

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.
@@ -61,7 +61,9 @@ export var useFullSidebarData = function useFullSidebarData() {
61
61
  // en-US/a => /en-US/a
62
62
  // a/b => /a
63
63
  // en-US/a/b => /en-US/a
64
- var parentPath = "/".concat(route.path.replace(/\/[^/]+$/, ''));
64
+ var parentPath = "/".concat(route.path.replace(clearPath, function (s) {
65
+ return s.replace(/\/[^/]+$/, '');
66
+ }));
65
67
 
66
68
  var _pickRouteSortMeta = pickRouteSortMeta({
67
69
  order: 0
@@ -225,6 +227,8 @@ export var useSidebarData = function useSidebarData() {
225
227
  // /en-US/a/b => /en-US/a
226
228
  // /en-US/a/b/ => /en-US/a (also strip trailing /)
227
229
 
228
- var parentPath = clearPath ? pathname.replace(/(\/[^/]+)(\/[^/]+\/?)$/, '$1') : pathname;
230
+ var parentPath = clearPath ? pathname.replace(clearPath, function (s) {
231
+ return s.replace(/([^/]+)(\/[^/]+\/?)$/, '$1');
232
+ }) : pathname;
229
233
  return parentPath ? sidebar[parentPath] : [];
230
234
  };
@@ -83,6 +83,16 @@ var parser_default = (api) => {
83
83
  api.service.atomParser.destroyWorker();
84
84
  }
85
85
  });
86
+ api.modifyTheme((memo) => {
87
+ const parserOffKey = "api.component.unavailable";
88
+ const parserOnKey = "api.component.loading";
89
+ Object.keys(memo.locales).forEach((locale) => {
90
+ if (memo.locales[locale][parserOnKey]) {
91
+ memo.locales[locale][parserOffKey] = memo.locales[locale][parserOnKey];
92
+ }
93
+ });
94
+ return memo;
95
+ });
86
96
  };
87
97
  // Annotate the CommonJS export names for ESM import in node:
88
98
  0 && (module.exports = {});
@@ -31,7 +31,7 @@ var visit;
31
31
  ({ visit } = await import("unist-util-visit"));
32
32
  })();
33
33
  function isRelativeUrl(url) {
34
- return !/^((blob:)?\w+:)?\/\//.test(url) && !import_path.default.isAbsolute(url);
34
+ return !url.startsWith("data:image") && !/^((blob:)?\w+:)?\/\//.test(url) && !import_path.default.isAbsolute(url);
35
35
  }
36
36
  function rehypeImg() {
37
37
  return (tree) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -52,7 +52,7 @@ var API = function API(props) {
52
52
  }) : /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
53
53
  colSpan: 4
54
54
  }, intl.formatMessage({
55
- id: "api.component.".concat(components ? 'not.found' : 'loading')
55
+ id: "api.component.".concat(components ? 'not.found' : 'unavailable')
56
56
  }, {
57
57
  id: id
58
58
  }))))));
@@ -24,6 +24,7 @@
24
24
  "api.component.type": "Type",
25
25
  "api.component.default": "Default",
26
26
  "api.component.required": "(required)",
27
+ "api.component.unavailable": "apiParser must be enabled to use auto-generated API",
27
28
  "api.component.loading": "Properties definition is resolving, wait a moment...",
28
29
  "api.component.not.found": "Properties definition not found for {id} component",
29
30
  "content.tabs.default": "Doc",
@@ -24,6 +24,7 @@
24
24
  "api.component.type": "类型",
25
25
  "api.component.default": "默认值",
26
26
  "api.component.required": "(必选)",
27
+ "api.component.unavailable": "必须启用 apiParser 才能使用自动 API 特性",
27
28
  "api.component.loading": "属性定义正在解析中,稍等片刻...",
28
29
  "api.component.not.found": "未找到 {id} 组件的属性定义",
29
30
  "content.tabs.default": "文档",
@@ -19,7 +19,8 @@ function getTargetLocalePath(_ref) {
19
19
  var pathname = _ref.pathname,
20
20
  current = _ref.current,
21
21
  target = _ref.target;
22
- var clearPath = 'base' in current ? pathname.replace(current.base.replace(/\/$/, ''), '') : pathname.replace(new RegExp("".concat(current.suffix, "$")), '');
22
+ var clearPath = 'base' in current ? // handle '/en-US/a' => '/a' or '/en-US' => '' => '/'
23
+ pathname.replace(current.base.replace(/\/$/, ''), '') || '/' : pathname.replace(new RegExp("".concat(current.suffix, "$")), '');
23
24
  return 'base' in target ? "".concat( // for `/` base, strip duplicated leading slash
24
25
  target.base.replace(/\/$/, '')).concat(clearPath) // for `/` clearPath, strip duplicated ending slash
25
26
  .replace(/([^/])\/$/, '$1') : "".concat(clearPath).concat(target.suffix);