@antv/dumi-theme-antv 0.4.5 → 0.5.0

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 (40) hide show
  1. package/dist/layouts/DocLayout.d.ts +2 -1
  2. package/dist/layouts/entry/Index.js +2 -2
  3. package/dist/locales/en.json +13 -7
  4. package/dist/locales/zh.json +9 -3
  5. package/dist/model/index.d.ts +5 -0
  6. package/dist/model/index.js +6 -0
  7. package/dist/pages/Example/components/CollapsedIcon/index.d.ts +8 -0
  8. package/dist/pages/Example/components/CollapsedIcon/index.js +15 -0
  9. package/dist/pages/Example/components/CollapsedIcon/index.module.less +14 -0
  10. package/dist/pages/Example/index.js +28 -11
  11. package/dist/pages/Examples/components/Accouncement/index.js +2 -2
  12. package/dist/pages/Examples/components/GalleryPageContent/index.js +2 -2
  13. package/dist/plugin/api.d.ts +7 -0
  14. package/dist/plugin/api.js +82 -0
  15. package/dist/plugin/examples.d.ts +1 -1
  16. package/dist/plugin/examples.js +28 -21
  17. package/dist/plugin/index.js +2 -1
  18. package/dist/slots/API/index.d.ts +15 -0
  19. package/dist/slots/API/index.js +202 -0
  20. package/dist/slots/API/index.module.less +93 -0
  21. package/dist/slots/Banner/index.js +2 -2
  22. package/dist/slots/CodeEditor/Toolbar.js +2 -2
  23. package/dist/slots/CodeEditor/utils.js +7 -9
  24. package/dist/slots/CodeRunner/utils.js +4 -3
  25. package/dist/slots/Detail/News.d.ts +2 -0
  26. package/dist/slots/Detail/News.js +9 -2
  27. package/dist/slots/Detail/News.module.less +47 -18
  28. package/dist/slots/Detail/index.js +4 -6
  29. package/dist/slots/Detail/index.module.less +11 -4
  30. package/dist/slots/ExampleSider/index.js +2 -3
  31. package/dist/slots/Footer/index.js +24 -11
  32. package/dist/slots/Header/Navs.js +7 -3
  33. package/dist/slots/Header/Products/getProducts.js +2 -2
  34. package/dist/slots/Header/Products/index.js +2 -2
  35. package/dist/slots/Header/index.d.ts +9 -0
  36. package/dist/slots/Header/index.js +70 -68
  37. package/dist/slots/Header/index.module.less +17 -0
  38. package/dist/slots/ManualContent/index.js +10 -4
  39. package/dist/slots/ManualContent/index.module.less +39 -18
  40. package/package.json +36 -32
@@ -1,7 +1,8 @@
1
+ import React from 'react';
1
2
  import '../slots/global';
2
3
  import '../slots/_.less';
3
4
  /**
4
5
  * DocuLayout 是 dumi2 的内置 layout 入口,在这里使用页面路径进行区分成自己不同的 Layout。
5
6
  */
6
- declare const _default: () => any;
7
+ declare const _default: () => React.JSX.Element;
7
8
  export default _default;
@@ -2,8 +2,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import React from 'react';
8
8
  import { useLocale, useSiteData, FormattedMessage } from 'dumi';
9
9
  import { SEO } from "dumi/theme/slots/SEO";
@@ -88,12 +88,18 @@
88
88
  "标准版基础产品": "Standard basic products",
89
89
  "标准版扩展产品": "Standard extended products",
90
90
  "移动定制(F版)产品": "Mobile (F series) products",
91
- "感谢信赖":"WE ARE TRUSTED BY",
92
- "更多产品":"More Productions",
93
- "上一篇":"Previous",
94
- "下一篇":"Next",
91
+ "感谢信赖": "WE ARE TRUSTED BY",
92
+ "更多产品": "More Productions",
93
+ "上一篇": "Previous",
94
+ "下一篇": "Next",
95
95
  "演示代码报错,请检查": "演示代码报错,请检查",
