@antv/dumi-theme-antv 0.3.0-beta.9 → 0.3.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.
Files changed (69) hide show
  1. package/dist/builtins/Playground/index.d.ts +3 -6
  2. package/dist/builtins/Playground/index.js +27 -7
  3. package/dist/layouts/DocLayout.js +2 -3
  4. package/dist/layouts/entry/Index.js +14 -13
  5. package/dist/layouts/entry/Manual.js +6 -3
  6. package/dist/pages/404.js +4 -4
  7. package/dist/pages/Example/index.js +4 -4
  8. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +2 -1
  9. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +10 -5
  10. package/dist/pages/Examples/components/GalleryPageContent/index.js +2 -1
  11. package/dist/pages/Examples/index.js +3 -3
  12. package/dist/pages/Examples/index.module.less +13 -0
  13. package/dist/pages/Examples/utils.d.ts +1 -0
  14. package/dist/pages/Examples/utils.js +3 -0
  15. package/dist/plugin/index.js +10 -0
  16. package/dist/slots/Article/index.d.ts +3 -0
  17. package/dist/slots/Article/index.js +11 -0
  18. package/dist/slots/Article/index.module.less +8 -0
  19. package/dist/slots/Banner/Notification.d.ts +10 -0
  20. package/dist/slots/Banner/Notification.js +43 -0
  21. package/dist/slots/Banner/Notification.module.less +120 -0
  22. package/dist/slots/Banner/index.d.ts +26 -0
  23. package/dist/slots/Banner/index.js +184 -0
  24. package/dist/slots/Banner/index.module.less +449 -0
  25. package/dist/slots/Cases/index.d.ts +1 -1
  26. package/dist/slots/Cases/index.js +13 -7
  27. package/dist/slots/Cases/index.module.less +2 -1
  28. package/dist/slots/CodeEditor/Toolbar.js +13 -6
  29. package/dist/slots/CodeEditor/index.d.ts +4 -0
  30. package/dist/slots/CodeEditor/index.js +43 -21
  31. package/dist/slots/CodeEditor/utils.js +1 -1
  32. package/dist/slots/CodePreview/CodeHeader.js +15 -14
  33. package/dist/slots/CodePreview/index.d.ts +8 -0
  34. package/dist/slots/CodePreview/index.js +15 -6
  35. package/dist/slots/CodePreview/index.module.less +11 -2
  36. package/dist/slots/CodeRunner/index.d.ts +2 -0
  37. package/dist/slots/CodeRunner/index.js +13 -5
  38. package/dist/slots/Companies/index.d.ts +1 -1
  39. package/dist/slots/{TOC.d.ts → ContentTable/index.d.ts} +2 -1
  40. package/dist/slots/{TOC.js → ContentTable/index.js} +2 -1
  41. package/dist/slots/ContentTable/index.module.less +11 -0
  42. package/dist/slots/Detail/News.js +3 -2
  43. package/dist/slots/Detail/index.js +3 -1
  44. package/dist/slots/ExampleSider/index.js +23 -21
  45. package/dist/slots/Features/index.js +5 -2
  46. package/dist/slots/Features/index.module.less +3 -3
  47. package/dist/slots/Footer/index.js +34 -14
  48. package/dist/slots/Footer/index.module.less +0 -1
  49. package/dist/slots/Header/LogoWhite.js +1 -2
  50. package/dist/slots/Header/Navs.d.ts +2 -2
  51. package/dist/slots/Header/Navs.js +7 -7
  52. package/dist/slots/Header/Products/NavigatorBanner.js +4 -3
  53. package/dist/slots/Header/Products/Product.js +7 -3
  54. package/dist/slots/Header/Products/getProducts.js +4 -2
  55. package/dist/slots/Header/Products/index.js +5 -3
  56. package/dist/slots/Header/Search.js +5 -3
  57. package/dist/slots/Header/index.d.ts +7 -2
  58. package/dist/slots/Header/index.js +128 -24
  59. package/dist/slots/ManualContent/NavigatorBanner.js +5 -3
  60. package/dist/slots/ManualContent/ReadingTime.js +6 -2
  61. package/dist/slots/ManualContent/index.js +22 -28
  62. package/dist/slots/ManualContent/index.module.less +17 -9
  63. package/dist/slots/ManualContent/utils.d.ts +15 -0
  64. package/dist/slots/ManualContent/utils.js +31 -1
  65. package/dist/slots/_.less +1 -1
  66. package/dist/slots/hooks.d.ts +1 -1
  67. package/dist/slots/hooks.js +5 -8
  68. package/dist/slots/utils.js +6 -1
  69. package/package.json +5 -2
