@antv/dumi-theme-antv 0.2.2 → 0.3.0-beta.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.
- package/LICENSE +21 -0
- package/README.md +32 -33
- package/dist/builtins/Playground/index.d.ts +24 -0
- package/{es/builtins/Example.js → dist/builtins/Playground/index.js} +40 -33
- package/dist/builtins/Playground/index.module.less +15 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.js +2 -0
- package/dist/layouts/DocLayout.d.ts +7 -0
- package/dist/layouts/DocLayout.js +38 -0
- package/dist/layouts/entry/API.d.ts +10 -0
- package/dist/layouts/entry/API.js +12 -0
- package/dist/layouts/entry/Index.d.ts +7 -0
- package/dist/layouts/entry/Index.js +71 -0
- package/dist/layouts/entry/Manual.d.ts +8 -0
- package/dist/layouts/entry/Manual.js +14 -0
- package/dist/locales/en.json +98 -0
- package/dist/locales/zh.json +98 -0
- package/dist/pages/404.d.ts +6 -0
- package/dist/pages/404.js +14 -0
- package/dist/pages/Example/index.d.ts +6 -0
- package/dist/pages/Example/index.js +139 -0
- package/dist/pages/Example/index.module.less +40 -0
- package/dist/pages/Examples/components/Accouncement/index.d.ts +6 -0
- package/dist/pages/Examples/components/Accouncement/index.js +60 -0
- package/dist/pages/Examples/components/Accouncement/index.module.less +9 -0
- package/dist/pages/Examples/components/Article/index.d.ts +2 -0
- package/dist/pages/Examples/components/Article/index.js +8 -0
- package/dist/pages/Examples/components/Article/index.module.less +2 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.d.ts +10 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +74 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/index.d.ts +9 -0
- package/{es/builtins/Table.js → dist/pages/Examples/components/ExampleTopicMenu/index.js} +47 -41
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.d.ts +10 -0
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +33 -0
- package/dist/pages/Examples/components/GalleryPageContent/index.d.ts +10 -0
- package/dist/pages/Examples/components/GalleryPageContent/index.js +81 -0
- package/dist/pages/Examples/index.d.ts +8 -0
- package/dist/pages/Examples/index.js +75 -0
- package/dist/pages/Examples/index.module.less +605 -0
- package/dist/pages/Examples/types.d.ts +33 -0
- package/dist/pages/Examples/types.js +1 -0
- package/dist/plugin/examples.d.ts +7 -0
- package/dist/plugin/examples.js +83 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +103 -0
- package/dist/slots/404.d.ts +2 -0
- package/{es/antv/404/index.js → dist/slots/404.js} +4 -9
- package/{es/antv/Cases/Cases.d.ts → dist/slots/Cases/index.d.ts} +4 -4
- package/{es/antv/Cases/Cases.js → dist/slots/Cases/index.js} +25 -25
- package/{src/antv/Cases/Cases.module.less → dist/slots/Cases/index.module.less} +36 -5
- package/dist/slots/CodeEditor/Toolbar.d.ts +67 -0
- package/dist/slots/CodeEditor/Toolbar.js +152 -0
- package/dist/slots/CodeEditor/Toolbar.module.less +81 -0
- package/dist/slots/CodeEditor/index.d.ts +58 -0
- package/dist/slots/CodeEditor/index.js +200 -0
- package/dist/slots/CodeEditor/index.module.less +11 -0
- package/dist/slots/CodeEditor/utils.d.ts +42 -0
- package/dist/slots/CodeEditor/utils.js +157 -0
- package/dist/slots/CodePreview/CodeHeader.d.ts +19 -0
- package/dist/slots/CodePreview/CodeHeader.js +32 -0
- package/dist/slots/CodePreview/CodeHeader.module.less +0 -0
- package/dist/slots/CodePreview/index.d.ts +17 -0
- package/dist/slots/CodePreview/index.js +29 -0
- package/dist/slots/CodePreview/index.module.less +42 -0
- package/dist/slots/CodeRunner/index.d.ts +14 -0
- package/dist/slots/CodeRunner/index.js +76 -0
- package/dist/slots/CodeRunner/index.module.less +0 -0
- package/dist/slots/CodeRunner/utils.d.ts +10 -0
- package/dist/slots/CodeRunner/utils.js +36 -0
- package/dist/slots/Companies/index.d.ts +13 -0
- package/dist/slots/Companies/index.js +49 -0
- package/dist/slots/Companies/index.module.less +82 -0
- package/dist/slots/Detail/News.d.ts +9 -0
- package/{es/antv/Banner/Notification.js → dist/slots/Detail/News.js} +8 -11
- package/{src/antv/Banner/Notification.module.less → dist/slots/Detail/News.module.less} +15 -3
- package/dist/slots/Detail/index.d.ts +26 -0
- package/dist/slots/Detail/index.js +124 -0
- package/{src/antv/Banner/Banner.module.less → dist/slots/Detail/index.module.less} +42 -74
- package/dist/slots/ExampleSider/index.d.ts +55 -0
- package/dist/slots/ExampleSider/index.js +218 -0
- package/dist/slots/ExampleSider/index.module.less +141 -0
- package/{es/antv → dist/slots}/Features/FeatureCard.d.ts +1 -1
- package/{es/antv → dist/slots}/Features/FeatureCard.js +6 -6
- package/{src/antv → dist/slots}/Features/FeatureCard.module.less +8 -1
- package/{es/antv → dist/slots}/Features/index.d.ts +2 -2
- package/{es/antv → dist/slots}/Features/index.js +17 -25
- package/{src/antv/Features/Features.module.less → dist/slots/Features/index.module.less} +34 -3
- package/dist/slots/Footer/index.d.ts +18 -0
- package/dist/slots/Footer/index.js +187 -0
- package/dist/slots/Footer/index.module.less +85 -0
- package/dist/slots/Header/Logo.d.ts +7 -0
- package/{es/antv → dist/slots}/Header/Logo.js +6 -2
- package/dist/slots/Header/LogoWhite.d.ts +7 -0
- package/dist/slots/Header/LogoWhite.js +19 -0
- package/dist/slots/Header/Navs.d.ts +17 -0
- package/dist/slots/Header/Navs.js +46 -0
- package/dist/slots/Header/Products/NavigatorBanner.d.ts +10 -0
- package/dist/slots/Header/Products/NavigatorBanner.js +34 -0
- package/dist/slots/Header/Products/NavigatorBanner.module.less +39 -0
- package/{es/antv → dist/slots/Header}/Products/Product.d.ts +3 -3
- package/{es/antv → dist/slots/Header}/Products/Product.js +11 -16
- package/{src/antv → dist/slots/Header}/Products/Product.module.less +10 -8
- package/{es/antv → dist/slots/Header}/Products/getProducts.d.ts +2 -7
- package/dist/slots/Header/Products/getProducts.js +67 -0
- package/dist/slots/Header/Products/index.d.ts +9 -0
- package/{es/antv → dist/slots/Header}/Products/index.js +15 -22
- package/dist/slots/Header/Search.d.ts +12 -0
- package/dist/slots/Header/Search.js +90 -0
- package/dist/slots/Header/Search.module.less +39 -0
- package/dist/slots/Header/index.d.ts +66 -0
- package/dist/slots/Header/index.js +379 -0
- package/dist/slots/Header/index.module.less +382 -0
- package/dist/slots/Header/utils.d.ts +1 -0
- package/dist/slots/Header/utils.js +26 -0
- package/dist/slots/Loading/index.d.ts +2 -0
- package/dist/slots/Loading/index.js +65 -0
- package/dist/slots/Loading/index.module.less +12 -0
- package/dist/slots/Loading.d.ts +5 -0
- package/dist/slots/Loading.js +8 -0
- package/dist/slots/ManualContent/NavigatorBanner.d.ts +9 -0
- package/dist/slots/ManualContent/NavigatorBanner.js +36 -0
- package/dist/slots/ManualContent/NavigatorBanner.module.less +39 -0
- package/dist/slots/ManualContent/ReadingTime.d.ts +3 -0
- package/dist/slots/ManualContent/ReadingTime.js +10 -0
- package/dist/slots/ManualContent/index.d.ts +9 -0
- package/dist/slots/ManualContent/index.js +321 -0
- package/dist/slots/ManualContent/index.module.less +656 -0
- package/dist/slots/TOC.d.ts +5 -0
- package/dist/slots/TOC.js +6 -0
- package/dist/slots/_.less +83 -0
- package/dist/slots/global.d.ts +1 -0
- package/dist/slots/global.js +7 -0
- package/dist/slots/hooks.d.ts +16 -0
- package/{es/antv → dist/slots}/hooks.js +60 -37
- package/dist/slots/utils.d.ts +20 -0
- package/dist/slots/utils.js +154 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +1 -0
- package/dist/typings.d.ts +137 -0
- package/package.json +108 -47
- package/es/antv/404/index.d.ts +0 -2
- package/es/antv/Banner/Banner.module.less +0 -412
- package/es/antv/Banner/Notification.d.ts +0 -10
- package/es/antv/Banner/Notification.module.less +0 -108
- package/es/antv/Banner/index.d.ts +0 -25
- package/es/antv/Banner/index.js +0 -104
- package/es/antv/Cases/Cases.module.less +0 -203
- package/es/antv/Features/FeatureCard.module.less +0 -51
- package/es/antv/Features/Features.module.less +0 -169
- package/es/antv/Footer/Footer.module.less +0 -36
- package/es/antv/Footer/index.d.ts +0 -12
- package/es/antv/Footer/index.js +0 -237
- package/es/antv/Header/Logo.d.ts +0 -4
- package/es/antv/Products/Product.module.less +0 -146
- package/es/antv/Products/getNewProducts.d.ts +0 -24
- package/es/antv/Products/getNewProducts.js +0 -35
- package/es/antv/Products/getProducts.js +0 -460
- package/es/antv/Products/index.d.ts +0 -9
- package/es/antv/hooks.d.ts +0 -14
- package/es/antv/mixins.less +0 -21
- package/es/antv/utils.d.ts +0 -5
- package/es/antv/utils.js +0 -49
- package/es/builtins/API.d.ts +0 -3
- package/es/builtins/API.js +0 -37
- package/es/builtins/Alert.d.ts +0 -3
- package/es/builtins/Alert.js +0 -7
- package/es/builtins/Alert.less +0 -62
- package/es/builtins/Badge.d.ts +0 -3
- package/es/builtins/Badge.js +0 -7
- package/es/builtins/Badge.less +0 -31
- package/es/builtins/Example.d.ts +0 -5
- package/es/builtins/Example.less +0 -47
- package/es/builtins/Previewer.d.ts +0 -39
- package/es/builtins/Previewer.js +0 -225
- package/es/builtins/Previewer.less +0 -406
- package/es/builtins/SourceCode.d.ts +0 -10
- package/es/builtins/SourceCode.js +0 -70
- package/es/builtins/SourceCode.less +0 -103
- package/es/builtins/Table.d.ts +0 -4
- package/es/builtins/Table.less +0 -43
- package/es/builtins/Tree.d.ts +0 -4
- package/es/builtins/Tree.js +0 -213
- package/es/builtins/Tree.less +0 -159
- package/es/components/Dark.d.ts +0 -9
- package/es/components/Dark.js +0 -125
- package/es/components/Dark.less +0 -121
- package/es/components/LocaleSelect.d.ts +0 -6
- package/es/components/LocaleSelect.js +0 -53
- package/es/components/LocaleSelect.less +0 -59
- package/es/components/Navbar.d.ts +0 -10
- package/es/components/Navbar.js +0 -155
- package/es/components/Navbar.less +0 -180
- package/es/components/SearchBar.d.ts +0 -4
- package/es/components/SearchBar.js +0 -81
- package/es/components/SearchBar.less +0 -165
- package/es/components/SideMenu.d.ts +0 -10
- package/es/components/SideMenu.js +0 -99
- package/es/components/SideMenu.less +0 -379
- package/es/components/SlugList.d.ts +0 -7
- package/es/components/SlugList.js +0 -38
- package/es/components/SlugList.less +0 -18
- package/es/declaration.d.ts +0 -1
- package/es/layout.d.ts +0 -5
- package/es/layout.js +0 -276
- package/es/style/layout.less +0 -402
- package/es/style/markdown.less +0 -240
- package/es/style/variables.less +0 -37
- package/src/antv/404/index.tsx +0 -25
- package/src/antv/Banner/Notification.tsx +0 -45
- package/src/antv/Banner/index.tsx +0 -139
- package/src/antv/Cases/Cases.tsx +0 -116
- package/src/antv/Features/FeatureCard.tsx +0 -24
- package/src/antv/Features/index.tsx +0 -86
- package/src/antv/Footer/Footer.module.less +0 -36
- package/src/antv/Footer/index.tsx +0 -272
- package/src/antv/Header/Logo.tsx +0 -85
- package/src/antv/Products/Product.tsx +0 -80
- package/src/antv/Products/getNewProducts.tsx +0 -53
- package/src/antv/Products/getProducts.tsx +0 -626
- package/src/antv/Products/index.tsx +0 -70
- package/src/antv/hooks.ts +0 -87
- package/src/antv/mixins.less +0 -21
- package/src/antv/utils.ts +0 -44
- package/src/builtins/API.tsx +0 -57
- package/src/builtins/Alert.less +0 -62
- package/src/builtins/Alert.tsx +0 -4
- package/src/builtins/Badge.less +0 -31
- package/src/builtins/Badge.tsx +0 -4
- package/src/builtins/Example.less +0 -47
- package/src/builtins/Example.tsx +0 -34
- package/src/builtins/Previewer.less +0 -406
- package/src/builtins/Previewer.tsx +0 -264
- package/src/builtins/SourceCode.less +0 -103
- package/src/builtins/SourceCode.tsx +0 -55
- package/src/builtins/Table.less +0 -43
- package/src/builtins/Table.tsx +0 -42
- package/src/builtins/Tree.less +0 -159
- package/src/builtins/Tree.tsx +0 -130
- package/src/components/Dark.less +0 -121
- package/src/components/Dark.tsx +0 -78
- package/src/components/LocaleSelect.less +0 -59
- package/src/components/LocaleSelect.tsx +0 -53
- package/src/components/Navbar.less +0 -180
- package/src/components/Navbar.tsx +0 -152
- package/src/components/SearchBar.less +0 -165
- package/src/components/SearchBar.tsx +0 -68
- package/src/components/SideMenu.less +0 -379
- package/src/components/SideMenu.tsx +0 -148
- package/src/components/SlugList.less +0 -18
- package/src/components/SlugList.tsx +0 -20
- package/src/declaration.d.ts +0 -1
- package/src/layout.tsx +0 -225
- package/src/style/layout.less +0 -402
- package/src/style/markdown.less +0 -240
- package/src/style/variables.less +0 -37
- package/src/test/SearchBar.test.ts +0 -32
- package/src/test/Table.test.tsx +0 -41
- package/src/test/index.test.tsx +0 -377
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
|
|
15
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
|
|
19
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
|
|
21
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
22
|
+
|
|
23
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
24
|
+
|
|
25
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
26
|
+
|
|
27
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
+
|
|
29
|
+
import React, { useEffect, useState } from 'react';
|
|
30
|
+
import { Layout, Affix, BackTop, Menu, Tooltip } from 'antd';
|
|
31
|
+
import { useMedia } from 'react-use';
|
|
32
|
+
import Drawer from 'rc-drawer';
|
|
33
|
+
import { useLocale, useSiteData, useFullSidebarData, useRouteMeta } from 'dumi';
|
|
34
|
+
import { useNavigate } from "react-router-dom";
|
|
35
|
+
import { EditOutlined, MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
36
|
+
import readingTime from 'reading-time';
|
|
37
|
+
import { NavigatorBanner } from "./NavigatorBanner";
|
|
38
|
+
import ReadingTime from "./ReadingTime";
|
|
39
|
+
import { TOC } from "../TOC";
|
|
40
|
+
import { useScrollToTop } from "../hooks";
|
|
41
|
+
import 'rc-drawer/assets/index.css';
|
|
42
|
+
import styles from "./index.module.less";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 文档的结构
|
|
46
|
+
*/
|
|
47
|
+
export var ManualContent = function ManualContent(_ref) {
|
|
48
|
+
var children = _ref.children;
|
|
49
|
+
var locale = useLocale();
|
|
50
|
+
var currentLocale = locale.id;
|
|
51
|
+
|
|
52
|
+
var _useSiteData = useSiteData(),
|
|
53
|
+
_useSiteData$themeCon = _useSiteData.themeConfig,
|
|
54
|
+
githubUrl = _useSiteData$themeCon.githubUrl,
|
|
55
|
+
relativePath = _useSiteData$themeCon.relativePath,
|
|
56
|
+
docs = _useSiteData$themeCon.docs;
|
|
57
|
+
|
|
58
|
+
var sidebar = useFullSidebarData();
|
|
59
|
+
var isWide = useMedia('(min-width: 767.99px)', true);
|
|
60
|
+
|
|
61
|
+
var _useState = useState(false),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
drawOpen = _useState2[0],
|
|
64
|
+
setDrawOpen = _useState2[1];
|
|
65
|
+
|
|
66
|
+
var navigate = useNavigate(); // 获取阅读时间
|
|
67
|
+
|
|
68
|
+
var mdInfo = useRouteMeta();
|
|
69
|
+
var text = mdInfo.texts.reduce(function (prev, next) {
|
|
70
|
+
return prev + next.value;
|
|
71
|
+
}, '');
|
|
72
|
+
|
|
73
|
+
var _readingTime = readingTime(text),
|
|
74
|
+
time = _readingTime.time; // menu渲染
|
|
75
|
+
// linkoTitle用来映射路由和Title
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
var linkoTitle = {};
|
|
79
|
+
|
|
80
|
+
function getBaseRoute() {
|
|
81
|
+
var matchRoute = window.location.pathname;
|
|
82
|
+
var reg = window.location.pathname.startsWith('/en') ? /(\/[A-z]*\/?\/[A-z]*)\/?/ : /(\/[A-z]*)\/?/;
|
|
83
|
+
var mainRoute = matchRoute.match(reg);
|
|
84
|
+
return mainRoute[1];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var baseRoute = getBaseRoute();
|
|
88
|
+
|
|
89
|
+
function fullSidebarDataToMenuData(rootList, hrefId, list) {
|
|
90
|
+
// 递归
|
|
91
|
+
rootList.forEach(function (item) {
|
|
92
|
+
var href = !baseRoute.startsWith('/en') ? "/".concat(item.slug) : "/en/".concat(item.slug);
|
|
93
|
+
var id = href.split("/").slice(0, href.split("/").length - 1).join("/");
|
|
94
|
+
|
|
95
|
+
if (href.includes(baseRoute)) {
|
|
96
|
+
if (id === hrefId) {
|
|
97
|
+
list.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
98
|
+
key: href,
|
|
99
|
+
label: item.title[currentLocale]
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
var _iterator = _createForOfIteratorHelper(list),
|
|
106
|
+
_step;
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
var _loop = function _loop() {
|
|
110
|
+
var _sidebar$item$key$0$c;
|
|
111
|
+
|
|
112
|
+
var item = _step.value;
|
|
113
|
+
item.children = [];
|
|
114
|
+
fullSidebarDataToMenuData(rootList, item.key, item.children);
|
|
115
|
+
(_sidebar$item$key$0$c = sidebar[item.key][0].children) === null || _sidebar$item$key$0$c === void 0 ? void 0 : _sidebar$item$key$0$c.forEach(function (itemChild) {
|
|
116
|
+
var label = itemChild.title;
|
|
117
|
+
var key = itemChild.link;
|
|
118
|
+
item.children.push(_objectSpread(_objectSpread({}, itemChild), {}, {
|
|
119
|
+
label: label,
|
|
120
|
+
key: key
|
|
121
|
+
}));
|
|
122
|
+
linkoTitle[key] = label;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
if (item.children.length == 0) {
|
|
126
|
+
delete item.children;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
131
|
+
_loop();
|
|
132
|
+
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
_iterator.e(err);
|
|
135
|
+
} finally {
|
|
136
|
+
_iterator.f();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (hrefId == baseRoute) {
|
|
140
|
+
var _sidebar$baseRoute$0$;
|
|
141
|
+
|
|
142
|
+
sidebar[baseRoute] && ((_sidebar$baseRoute$0$ = sidebar[baseRoute][0].children) === null || _sidebar$baseRoute$0$ === void 0 ? void 0 : _sidebar$baseRoute$0$.forEach(function (itemChild) {
|
|
143
|
+
var label = itemChild.title;
|
|
144
|
+
list.push(_objectSpread(_objectSpread({}, itemChild), {}, {
|
|
145
|
+
label: label,
|
|
146
|
+
key: itemChild.link
|
|
147
|
+
}));
|
|
148
|
+
}));
|
|
149
|
+
list.sort(function (a, b) {
|
|
150
|
+
return a.order - b.order;
|
|
151
|
+
});
|
|
152
|
+
return list;
|
|
153
|
+
}
|
|
154
|
+
} // 获取最终的MenuData
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
var renderSidebar = fullSidebarDataToMenuData(docs, baseRoute, []); // 获取默认打开的菜单栏
|
|
158
|
+
|
|
159
|
+
function getDefaultOpenKeys(MenuData) {
|
|
160
|
+
var defaultOpenKeys = [];
|
|
161
|
+
var topRoute = MenuData[0];
|
|
162
|
+
defaultOpenKeys.push(topRoute.key);
|
|
163
|
+
|
|
164
|
+
while (topRoute.children) {
|
|
165
|
+
topRoute = topRoute.children[0];
|
|
166
|
+
defaultOpenKeys.push(topRoute.key);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return defaultOpenKeys;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var defaultOpenKeys = getDefaultOpenKeys(renderSidebar); // 点击菜单栏
|
|
173
|
+
|
|
174
|
+
var onClick = function onClick(e) {
|
|
175
|
+
navigate(e.key);
|
|
176
|
+
useScrollToTop();
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
var _useState3 = useState([renderSidebar[0].key]),
|
|
180
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
181
|
+
defaultSelectedKey = _useState4[0],
|
|
182
|
+
setDefaultSelectedKey = _useState4[1]; //上一夜下一页
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
var _useState5 = useState(undefined),
|
|
186
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
187
|
+
prev = _useState6[0],
|
|
188
|
+
setPrev = _useState6[1];
|
|
189
|
+
|
|
190
|
+
var _useState7 = useState(undefined),
|
|
191
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
192
|
+
next = _useState8[0],
|
|
193
|
+
setNext = _useState8[1]; // 监听路由去改变selected menu-item
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
useEffect(function () {
|
|
197
|
+
if (window.location.pathname == baseRoute) {
|
|
198
|
+
navigate(renderSidebar[0].key);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
setDefaultSelectedKey([window.location.pathname]);
|
|
203
|
+
}, [window.location.pathname]);
|
|
204
|
+
useEffect(function () {
|
|
205
|
+
// 监听选中的menu-item 拿到 prev and next
|
|
206
|
+
getPreAndNext();
|
|
207
|
+
}, [defaultSelectedKey]);
|
|
208
|
+
|
|
209
|
+
function getPreAndNext() {
|
|
210
|
+
var menuNodes = document.querySelectorAll('aside .ant-menu-item');
|
|
211
|
+
var currentMenuNode = document.querySelector('aside .ant-menu-item-selected'); // @ts-ignore
|
|
212
|
+
|
|
213
|
+
var currentIndex = Array.from(menuNodes).findIndex(function (node) {
|
|
214
|
+
return node === currentMenuNode;
|
|
215
|
+
});
|
|
216
|
+
var prevNode = currentIndex - 1 >= 0 ? menuNodes[currentIndex - 1] : undefined;
|
|
217
|
+
var nextNode = currentIndex + 1 < menuNodes.length ? menuNodes[currentIndex + 1] : undefined;
|
|
218
|
+
setPrev(prevNode ? {
|
|
219
|
+
slug: prevNode.getAttribute('link') || undefined,
|
|
220
|
+
title: prevNode.textContent || undefined
|
|
221
|
+
} : undefined);
|
|
222
|
+
setNext(nextNode ? {
|
|
223
|
+
slug: nextNode.getAttribute('link') || undefined,
|
|
224
|
+
title: nextNode.textContent || undefined
|
|
225
|
+
} : undefined);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var getGithubSourceUrl = function getGithubSourceUrl(_ref2) {
|
|
229
|
+
var githubUrl = _ref2.githubUrl,
|
|
230
|
+
relativePath = _ref2.relativePath,
|
|
231
|
+
prefix = _ref2.prefix;
|
|
232
|
+
|
|
233
|
+
// https://github.com/antvis/x6/tree/master/packages/x6-sites
|
|
234
|
+
if (githubUrl.includes('/tree/master/')) {
|
|
235
|
+
return "".concat(githubUrl.replace('/tree/master/', '/edit/master/'), "/").concat(prefix, "/").concat(relativePath);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return "".concat(githubUrl, "/edit/master/").concat(prefix, "/").concat(relativePath);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
var menu = /*#__PURE__*/React.createElement(Menu, {
|
|
242
|
+
onClick: onClick,
|
|
243
|
+
defaultSelectedKeys: defaultSelectedKey,
|
|
244
|
+
selectedKeys: defaultSelectedKey,
|
|
245
|
+
defaultOpenKeys: _toConsumableArray(defaultOpenKeys),
|
|
246
|
+
mode: "inline",
|
|
247
|
+
items: renderSidebar,
|
|
248
|
+
inlineIndent: 16,
|
|
249
|
+
style: {
|
|
250
|
+
height: '100%'
|
|
251
|
+
},
|
|
252
|
+
forceSubMenuRender: true
|
|
253
|
+
});
|
|
254
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Layout, {
|
|
255
|
+
style: {
|
|
256
|
+
background: '#fff'
|
|
257
|
+
},
|
|
258
|
+
hasSider: true,
|
|
259
|
+
className: styles.layout
|
|
260
|
+
}, /*#__PURE__*/React.createElement(Affix, {
|
|
261
|
+
offsetTop: 0,
|
|
262
|
+
className: styles.affix,
|
|
263
|
+
style: {
|
|
264
|
+
height: isWide ? '100vh' : 'inherit'
|
|
265
|
+
}
|
|
266
|
+
}, isWide ? /*#__PURE__*/React.createElement(Layout.Sider, {
|
|
267
|
+
width: "auto",
|
|
268
|
+
theme: "light",
|
|
269
|
+
className: styles.sider
|
|
270
|
+
}, menu) : /*#__PURE__*/React.createElement(Drawer, {
|
|
271
|
+
handler: drawOpen ? /*#__PURE__*/React.createElement(MenuFoldOutlined, {
|
|
272
|
+
className: styles.menuSwitch
|
|
273
|
+
}) : /*#__PURE__*/React.createElement(MenuUnfoldOutlined, {
|
|
274
|
+
className: styles.menuSwitch
|
|
275
|
+
}),
|
|
276
|
+
wrapperClassName: styles.menuDrawer,
|
|
277
|
+
onChange: function onChange(open) {
|
|
278
|
+
return setDrawOpen(!!open);
|
|
279
|
+
},
|
|
280
|
+
width: 280
|
|
281
|
+
}, menu)), /*#__PURE__*/React.createElement(Layout.Content, {
|
|
282
|
+
className: styles.content
|
|
283
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
284
|
+
className: styles.contentMain
|
|
285
|
+
}, /*#__PURE__*/React.createElement("h1", null, linkoTitle[window.location.pathname], /*#__PURE__*/React.createElement(Tooltip, {
|
|
286
|
+
title: '在 GitHub 上编辑'
|
|
287
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
288
|
+
href: getGithubSourceUrl({
|
|
289
|
+
githubUrl: githubUrl,
|
|
290
|
+
relativePath: relativePath,
|
|
291
|
+
prefix: 'docs'
|
|
292
|
+
}),
|
|
293
|
+
target: "_blank",
|
|
294
|
+
rel: "noopener noreferrer",
|
|
295
|
+
className: styles.editOnGtiHubButton
|
|
296
|
+
}, /*#__PURE__*/React.createElement(EditOutlined, null)))), /*#__PURE__*/React.createElement(ReadingTime, {
|
|
297
|
+
readingTime: time,
|
|
298
|
+
className: styles.readtime
|
|
299
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
300
|
+
className: styles.markdown
|
|
301
|
+
}, children), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
302
|
+
className: styles.preandnext
|
|
303
|
+
}, /*#__PURE__*/React.createElement(NavigatorBanner, {
|
|
304
|
+
type: "prev",
|
|
305
|
+
post: prev
|
|
306
|
+
}), /*#__PURE__*/React.createElement(NavigatorBanner, {
|
|
307
|
+
type: "next",
|
|
308
|
+
post: next
|
|
309
|
+
}), /*#__PURE__*/React.createElement(BackTop, {
|
|
310
|
+
style: {
|
|
311
|
+
right: 32
|
|
312
|
+
}
|
|
313
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
314
|
+
className: styles.backTop
|
|
315
|
+
}, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null))))))), /*#__PURE__*/React.createElement(Layout.Sider, {
|
|
316
|
+
theme: "light",
|
|
317
|
+
width: 260
|
|
318
|
+
}, /*#__PURE__*/React.createElement(Affix, {
|
|
319
|
+
className: styles.toc
|
|
320
|
+
}, /*#__PURE__*/React.createElement(TOC, null)))));
|
|
321
|
+
};
|