96
- "阅读时间约":"Reading needs",
97
- "分钟":"minutes",
98
- "没有找到查询结果":"No query result found"
96
+ "阅读时间约": "Reading needs",
97
+ "分钟": "minutes",
98
+ "没有找到查询结果": "No query result found",
99
+ "企业级 UI 设计语言": "Enterprise UI design language",
100
+ "知识创作与分享工具": "Knowledge creation and Sharing tool",
101
+ "语雀": "Yuque",
102
+ "企业级 Node 开发框架": "Enterprise-class Node development framework",
103
+ "Sketch 工具集": "Sketch Tool set",
104
+ "蚂蚁体验科技": "Liven Experience technology"
99
105
  }
@@ -93,7 +93,13 @@
93
93
  "上一篇": "上一篇",
94
94
  "下一篇": "下一篇",
95
95
  "演示代码报错,请检查": "演示代码报错,请检查",
96
- "阅读时间约":"阅读时间约",
97
- "分钟":"分钟",
98
- "没有找到查询结果":"没有找到查询结果"
96
+ "阅读时间约": "阅读时间约",
97
+ "分钟": "分钟",
98
+ "没有找到查询结果": "没有找到查询结果",
99
+ "企业级 UI 设计语言": "企业级 UI 设计语言",
100
+ "知识创作与分享工具": "知识创作与分享工具",
101
+ "语雀": "语雀",
102
+ "企业级 Node 开发框架": "企业级 Node 开发框架",
103
+ "Sketch 工具集": "Sketch 工具集",
104
+ "蚂蚁体验科技": "蚂蚁体验科技"
99
105
  }