@@ -19,19 +19,19 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
 
21
21
  import React, { useEffect, useState } from 'react';
22
- import { Layout, Affix, BackTop, Menu, Tooltip } from 'antd';
22
+ import { Layout, Affix, BackTop, Menu } from 'antd';
23
23
  import { useMedia } from 'react-use';
24
24
  import Drawer from 'rc-drawer';
25
25
  import { useLocale, useSiteData, useFullSidebarData, useRouteMeta } from 'dumi';
26
26
  import { useNavigate } from "react-router-dom";
27
- import { EditOutlined, MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
27
+ import { MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
28
28
  import readingTime from 'reading-time';
29
- import { SEO } from "../SEO";
30
- import { getBaseRoute, getIndexRoute, getOpenKeys } from "./utils";
29
+ import URI from 'uri-parse';
30
+ import { SEO } from "dumi/theme/slots/SEO";
31
+ import { getBaseRoute, getIndexRoute, getOpenKeys, getNavigateUrl } from "./utils";
31
32
  import { NavigatorBanner } from "./NavigatorBanner";
32
33
  import ReadingTime from "./ReadingTime";
33
- import { TOC } from "../TOC";
34
- import { Footer } from "../Footer";
34
+ import { ContentTable } from "dumi/theme/slots/ContentTable";
35
35
  import { useScrollToTop } from "../hooks";
36
36
  import 'rc-drawer/assets/index.css';
37
37
  import styles from "./index.module.less";
@@ -92,7 +92,7 @@ export var ManualContent = function ManualContent(_ref) {
92
92
  function fullSidebarDataToMenuData(rootList, hrefId, list) {
93
93
  // 递归
94
94
  rootList.forEach(function (item) {
95
- var href = !baseRoute.startsWith('/en') ? "/".concat(item.slug) : "/en/".concat(item.slug);
95
+ var href = (!baseRoute.startsWith('/en') ? "/".concat(item.slug) : "/en/".concat(item.slug)).toLocaleLowerCase();
96
96
  var id = href.split("/").slice(0, href.split("/").length - 1).join("/");
97
97
 
98
98
  if (href.includes(baseRoute)) {
@@ -115,13 +115,17 @@ export var ManualContent = function ManualContent(_ref) {
115
115
  var item = _step.value;
116
116
  item.children = [];
117
117
  fullSidebarDataToMenuData(rootList, item.key, item.children);
118
- (_funllSidebarData$ite = funllSidebarData[item.key][0].children) === null || _funllSidebarData$ite === void 0 ? void 0 : _funllSidebarData$ite.forEach(function (itemChild) {
118
+ funllSidebarData[item.key] && ((_funllSidebarData$ite = funllSidebarData[item.key][0].children) === null || _funllSidebarData$ite === void 0 ? void 0 : _funllSidebarData$ite.forEach(function (itemChild) {
119
119
  var label = itemChild.title;
120
120
  var key = itemChild.link;
121
121
  item.children.push(_objectSpread(_objectSpread({}, itemChild), {}, {
122
122
  label: label,
123
123
  key: key
124
124
  }));
125
+ })); // children 的 order 排序
126
+
127
+ item.children.sort(function (a, b) {
128
+ return a.order - b.order;
125
129
  });
126
130
 
127
131
  if (item.children.length == 0) {
@@ -175,7 +179,7 @@ export var ManualContent = function ManualContent(_ref) {
175
179
  useScrollToTop();
176
180
  };
177
181
 
178
- var _useState5 = useState(renderSidebar.length !== 0 ? [renderSidebar[0].key] : ['']),
182
+ var _useState5 = useState(),
179
183
  _useState6 = _slicedToArray(_useState5, 2),
180
184
  defaultSelectedKey = _useState6[0],
181
185
  setDefaultSelectedKey = _useState6[1]; //上一夜下一页
@@ -197,11 +201,14 @@ export var ManualContent = function ManualContent(_ref) {
197
201
  for (var _i3 = 0, _Object$keys = Object.keys(linkoTitle); _i3 < _Object$keys.length; _i3++) {
198
202
  var route = _Object$keys[_i3];
199
203
  sidebarRoutes.push(route);
200
- } // 兜底 如果 nav 指定有误则自动重定向到 indexDocRoute
204
+ }
201
205
 
206
+ var uri = new URI(location.href);
207
+ uri.path = getNavigateUrl("/".concat(uri.path), indexRoute, sidebarRoutes);
202
208
 
203
- if (window.location.pathname.startsWith('/docs/') || !sidebarRoutes.includes(window.location.pathname)) {
204
- navigate(indexRoute);
209
+ if ("".concat(uri.path) !== window.location.pathname) {
210
+ uri.path = uri.path.slice(1);
211
+ navigate(uri.toURI().replace(location.origin, ''));
205
212
  } // 改变菜单栏选中和 openKeys 状态
206
213
 
207
214
 
@@ -301,18 +308,7 @@ export var ManualContent = function ManualContent(_ref) {
301
308
  className: styles.main
302
309
  }, /*#__PURE__*/React.createElement("h1", {
303
310
  className: styles.contentTitle
304
- }, linkoTitle[window.location.pathname], /*#__PURE__*/React.createElement(Tooltip, {
305
- title: '在 GitHub 上编辑'
306
- }, /*#__PURE__*/React.createElement("a", {
307
- href: getGithubSourceUrl({
308
- githubUrl: githubUrl,
309
- relativePath: relativePath,
310
- prefix: 'docs'
311
- }),
312
- target: "_blank",
313
- rel: "noopener noreferrer",
314
- className: styles.editOnGtiHubButton
315
- }, /*#__PURE__*/React.createElement(EditOutlined, null)))), /*#__PURE__*/React.createElement("div", {
311
+ }, linkoTitle[window.location.pathname]), /*#__PURE__*/React.createElement("div", {
316
312
  className: styles.readtimeContainer
317
313
  }, /*#__PURE__*/React.createElement(ReadingTime, {
318
314
  readingTime: time,
@@ -333,12 +329,10 @@ export var ManualContent = function ManualContent(_ref) {
333
329
  }
334
330
  }, /*#__PURE__*/React.createElement("div", {
335
331
  className: styles.backTop
336
- }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null)))))), /*#__PURE__*/React.createElement(Footer, {
337
- className: styles.footer
338
- })), is991Wide ? /*#__PURE__*/React.createElement(Layout.Sider, {
332
+ }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null))))))), is991Wide ? /*#__PURE__*/React.createElement(Layout.Sider, {
339
333
  theme: "light",
340
334
  width: 260
341
335
  }, /*#__PURE__*/React.createElement(Affix, {
342
336
  className: styles.toc
343
- }, /*#__PURE__*/React.createElement(TOC, null))) : /*#__PURE__*/React.createElement("div", null)));
337
+ }, /*#__PURE__*/React.createElement(ContentTable, null))) : /*#__PURE__*/React.createElement("div", null)));
344
338
  };