@@ -0,0 +1,5 @@
1
+ export declare const store: {
2
+ hideMenu: boolean;
3
+ showAPI: boolean;
4
+ apiContainerWidth: number;
5
+ };
@@ -0,0 +1,6 @@
1
+ import { proxy } from 'valtio';
2
+ export var store = proxy({
3
+ hideMenu: false,
4
+ showAPI: false,
5
+ apiContainerWidth: 420
6
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface CollapsedProps {
3
+ isCollapsed: boolean;
4
+ style?: React.CSSProperties;
5
+ onClick?: (isCollapsed: boolean) => void;
6
+ }
7
+ export declare const CollapsedIcon: React.FC<CollapsedProps>;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons';
2
+ import React from 'react';
3
+ import styles from "./index.module.less";
4
+ export var CollapsedIcon = function CollapsedIcon(props) {
5
+ var isCollapsed = props.isCollapsed,
6
+ _onClick = props.onClick,
7
+ style = props.style;
8
+ return /*#__PURE__*/React.createElement("div", {
9
+ className: styles.collapsed,
10
+ onClick: function onClick() {
11
+ _onClick(!isCollapsed);
12
+ },
13
+ style: style
14
+ }, isCollapsed ? /*#__PURE__*/React.createElement(DoubleRightOutlined, null) : /*#__PURE__*/React.createElement(DoubleLeftOutlined, null));
15
+ };
@@ -0,0 +1,14 @@
1
+ @collapsed-icon-size: 36px;
2
+
3
+ .collapsed {
4
+ position: absolute;
5
+ z-index: 3;
6
+ width: 24px;
7
+ height: @collapsed-icon-size;
8
+ line-height: @collapsed-icon-size;
9
+ font-size: 18px;
10
+ color: #777;
11
+ cursor: pointer;
12
+ background: #f8f9fc;
13
+ text-align: center;
14
+ }
@@ -6,15 +6,19 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { Layout } from 'antd';
8
8
  import { useLocale, useSiteData } from 'dumi';
9
- import { get, find } from 'lodash-es';
10
- import React, { useContext, useEffect, useState, useMemo } from 'react';
9
+ import { every, find, get } from 'lodash-es';
10
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
11
11
  import { useLocation, useNavigate, useParams } from 'react-router-dom';
12
+ import { useSnapshot } from 'valtio';
12
13
  import { ThemeAntVContext } from "../../context";
14
+ import { store } from "../../model";
15
+ import { API } from "dumi/theme/slots/API";
13
16
  import { CodeRunner } from "dumi/theme/slots/CodeRunner";
14
17
  import { getDemoInfo } from "../../slots/CodeRunner/utils";
15
18
  import { ExampleSider } from "dumi/theme/slots/ExampleSider";
16
19
  import { Header } from "dumi/theme/slots/Header";
17
20
  import { SEO } from "dumi/theme/slots/SEO";
21
+ import { CollapsedIcon } from "./components/CollapsedIcon";
18
22
  import styles from "./index.module.less";
19
23
  import { getCurrentTitle } from "./utils";
20
24
  var Sider = Layout.Sider,
@@ -48,14 +52,11 @@ var Example = function Example() {
48
52
  _useState2 = _slicedToArray(_useState, 2),
49
53
  currentDemo = _useState2[0],
50
54
  setCurrentDemo = _useState2[1];
51
- var _useState3 = useState(false),
55
+ var state = useSnapshot(store);
56
+ var _useState3 = useState({}),
52
57
  _useState4 = _slicedToArray(_useState3, 2),
53
- isCollapsed = _useState4[0],
54
- setIsCollapsed = _useState4[1];
55
- var _useState5 = useState({}),
56
- _useState6 = _slicedToArray(_useState5, 2),
57
- title = _useState6[0],
58
- setTitle = _useState6[1];
58
+ title = _useState4[0],
59
+ setTitle = _useState4[1];
59
60
  useEffect(function () {
60
61
  if (topic && example && demo) {
61
62
  var targetDemoInfo = getDemoInfo(exampleTopics, topic, example, demo);
@@ -63,6 +64,7 @@ var Example = function Example() {
63
64
  setTitle(getCurrentTitle(exampleTopics, topic, example));
64
65
  }
65
66
  }, [topic, example, hash]);
67
+ var showAPI = every([get(themeConfig, 'showAPIDoc'), topic, example], Boolean);
66
68
  return /*#__PURE__*/React.createElement("div", {
67
69
  className: styles.example
68
70
  }, /*#__PURE__*/React.createElement(SEO, {
@@ -77,7 +79,7 @@ var Example = function Example() {
77
79
  width: 250,
78
80
  trigger: null,
79
81
  collapsible: true,
80
- collapsed: isCollapsed,
82
+ collapsed: state.hideMenu,
81
83
  className: styles.menuSider,
82
84
  theme: "light"
83
85
  }, currentDemo && /*#__PURE__*/React.createElement(ExampleSider, {
@@ -92,6 +94,15 @@ var Example = function Example() {
92
94
  nav(newURL);
93
95
  },
94
96
  exampleTopics: exampleTopics
97
+ }), /*#__PURE__*/React.createElement(CollapsedIcon, {
98
+ isCollapsed: state.hideMenu,
99
+ onClick: function onClick(show) {
100
+ store.hideMenu = show;
101
+ },
102
+ style: {
103
+ bottom: 0,
104
+ right: state.hideMenu ? -24 : 0
105
+ }
95
106
  })), /*#__PURE__*/React.createElement(Content, {
96
107
  className: styles.content
97
108
  }, topic && example && /*#__PURE__*/React.createElement(CodeRunner, {
@@ -100,6 +111,12 @@ var Example = function Example() {
100
111
  example: example,
101
112
  demo: demo,
102
113
  size: get(themeConfig, 'editor.size', 0.38)
103
- }))));
114
+ })), showAPI && /*#__PURE__*/React.createElement(API, {
115
+ exampleTopics: exampleTopics,
116
+ topic: topic,
117
+ example: example,
118
+ demo: demo,
119
+ language: locale.id
120
+ })));
104
121
  };
105
122
  export default Example;
@@ -2,8 +2,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  var _excluded = ["message", "bannerId", "localStorageId"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
8
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
9
  import React, { useEffect } from 'react';
@@ -2,8 +2,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import React from 'react';
8
8
  import { useLocale } from 'dumi';
9
9
  import { DemoCard } from "./DemoCard";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 获取API
3
+ *
4
+ * @param {string} apiPath API路径
5
+ * @returns {string} 文件内容
6
+ */
7
+ export declare const getExampleAPI: (apiPath: string) => string;
@@ -0,0 +1,82 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/plugin/api.ts
30
+ var api_exports = {};
31
+ __export(api_exports, {
32
+ getExampleAPI: () => getExampleAPI
33
+ });
34
+ module.exports = __toCommonJS(api_exports);
35
+ var fs = __toESM(require("fs-extra"));
36
+ var MARKDOWN_REG_SIGN = /`markdown:([^`]*)`/;
37
+ var EMBED_REG_SIGN = /<embed[^>]*src=["']([^"']*)["'][^>]*[>/>]/;
38
+ var getContent = (filePath) => {
39
+ let content = "";
40
+ try {
41
+ const currentContent = fs.readFileSync(filePath).toString();
42
+ const lines = currentContent.split("\n");
43
+ let isTitle = false;
44
+ lines.forEach((line) => {
45
+ if (line.startsWith("---")) {
46
+ isTitle = !isTitle;
47
+ } else {
48
+ if (!isTitle) {
49
+ let nestedPath = "";
50
+ const markdownMatch = MARKDOWN_REG_SIGN.exec(line);
51
+ const embedMatch = EMBED_REG_SIGN.exec(line);
52
+ if (markdownMatch) {
53
+ nestedPath = markdownMatch[1];
54
+ }
55
+ if (embedMatch) {
56
+ nestedPath = embedMatch[1].replace(/@\//g, "");
57
+ }
58
+ if (nestedPath) {
59
+ content += getContent(nestedPath);
60
+ } else {
61
+ content += `${line}
62
+ `;
63
+ }
64
+ }
65
+ }
66
+ });
67
+ } catch (e) {
68
+ console.error(e);
69
+ }
70
+ return content;
71
+ };
72
+ var getExampleAPI = (apiPath) => {
73
+ if (!fs.existsSync(apiPath)) {
74
+ console.error(`File does not exist: ${apiPath}`);
75
+ return "";
76
+ }
77
+ return getContent(apiPath);
78
+ };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ getExampleAPI
82
+ });
@@ -5,7 +5,7 @@ import { Example, ExampleTopic } from '../types';
5
5
  * @returns {ExampleTopic[]} 案例主题列表
6
6
  * @author YuZhanglong <loveyzl1123@gmail.com>
7
7
  */
8
- export declare const getExamplesPageTopics: (exampleTopics: ExampleTopic[]) => {
8
+ export declare const getExamplesPageTopics: (exampleTopics: ExampleTopic[], showAPIDoc: boolean) => {
9
9
  id: string;
10
10
  title: {
11
11
  zh: string;
@@ -33,10 +33,11 @@ __export(examples_exports, {
33
33
  getExamplesPageTopics: () => getExamplesPageTopics
34
34
  });
35
35
  module.exports = __toCommonJS(examples_exports);
36
+ var import_front_matter = __toESM(require("front-matter"));
37
+ var fs = __toESM(require("fs-extra"));
36
38
  var glob = __toESM(require("glob"));
37
39
  var path = __toESM(require("path"));
38
- var fs = __toESM(require("fs-extra"));
39
- var import_front_matter = __toESM(require("front-matter"));
40
+ var import_api = require("./api");
40
41
  var examplesBaseDir = path.resolve(process.cwd(), "examples");
41
42
  var getExampleDemos = (exampleDir) => {
42
43
  const demoMetaJSON = fs.readFileSync(path.resolve(exampleDir, "demo", "meta.json")).toString();
@@ -55,13 +56,20 @@ var getExampleDemos = (exampleDir) => {
55
56
  });
56
57
  return demos;
57
58
  };
58
- var getTopicExamples = (topicPath) => {
59
+ var getTopicExamples = (topicPath, showAPIDoc) => {
59
60
  const examplePaths = glob.sync(`${topicPath}/*`).filter((item) => {
60
61
  return !item.endsWith(".js");
61
62
  });
62
63
  return examplePaths.map((item) => {
63
64
  const exampleMetaZh = fs.readFileSync(path.resolve(item, "index.zh.md")).toString();
64
65
  const exampleMetaEn = fs.readFileSync(path.resolve(item, "index.en.md")).toString();
66
+ let api = null;
67
+ if (showAPIDoc) {
68
+ api = {
69
+ zh: (0, import_api.getExampleAPI)(path.resolve(item, "API.zh.md")),
70
+ en: (0, import_api.getExampleAPI)(path.resolve(item, "API.en.md"))
71
+ };
72
+ }
65
73
  const exampleMetaZhContent = (0, import_front_matter.default)(exampleMetaZh);
66
74
  const exampleMetaEnContent = (0, import_front_matter.default)(exampleMetaEn);
67
75
  const example = {
@@ -73,31 +81,30 @@ var getTopicExamples = (topicPath) => {
73
81
  en: exampleMetaEnContent.attributes.title,
74
82
  zh: exampleMetaZhContent.attributes.title
75
83
  },
84
+ api,
76
85
  childrenKey: "demos",
77
86
  order: exampleMetaZhContent.attributes.order || 0
78
87
  };
79
88
  return example;
80
89
  }).sort((a, b) => a.order - b.order);
81
90
  };
82
- var getExamplesPageTopics = (exampleTopics) => {
83
- return exampleTopics.map(
84
- ({ id, slug, title, icon }) => {
85
- const nid = id || slug;
86
- let examples = [];
87
- try {
88
- examples = getTopicExamples(path.join(examplesBaseDir, nid));
89
- } catch (e) {
90
- console.warn(e);
91
- }
92
- return {
93
- id: nid,
94
- title,
95
- icon,
96
- examples,
97
- childrenKey: "examples"
98
- };
91
+ var getExamplesPageTopics = (exampleTopics, showAPIDoc) => {
92
+ return exampleTopics.map(({ id, slug, title, icon }) => {
93
+ const nid = id || slug;
94
+ let examples = [];
95
+ try {
96
+ examples = getTopicExamples(path.join(examplesBaseDir, nid), showAPIDoc);
97
+ } catch (e) {
98
+ console.warn(e);
99
99
  }
100
- );
100
+ return {
101
+ id: nid,
102
+ title,
103
+ icon,
104
+ examples,
105
+ childrenKey: "examples"
106
+ };
107
+ });
101
108
  };
102
109
  function getExamplePaths() {
103
110
  const exampleTopicPaths = glob.sync(`${examplesBaseDir}/*/*`);
@@ -106,7 +106,8 @@ export default function ThemeAntVContextWrapper() {
106
106
  value={{
107
107
  meta: ${JSON.stringify({
108
108
  exampleTopics: (0, import_examples.getExamplesPageTopics)(
109
- api.config.themeConfig.examples || []
109
+ api.config.themeConfig.examples || [],
110
+ api.userConfig.themeConfig.showAPIDoc
110
111
  )
111
112
  })}
112
113
  }}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ExampleTopic } from '../../types';
3
+ type APIProps = {
4
+ isPlayground?: boolean;
5
+ topic: string;
6
+ example: string;
7
+ demo: string;
8
+ exampleTopics: ExampleTopic[];
9
+ language?: string;
10
+ };
11
+ /**
12
+ * API 预览
13
+ */
14
+ export declare const API: ({ exampleTopics, topic, example, demo, language, }: APIProps) => React.JSX.Element;
15
+ export {};