@@ -7,6 +7,7 @@
7
7
  .markdown {
8
8
  font-size: 14px;
9
9
  line-height: 2;
10
+ min-height: 600px; // 大概一屏幕占位,防止切换文档的时候,有黑影!
10
11
 
11
12
  h1 {
12
13
  margin-bottom: 20px;
@@ -83,6 +84,14 @@
83
84
  background-color: rgba(0, 0, 0, 0.03);
84
85
  }
85
86
 
87
+ code {
88
+ padding: 0.2em 0.4em;
89
+ margin: 0;
90
+ font-size: 85%;
91
+ background-color: rgba(175, 184, 193, 0.2);
92
+ border-radius: 6px;
93
+ }
94
+
86
95
  code[class*='language-'] {
87
96
  background: none;
88
97
  }
@@ -196,6 +205,10 @@
196
205
  > p > br {
197
206
  clear: both;
198
207
  }
208
+
209
+ img {
210
+ max-width: 100%;
211
+ }
199
212
  }
200
213
 
201
214
  .layout {
@@ -249,7 +262,7 @@
249
262
  ul>li {
250
263
  list-style: none !important;
251
264
  padding: 0 !important;
252
- margin-left: 1em !important;
265
+ margin-left: -1px !important;
253
266
 
254
267
  // 超出部分省略号显示
255
268
  text-overflow: ellipsis;
@@ -261,7 +274,7 @@
261
274
  }
262
275
  }
263
276
  }
264
- .contentTitle{
277
+ .contentTitle {
265
278
  margin-top: 8px;
266
279
  margin-bottom: 20px;
267
280
  font-weight: 500;
@@ -616,10 +629,6 @@
616
629
  justify-content: center;
617
630
  }
618
631
 
619
- .footer {
620
- width: 100%;
621
- }
622
-
623
632
  .menuSwitch {
624
633
  position: absolute;
625
634
  top: 72px;
@@ -639,11 +648,10 @@
639
648
  border-radius: 0 4px 4px 0;
640
649
  }
641
650
 
642
-
643
-
644
- .readtimeContainer{
651
+ .readtimeContainer {
645
652
  margin-bottom: 1.2em;
646
653
  }
654
+
647
655
  .readtime {
648
656
  color: #0d1a26;
649
657
  line-height: 1.5715;
@@ -1,3 +1,18 @@
1
1
  export declare function getOpenKeys(): any[];
2
2
  export declare function getBaseRoute(): string;
3
3
  export declare function getIndexRoute(MenuData: any): any;
4
+ /**
5
+ * 返回需要跳转的 pathname
6
+ * /en/api/ ----> /en/api/[first-doc]
7
+ * /zh/api/ ----> /api/[first-doc]
8
+ * /en/docs/api/ ----> /en/api/[first-doc]
9
+ * /zh/docs/api/ ----> /api/[first-doc]
10
+ *
11
+ * /en/docs/api/xxx ----> /en/api/xxx
12
+ * /zh/docs/api/xxx ----> /api/xxx
13
+ *
14
+ * /docs/api/xxx -----> /api/xxx
15
+ *
16
+ * @param p
17
+ */
18
+ export declare function getNavigateUrl(pathname: string, first: string, siderbarMenu: any[]): string;
@@ -1,5 +1,5 @@
1
1
  export function getOpenKeys() {
2
- var pathname = window.location.pathname;
2
+ var pathname = window.location.pathname.replace('/docs/', '/').replace('/zh/', '/');
3
3
  var pathArr = pathname.split('/');
4
4
  var openKeys = [];
5
5
 
@@ -32,4 +32,34 @@ export function getIndexRoute(MenuData) {
32
32
  }
33
33
 
34
34
  return defaultOpenKeys[defaultOpenKeys.length - 1];
35
+ }
36
+ /**
37
+ * 返回需要跳转的 pathname
38
+ * /en/api/ ----> /en/api/[first-doc]
39
+ * /zh/api/ ----> /api/[first-doc]
40
+ * /en/docs/api/ ----> /en/api/[first-doc]
41
+ * /zh/docs/api/ ----> /api/[first-doc]
42
+ *
43
+ * /en/docs/api/xxx ----> /en/api/xxx
44
+ * /zh/docs/api/xxx ----> /api/xxx
45
+ *
46
+ * /docs/api/xxx -----> /api/xxx
47
+ *
48
+ * @param p
49
+ */
50
+
51
+ export function getNavigateUrl(pathname, first, siderbarMenu) {
52
+ // 兜底 如果 nav 指定有误则自动重定向到 indexDocRoute
53
+ if (pathname.includes('/docs/') || pathname.includes('/zh/')) {
54
+ return pathname.replace('/docs/', '/').replace('/zh/', '/');
55
+ }
56
+
57
+ if (siderbarMenu.every(function (item) {
58
+ var itemLowerCase = "".concat(item).toLowerCase();
59
+ return ![itemLowerCase, "".concat(itemLowerCase, "/")].includes(pathname.toLowerCase());
60
+ })) {
61
+ return first;
62
+ }
63
+
64
+ return pathname;
35
65
  }
package/dist/slots/_.less CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  @media only screen and (max-width: 931.99px) {
12
12
  & {
13
- max-width: calc(100% - 60px);
13
+ max-width: calc(100% - 80px);
14
14
  }
15
15
  }
16
16
 
@@ -1,7 +1,6 @@
1
1
  import { NavigatorBannerProps } from './ManualContent/NavigatorBanner';
2
2
  export declare const useChinaMirrorHost: () => [boolean];
3
3
  export declare const useScrollToTop: () => void;
4
- export declare const useT: (transformedMessage: string) => string;
5
4
  export declare const useLogoLink: ({ link, siteUrl, lang, }: {
6
5
  link?: string;
7
6
  siteUrl?: string;
@@ -14,3 +13,4 @@ export declare const usePrevAndNext: () => NavigatorBannerProps['post'][];
14
13
  * @param v
15
14
  */
16
15
  export declare function ic(v: string | object): any;
16
+ export declare function icWithLocale(v: string | object, locale: any): any;
@@ -14,7 +14,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
14
 
15
15
  import { useEffect, useState } from 'react';
16
16
  import { get } from 'lodash-es';
17
- import { useIntl, useLocale } from 'dumi';
17
+ import { useLocale } from 'dumi';
18
18
  export var useChinaMirrorHost = function useChinaMirrorHost() {
19
19
  var _useState = useState(false),
20
20
  _useState2 = _slicedToArray(_useState, 2),
@@ -31,12 +31,6 @@ export var useChinaMirrorHost = function useChinaMirrorHost() {
31
31
  export var useScrollToTop = function useScrollToTop() {
32
32
  document.body.scrollTop = document.documentElement.scrollTop = 0;
33
33
  };
34
- export var useT = function useT(transformedMessage) {
35
- var intl = useIntl();
36
- return intl.formatMessage({
37
- id: transformedMessage
38
- });
39
- };
40
34
  export var useLogoLink = function useLogoLink(_ref) {
41
35
  var _ref$link = _ref.link,
42
36
  link = _ref$link === void 0 ? '' : _ref$link,
@@ -100,5 +94,8 @@ export var usePrevAndNext = function usePrevAndNext() {
100
94
 
101
95
  export function ic(v) {
102
96
  var locale = useLocale();
103
- return _typeof(v) === 'object' ? get(v, [locale.id]) : v;
97
+ return icWithLocale(v, locale.id);
98
+ }
99
+ export function icWithLocale(v, locale) {
100
+ return _typeof(v) === 'object' ? get(v, [locale]) : v;
104
101
  }
@@ -18,6 +18,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
18
18
 
19
19
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
20
20
 
21
+ import { icWithLocale } from "./hooks";
21
22
  export function ping() {
22
23
  return _ping.apply(this, arguments);
23
24
  }
@@ -102,7 +103,11 @@ export var filterTreeNode = function filterTreeNode(treeNode, keyValue, locale)
102
103
  }
103
104
  }
104
105
 
105
- var isCurrentTreeNodeMatched = treeNode.title[locale].toLowerCase().includes(keyValue.toLowerCase()); // 当前节点自身匹配,那么其孩子直接匹配,可以直接返回当前节点
106
+ var title = icWithLocale(treeNode.title, locale) || '';
107
+ var matchFields = [title, treeNode.id, treeNode.filename];
108
+ var isCurrentTreeNodeMatched = matchFields.some(function (f) {
109
+ return (f ? f.toLowerCase() : '').includes(keyValue ? keyValue.toLowerCase() : '');
110
+ }); // 当前节点自身匹配,那么其孩子直接匹配,可以直接返回当前节点
106
111
 
107
112
  if (isCurrentTreeNodeMatched) {
108
113
  return treeNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.3.0-beta.9",
3
+ "version": "0.3.1",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "types": "dist/types.d.ts",
6
6
  "scripts": {
@@ -75,7 +75,9 @@
75
75
  "rc-footer": "^0.6.6",
76
76
  "react": "^18.2.0",
77
77
  "react-dom": "^18.2.0",
78
+ "react-error-boundary": "^3.1.4",
78
79
  "react-github-button": "^0.1.11",
80
+ "react-helmet": "^6.1.0",
79
81
  "react-router-dom": "^6.4.2",
80
82
  "react-slick": "^0.29.0",
81
83
  "react-split-pane": "^0.1.92",
@@ -83,7 +85,8 @@
83
85
  "reading-time": "^1.5.0",
84
86
  "size-sensor": "^1.0.1",
85
87
  "slick-carousel": "^1.8.1",
86
- "uri-parse": "^1.0.0"
88
+ "uri-parse": "^1.0.0",
89
+ "video-react": "^0.16.0"
87
90
  },
88
91
  "peerDependencies": {
89
92
  "dumi": "^2.0.0-beta.15",