@antv/dumi-theme-antv 0.5.3 → 0.5.4-beta.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.
- package/dist/builtins/Playground/index.js +1 -1
- package/dist/common/Link.js +78 -0
- package/dist/common/SEO.js +61 -0
- package/dist/hooks/useMenu.js +117 -0
- package/dist/layouts/DocLayout.js +6 -7
- package/dist/layouts/entry/API.js +1 -0
- package/dist/layouts/entry/Index.js +12 -25
- package/dist/layouts/entry/Manual.js +7 -5
- package/dist/pages/404.js +4 -5
- package/dist/pages/Example/index.js +6 -7
- package/dist/pages/Examples/index.js +6 -5
- package/dist/plugin/rehypeObservable.js +6 -3
- package/dist/slots/CodeEditor/index.js +1 -1
- package/dist/slots/CodeRunner/index.js +3 -3
- package/dist/slots/ManualContent/Main.js +90 -0
- package/dist/slots/ManualContent/Sidebar.js +77 -0
- package/dist/slots/ManualContent/index.js +8 -305
- package/dist/slots/ManualContent/index.module.less +63 -29
- package/dist/slots/ManualContent/utils.js +19 -15
- package/dist/slots/utils.js +7 -0
- package/dist/utils/menu.js +46 -0
- package/package.json +47 -43
- package/dist/builtins/Playground/index.d.ts +0 -21
- package/dist/context.d.ts +0 -6
- package/dist/layouts/DocLayout.d.ts +0 -7
- package/dist/layouts/entry/API.d.ts +0 -10
- package/dist/layouts/entry/Index.d.ts +0 -6
- package/dist/layouts/entry/Manual.d.ts +0 -8
- package/dist/model/index.d.ts +0 -5
- package/dist/pages/404.d.ts +0 -5
- package/dist/pages/Example/components/CollapsedIcon/index.d.ts +0 -8
- package/dist/pages/Example/index.d.ts +0 -6
- package/dist/pages/Example/utils.d.ts +0 -1
- package/dist/pages/Examples/components/Accouncement/index.d.ts +0 -6
- package/dist/pages/Examples/components/Article/index.d.ts +0 -2
- package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.d.ts +0 -10
- package/dist/pages/Examples/components/ExampleTopicMenu/index.d.ts +0 -9
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.d.ts +0 -10
- package/dist/pages/Examples/components/GalleryPageContent/index.d.ts +0 -10
- package/dist/pages/Examples/index.d.ts +0 -7
- package/dist/pages/Examples/types.d.ts +0 -34
- package/dist/pages/Examples/utils.d.ts +0 -1
- package/dist/plugin/api.d.ts +0 -7
- package/dist/plugin/examples.d.ts +0 -21
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/rehypeObservable.d.ts +0 -1
- package/dist/slots/404.d.ts +0 -1
- package/dist/slots/API/index.d.ts +0 -14
- package/dist/slots/Article/index.d.ts +0 -3
- package/dist/slots/Banner/Notification.d.ts +0 -10
- package/dist/slots/Banner/index.d.ts +0 -26
- package/dist/slots/Cases/index.d.ts +0 -19
- package/dist/slots/CodeEditor/Toolbar.d.ts +0 -72
- package/dist/slots/CodeEditor/index.d.ts +0 -62
- package/dist/slots/CodeEditor/utils.d.ts +0 -42
- package/dist/slots/CodePreview/CodeHeader.d.ts +0 -19
- package/dist/slots/CodePreview/index.d.ts +0 -25
- package/dist/slots/CodeRunner/index.d.ts +0 -17
- package/dist/slots/CodeRunner/utils.d.ts +0 -11
- package/dist/slots/Companies/index.d.ts +0 -13
- package/dist/slots/ContentTable/index.d.ts +0 -6
- package/dist/slots/Detail/News.d.ts +0 -12
- package/dist/slots/Detail/index.d.ts +0 -30
- package/dist/slots/ExampleSider/index.d.ts +0 -21
- package/dist/slots/Features/FeatureCard.d.ts +0 -9
- package/dist/slots/Features/index.d.ts +0 -15
- package/dist/slots/Footer/index.d.ts +0 -18
- package/dist/slots/Header/Navs.d.ts +0 -27
- package/dist/slots/Header/Products/NavigatorBanner.d.ts +0 -10
- package/dist/slots/Header/Products/Product.d.ts +0 -14
- package/dist/slots/Header/Products/getProducts.d.ts +0 -48
- package/dist/slots/Header/Products/index.d.ts +0 -10
- package/dist/slots/Header/Search/SearchResult.d.ts +0 -21
- package/dist/slots/Header/Search/helper.d.ts +0 -8
- package/dist/slots/Header/Search/index.d.ts +0 -1
- package/dist/slots/Header/index.d.ts +0 -84
- package/dist/slots/Header/utils.d.ts +0 -10
- package/dist/slots/Loading/index.d.ts +0 -5
- package/dist/slots/ManualContent/NavigatorBanner.d.ts +0 -9
- package/dist/slots/ManualContent/Preview.d.ts +0 -7
- package/dist/slots/ManualContent/ReadingTime.d.ts +0 -3
- package/dist/slots/ManualContent/index.d.ts +0 -9
- package/dist/slots/ManualContent/usePreview.d.ts +0 -1
- package/dist/slots/ManualContent/utils.d.ts +0 -19
- package/dist/slots/SEO.d.ts +0 -10
- package/dist/slots/SEO.js +0 -57
- package/dist/slots/global.d.ts +0 -1
- package/dist/slots/hooks.d.ts +0 -16
- package/dist/slots/utils.d.ts +0 -5
- package/dist/types.d.ts +0 -86
|
@@ -9,7 +9,7 @@ import { get } from 'lodash-es';
|
|
|
9
9
|
import React, { useContext } from 'react';
|
|
10
10
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
11
11
|
import { ThemeAntVContext } from "../../context";
|
|
12
|
-
import { CodeRunner } from "
|
|
12
|
+
import { CodeRunner } from "dumi/theme/slots/CodeRunner";
|
|
13
13
|
import styles from "./index.module.less";
|
|
14
14
|
/**
|
|
15
15
|
* Markdown 标签插件 Playground
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var _excluded = ["to", "children", "component"];
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
import { Link as DumiLink, useLocation, useNavigate } from 'dumi';
|
|
18
|
+
import nprogress from 'nprogress';
|
|
19
|
+
import React, { forwardRef, useLayoutEffect, useTransition } from 'react';
|
|
20
|
+
nprogress.configure({
|
|
21
|
+
showSpinner: false
|
|
22
|
+
});
|
|
23
|
+
var Link = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
24
|
+
var to = props.to,
|
|
25
|
+
children = props.children,
|
|
26
|
+
component = props.component,
|
|
27
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
28
|
+
var _useTransition = useTransition(),
|
|
29
|
+
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
30
|
+
isPending = _useTransition2[0],
|
|
31
|
+
startTransition = _useTransition2[1];
|
|
32
|
+
var navigate = useNavigate();
|
|
33
|
+
var _useLocation = useLocation(),
|
|
34
|
+
pathname = _useLocation.pathname;
|
|
35
|
+
var href = React.useMemo(function () {
|
|
36
|
+
if (_typeof(to) === 'object') {
|
|
37
|
+
return "".concat(to.pathname || pathname).concat(to.search || '').concat(to.hash || '');
|
|
38
|
+
}
|
|
39
|
+
return to;
|
|
40
|
+
}, [to]);
|
|
41
|
+
var handleClick = function handleClick(e) {
|
|
42
|
+
var _props$onClick;
|
|
43
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, e);
|
|
44
|
+
if (!(href !== null && href !== void 0 && href.startsWith('http'))) {
|
|
45
|
+
// Should support open in new tab
|
|
46
|
+
if (!e.metaKey && !e.ctrlKey && !e.shiftKey) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
startTransition(function () {
|
|
49
|
+
if (href) {
|
|
50
|
+
navigate(href);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
useLayoutEffect(function () {
|
|
57
|
+
if (isPending) {
|
|
58
|
+
nprogress.start();
|
|
59
|
+
} else {
|
|
60
|
+
nprogress.done();
|
|
61
|
+
}
|
|
62
|
+
}, [isPending]);
|
|
63
|
+
if (component) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(component, _objectSpread(_objectSpread({}, rest), {}, {
|
|
65
|
+
ref: ref,
|
|
66
|
+
onClick: handleClick,
|
|
67
|
+
href: href
|
|
68
|
+
}), children);
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/React.createElement(DumiLink, _extends({
|
|
71
|
+
ref: ref,
|
|
72
|
+
onClick: handleClick
|
|
73
|
+
}, rest, {
|
|
74
|
+
to: href,
|
|
75
|
+
prefetch: true
|
|
76
|
+
}), children);
|
|
77
|
+
});
|
|
78
|
+
export default Link;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
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; }
|
|
7
|
+
import { Helmet, useLocale, useRouteMeta, useSiteData } from 'dumi';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
var SEO = function SEO(_ref) {
|
|
10
|
+
var titleSuffix = _ref.titleSuffix,
|
|
11
|
+
propTitle = _ref.title,
|
|
12
|
+
propDescription = _ref.description,
|
|
13
|
+
_ref$meta = _ref.meta,
|
|
14
|
+
propMeta = _ref$meta === void 0 ? [] : _ref$meta;
|
|
15
|
+
var meta = useRouteMeta();
|
|
16
|
+
var locale = useLocale();
|
|
17
|
+
var lang = locale.id;
|
|
18
|
+
var _useSiteData = useSiteData(),
|
|
19
|
+
themeConfig = _useSiteData.themeConfig;
|
|
20
|
+
var defaultTitle = themeConfig.title,
|
|
21
|
+
defaultDescription = themeConfig.defaultDescription;
|
|
22
|
+
var title = propTitle || meta.frontmatter.title;
|
|
23
|
+
var description = propDescription || meta.frontmatter.description || defaultDescription;
|
|
24
|
+
var defaultMeta = [{
|
|
25
|
+
name: "description",
|
|
26
|
+
content: description
|
|
27
|
+
}, {
|
|
28
|
+
property: "og:title",
|
|
29
|
+
content: title
|
|
30
|
+
}, {
|
|
31
|
+
property: "og:description",
|
|
32
|
+
content: description
|
|
33
|
+
}, {
|
|
34
|
+
property: "og:image",
|
|
35
|
+
content: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png'
|
|
36
|
+
}, {
|
|
37
|
+
property: "og:type",
|
|
38
|
+
content: "website"
|
|
39
|
+
}, {
|
|
40
|
+
name: "twitter:card",
|
|
41
|
+
content: "summary"
|
|
42
|
+
}, {
|
|
43
|
+
name: "twitter:title",
|
|
44
|
+
content: title
|
|
45
|
+
}, {
|
|
46
|
+
name: "twitter:description",
|
|
47
|
+
content: description
|
|
48
|
+
}, {
|
|
49
|
+
property: "twitter:image",
|
|
50
|
+
content: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png'
|
|
51
|
+
}];
|
|
52
|
+
return /*#__PURE__*/React.createElement(Helmet, {
|
|
53
|
+
htmlAttributes: {
|
|
54
|
+
lang: lang
|
|
55
|
+
},
|
|
56
|
+
titleTemplate: "%s | ".concat(titleSuffix || defaultTitle),
|
|
57
|
+
title: title,
|
|
58
|
+
meta: [].concat(defaultMeta, _toConsumableArray(propMeta))
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export default SEO;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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(_e) { throw _e; }, 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(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
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); }
|
|
10
|
+
import { useFullSidebarData, useLocale, useLocation, useNavigate, useSiteData } from 'dumi';
|
|
11
|
+
import { get } from 'lodash-es';
|
|
12
|
+
import React, { useMemo } from 'react';
|
|
13
|
+
import Link from "../common/Link";
|
|
14
|
+
import styles from "../slots/ManualContent/index.module.less";
|
|
15
|
+
import { getBaseRoute } from "../slots/ManualContent/utils";
|
|
16
|
+
import { flattenMenu } from "../utils/menu";
|
|
17
|
+
export var useMenu = function useMenu() {
|
|
18
|
+
var fullData = useFullSidebarData();
|
|
19
|
+
var _useLocation = useLocation(),
|
|
20
|
+
pathname = _useLocation.pathname;
|
|
21
|
+
var _useSiteData = useSiteData(),
|
|
22
|
+
docs = _useSiteData.themeConfig.docs;
|
|
23
|
+
var baseRoute = getBaseRoute();
|
|
24
|
+
var navigate = useNavigate();
|
|
25
|
+
var locale = useLocale();
|
|
26
|
+
var currentLocale = locale.id;
|
|
27
|
+
var getMenuData = function getMenuData(fullData, rootList, hrefId) {
|
|
28
|
+
var fullSidebarDataToMenuData = function fullSidebarDataToMenuData(rootList, hrefId, list) {
|
|
29
|
+
// 递归
|
|
30
|
+
rootList.forEach(function (item) {
|
|
31
|
+
var href = (!baseRoute.startsWith('/en') ? "/".concat(item.slug) : "/en/".concat(item.slug)).toLocaleLowerCase();
|
|
32
|
+
var id = href.split('/').slice(0, href.split('/').length - 1).join('/');
|
|
33
|
+
if (href.includes(baseRoute)) {
|
|
34
|
+
if (id === hrefId) {
|
|
35
|
+
list.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
36
|
+
key: href,
|
|
37
|
+
label: item.title[currentLocale]
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _iterator = _createForOfIteratorHelper(list),
|
|
43
|
+
_step;
|
|
44
|
+
try {
|
|
45
|
+
var _loop = function _loop() {
|
|
46
|
+
var _fullData$item$key$0$;
|
|
47
|
+
var item = _step.value;
|
|
48
|
+
item.children = [];
|
|
49
|
+
fullSidebarDataToMenuData(rootList, item.key, item.children);
|
|
50
|
+
fullData[item.key] && ((_fullData$item$key$0$ = fullData[item.key][0].children) === null || _fullData$item$key$0$ === void 0 ? void 0 : _fullData$item$key$0$.forEach(function (itemChild) {
|
|
51
|
+
var label = itemChild.title;
|
|
52
|
+
var key = itemChild.link;
|
|
53
|
+
var tag = get(itemChild, ['frontmatter', 'tag']);
|
|
54
|
+
item.children.push(_objectSpread(_objectSpread({}, itemChild), {}, {
|
|
55
|
+
label: tag ? /*#__PURE__*/React.createElement(Link, {
|
|
56
|
+
to: key
|
|
57
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: styles.memuLabel
|
|
59
|
+
}, label, /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: styles.tag
|
|
61
|
+
}, tag))) : /*#__PURE__*/React.createElement(Link, {
|
|
62
|
+
to: key
|
|
63
|
+
}, label),
|
|
64
|
+
key: key
|
|
65
|
+
}));
|
|
66
|
+
}));
|
|
67
|
+
// children 的 order 排序
|
|
68
|
+
item.children.sort(function (a, b) {
|
|
69
|
+
return a.order - b.order;
|
|
70
|
+
});
|
|
71
|
+
if (item.children.length == 0) delete item.children;
|
|
72
|
+
};
|
|
73
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
74
|
+
_loop();
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
_iterator.e(err);
|
|
78
|
+
} finally {
|
|
79
|
+
_iterator.f();
|
|
80
|
+
}
|
|
81
|
+
if (hrefId === baseRoute) {
|
|
82
|
+
var _fullData$baseRoute$;
|
|
83
|
+
fullData[baseRoute] && ((_fullData$baseRoute$ = fullData[baseRoute][0].children) === null || _fullData$baseRoute$ === void 0 ? void 0 : _fullData$baseRoute$.forEach(function (itemChild) {
|
|
84
|
+
var key = itemChild.link;
|
|
85
|
+
var label = itemChild.title;
|
|
86
|
+
list.push(_objectSpread(_objectSpread({}, itemChild), {}, {
|
|
87
|
+
label: /*#__PURE__*/React.createElement(Link, {
|
|
88
|
+
to: key
|
|
89
|
+
}, label),
|
|
90
|
+
key: key
|
|
91
|
+
}));
|
|
92
|
+
}));
|
|
93
|
+
list.sort(function (a, b) {
|
|
94
|
+
return a.order - b.order;
|
|
95
|
+
});
|
|
96
|
+
return list;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return fullSidebarDataToMenuData(rootList, hrefId, []);
|
|
100
|
+
};
|
|
101
|
+
var menuData = useMemo(function () {
|
|
102
|
+
return getMenuData(fullData, docs, baseRoute);
|
|
103
|
+
}, [docs, baseRoute, fullData]);
|
|
104
|
+
|
|
105
|
+
// 将菜单数据扁平化
|
|
106
|
+
var flattedMenuData = useMemo(function () {
|
|
107
|
+
return flattenMenu(menuData);
|
|
108
|
+
}, [menuData]);
|
|
109
|
+
var selectedKey = pathname;
|
|
110
|
+
// 如果当前路径不在菜单中,选中第一个菜单项
|
|
111
|
+
if (!flattedMenuData.find(function (item) {
|
|
112
|
+
return item.link === selectedKey;
|
|
113
|
+
})) {
|
|
114
|
+
navigate(flattedMenuData[0].link);
|
|
115
|
+
}
|
|
116
|
+
return [menuData, selectedKey, flattedMenuData];
|
|
117
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { useLocation, useOutlet, useSiteData } from 'dumi';
|
|
1
2
|
import React, { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
+
import { getCurrentPathname } from "../slots/utils";
|
|
3
4
|
import { Index } from "./entry/Index";
|
|
4
5
|
import { Manual } from "./entry/Manual";
|
|
6
|
+
|
|
5
7
|
// 用户手动添加自己的
|
|
6
|
-
import "../slots/global";
|
|
7
8
|
import "../slots/_.less";
|
|
9
|
+
import "../slots/global";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* DocuLayout 是 dumi2 的内置 layout 入口,在这里使用页面路径进行区分成自己不同的 Layout。
|
|
@@ -17,11 +19,10 @@ export default (function () {
|
|
|
17
19
|
|
|
18
20
|
// 打印控制台文案
|
|
19
21
|
useEffect(function () {
|
|
20
|
-
console.log(
|
|
22
|
+
console.log('%cAntV 让数据栩栩如生', 'color:#5B7102; font-size: 20px;'), console.log('%c新一代数据可视化解决方案', 'color:#5B7102;'), console.log('--------------------------'), console.log('%c关注我们的微信公众号 %c“数据可视化 AntV”%c,获取我们团队最新的进展、动态、分享,也欢迎加入我们!', 'color: red', 'color: pink', 'color: red');
|
|
21
23
|
}, []);
|
|
22
24
|
var outlet = useOutlet();
|
|
23
25
|
var _useLocation = useLocation(),
|
|
24
|
-
pathname = _useLocation.pathname,
|
|
25
26
|
hash = _useLocation.hash;
|
|
26
27
|
|
|
27
28
|
// 监听 hash 变更,跳转到锚点位置
|
|
@@ -33,9 +34,7 @@ export default (function () {
|
|
|
33
34
|
if (elm) document.documentElement.scrollTo(0, elm.offsetTop - 80);
|
|
34
35
|
}
|
|
35
36
|
}, [loading, hash]);
|
|
36
|
-
var
|
|
37
|
-
// 统一去掉中英文前缀
|
|
38
|
-
var p = path.replace('/zh/', '/').replace('/en/', '/');
|
|
37
|
+
var p = getCurrentPathname();
|
|
39
38
|
// 首页
|
|
40
39
|
if (p === '/' || p === '/zh' || p === '/en' || p === '/en/') return /*#__PURE__*/React.createElement(Index, null);
|
|
41
40
|
|
|
@@ -4,16 +4,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
|
+
import { FormattedMessage, useSiteData } from 'dumi';
|
|
8
|
+
import { get, isArray, size } from 'lodash-es';
|
|
7
9
|
import React from 'react';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { Detail } from "
|
|
12
|
-
import { Features } from "
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { Footer } from "../../slots/Footer";
|
|
16
|
-
import { isArray, size, get } from 'lodash-es';
|
|
10
|
+
import SEO from "../../common/SEO";
|
|
11
|
+
import { Cases } from "dumi/theme/slots/Cases";
|
|
12
|
+
import { Companies } from "dumi/theme/slots/Companies";
|
|
13
|
+
import { Detail } from "dumi/theme/slots/Detail";
|
|
14
|
+
import { Features } from "dumi/theme/slots/Features";
|
|
15
|
+
import { Footer } from "dumi/theme/slots/Footer";
|
|
16
|
+
import { Header } from "dumi/theme/slots/Header";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Index 路由下的入口
|
|
@@ -21,23 +21,12 @@ import { isArray, size, get } from 'lodash-es';
|
|
|
21
21
|
* - 组合 slots 下的木偶组件
|
|
22
22
|
*/
|
|
23
23
|
export var Index = function Index() {
|
|
24
|
-
var locale = useLocale();
|
|
25
24
|
var _useSiteData = useSiteData(),
|
|
26
25
|
themeConfig = _useSiteData.themeConfig;
|
|
27
26
|
var title = themeConfig.title,
|
|
28
|
-
siteUrl = themeConfig.siteUrl,
|
|
29
27
|
githubUrl = themeConfig.githubUrl,
|
|
30
28
|
isAntVSite = themeConfig.isAntVSite,
|
|
31
|
-
showSearch = themeConfig.showSearch,
|
|
32
|
-
showGithubCorner = themeConfig.showGithubCorner,
|
|
33
29
|
showGithubStars = themeConfig.showGithubStars,
|
|
34
|
-
showLanguageSwitcher = themeConfig.showLanguageSwitcher,
|
|
35
|
-
showWxQrcode = themeConfig.showWxQrcode,
|
|
36
|
-
defaultLanguage = themeConfig.defaultLanguage,
|
|
37
|
-
showAntVProductsCard = themeConfig.showAntVProductsCard,
|
|
38
|
-
versions = themeConfig.versions,
|
|
39
|
-
ecosystems = themeConfig.ecosystems,
|
|
40
|
-
navs = themeConfig.navs,
|
|
41
30
|
detail = themeConfig.detail,
|
|
42
31
|
news = themeConfig.news,
|
|
43
32
|
companies = themeConfig.companies,
|
|
@@ -63,14 +52,12 @@ export var Index = function Index() {
|
|
|
63
52
|
style: style,
|
|
64
53
|
className: className
|
|
65
54
|
};
|
|
66
|
-
var metaTitle = detailProps.title;
|
|
67
55
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SEO, {
|
|
68
|
-
title:
|
|
69
|
-
titleSuffix: "AntV"
|
|
70
|
-
lang: locale.id
|
|
56
|
+
title: title,
|
|
57
|
+
titleSuffix: "AntV"
|
|
71
58
|
}), /*#__PURE__*/React.createElement(Header, null), size(detail) ? /*#__PURE__*/React.createElement(Detail, detailProps) : null, size(featuresProps.features) ? /*#__PURE__*/React.createElement(Features, featuresProps) : null, size(cases) ? /*#__PURE__*/React.createElement(Cases, casesProps) : null, size(companies) ? /*#__PURE__*/React.createElement(Companies, {
|
|
72
59
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
73
|
-
id: isAntVSite ?
|
|
60
|
+
id: isAntVSite ? '2000+ 公司正在使用' : '感谢信赖'
|
|
74
61
|
}),
|
|
75
62
|
companies: companies
|
|
76
63
|
}) : null, /*#__PURE__*/React.createElement(Footer, null));
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import SEO from "../../common/SEO";
|
|
3
|
+
import { Footer } from "dumi/theme/slots/Footer";
|
|
4
|
+
import { Header } from "dumi/theme/slots/Header";
|
|
5
|
+
import { ManualContent } from "dumi/theme/slots/ManualContent";
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Manual 路由下的入口
|
|
7
9
|
*/
|
|
8
10
|
export var Manual = function Manual(_ref) {
|
|
9
11
|
var children = _ref.children;
|
|
10
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
|
12
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SEO, null), /*#__PURE__*/React.createElement(Header, {
|
|
11
13
|
isHomePage: false
|
|
12
|
-
}), /*#__PURE__*/React.createElement(ManualContent, null,
|
|
14
|
+
}), /*#__PURE__*/React.createElement(ManualContent, null, children), /*#__PURE__*/React.createElement(Footer, {
|
|
13
15
|
isDynamicFooter: true
|
|
14
16
|
}));
|
|
15
17
|
};
|
package/dist/pages/404.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { NotFound as NotFoundPage } from "
|
|
3
|
-
import { Footer } from "
|
|
4
|
-
import { Header } from "
|
|
5
|
-
import
|
|
6
|
-
|
|
2
|
+
import { NotFound as NotFoundPage } from "dumi/theme/slots/404";
|
|
3
|
+
import { Footer } from "dumi/theme/slots/Footer";
|
|
4
|
+
import { Header } from "dumi/theme/slots/Header";
|
|
5
|
+
import SEO from "../common/SEO";
|
|
7
6
|
/**
|
|
8
7
|
* 404 页面
|
|
9
8
|
*/
|
|
@@ -10,14 +10,14 @@ import { every, find, get } from 'lodash-es';
|
|
|
10
10
|
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
11
11
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
12
12
|
import { useSnapshot } from 'valtio';
|
|
13
|
+
import SEO from "../../common/SEO";
|
|
13
14
|
import { ThemeAntVContext } from "../../context";
|
|
14
15
|
import { store } from "../../model";
|
|
15
|
-
import { API } from "
|
|
16
|
-
import { CodeRunner } from "
|
|
16
|
+
import { API } from "dumi/theme/slots/API";
|
|
17
|
+
import { CodeRunner } from "dumi/theme/slots/CodeRunner";
|
|
17
18
|
import { getDemoInfo } from "../../slots/CodeRunner/utils";
|
|
18
|
-
import { ExampleSider } from "
|
|
19
|
-
import { Header } from "
|
|
20
|
-
import { SEO } from "../../slots/SEO";
|
|
19
|
+
import { ExampleSider } from "dumi/theme/slots/ExampleSider";
|
|
20
|
+
import { Header } from "dumi/theme/slots/Header";
|
|
21
21
|
import { CollapsedIcon } from "./components/CollapsedIcon";
|
|
22
22
|
import styles from "./index.module.less";
|
|
23
23
|
import { getCurrentTitle } from "./utils";
|
|
@@ -68,8 +68,7 @@ var Example = function Example() {
|
|
|
68
68
|
return /*#__PURE__*/React.createElement("div", {
|
|
69
69
|
className: styles.example
|
|
70
70
|
}, /*#__PURE__*/React.createElement(SEO, {
|
|
71
|
-
title: title[locale.id]
|
|
72
|
-
lang: locale.id
|
|
71
|
+
title: title[locale.id]
|
|
73
72
|
}), /*#__PURE__*/React.createElement(Header, {
|
|
74
73
|
isHomePage: false
|
|
75
74
|
}), /*#__PURE__*/React.createElement(Layout, {
|
|
@@ -9,9 +9,8 @@ import { useContext, useEffect } from 'react';
|
|
|
9
9
|
import { useNavigate } from 'react-router-dom';
|
|
10
10
|
import { BackTop, Layout as AntLayout } from 'antd';
|
|
11
11
|
import { useLocale } from 'dumi';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { Footer } from "../../slots/Footer";
|
|
12
|
+
import { Header } from "dumi/theme/slots/Header";
|
|
13
|
+
import { Footer } from "dumi/theme/slots/Footer";
|
|
15
14
|
import NavigatorBanner from "../../slots/Header/Products/NavigatorBanner";
|
|
16
15
|
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
17
16
|
import { Article } from "./components/Article";
|
|
@@ -20,6 +19,7 @@ import { GalleryPageContent } from "./components/GalleryPageContent";
|
|
|
20
19
|
import { usePrevAndNext } from "../../slots/hooks";
|
|
21
20
|
import { ThemeAntVContext } from "../../context";
|
|
22
21
|
import styles from "./index.module.less";
|
|
22
|
+
import SEO from "../../common/SEO";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Examples 页面
|
|
@@ -39,7 +39,8 @@ var Example = function Example() {
|
|
|
39
39
|
var title = {
|
|
40
40
|
zh: '所有图表',
|
|
41
41
|
en: "Gallery"
|
|
42
|
-
};
|
|
42
|
+
}[locale.id];
|
|
43
|
+
|
|
43
44
|
// 为 zh 做兜底
|
|
44
45
|
useEffect(function () {
|
|
45
46
|
var p = window.location.pathname;
|
|
@@ -48,7 +49,7 @@ var Example = function Example() {
|
|
|
48
49
|
}
|
|
49
50
|
}, []);
|
|
50
51
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SEO, {
|
|
51
|
-
title: title
|
|
52
|
+
title: title
|
|
52
53
|
}), /*#__PURE__*/React.createElement(Header, {
|
|
53
54
|
isHomePage: false
|
|
54
55
|
}), /*#__PURE__*/React.createElement(AntLayout, {
|
|
@@ -37,15 +37,18 @@ var visit;
|
|
|
37
37
|
({ visit } = await import("unist-util-visit"));
|
|
38
38
|
})();
|
|
39
39
|
function isObservable(node) {
|
|
40
|
-
if (!node.data)
|
|
40
|
+
if (!node.data)
|
|
41
|
+
return;
|
|
41
42
|
const { meta } = node.data;
|
|
42
|
-
if (!meta)
|
|
43
|
+
if (!meta)
|
|
44
|
+
return;
|
|
43
45
|
return meta.match(/\|\s*ob\s*{*/);
|
|
44
46
|
}
|
|
45
47
|
function rehypeObservable() {
|
|
46
48
|
return async (tree) => {
|
|
47
49
|
visit(tree, "element", (node, i, parent) => {
|
|
48
|
-
if (!isObservable(node))
|
|
50
|
+
if (!isObservable(node))
|
|
51
|
+
return;
|
|
49
52
|
if (node.tagName === "SourceCode") {
|
|
50
53
|
parent.children.splice(i, 1, {
|
|
51
54
|
type: "element",
|
|
@@ -21,7 +21,7 @@ import { format } from 'prettier';
|
|
|
21
21
|
import parserBabel from 'prettier/parser-babel';
|
|
22
22
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
23
23
|
import { bind, clear } from 'size-sensor';
|
|
24
|
-
import Loading from "
|
|
24
|
+
import Loading from "dumi/theme/slots/Loading";
|
|
25
25
|
import { EDITOR_TABS, Toolbar } from "./Toolbar";
|
|
26
26
|
import styles from "./index.module.less";
|
|
27
27
|
import { compile, execute, replaceInsertCss } from "./utils";
|
|
@@ -8,11 +8,11 @@ import React, { useState } from 'react';
|
|
|
8
8
|
import { useSiteData, useLocale } from 'dumi';
|
|
9
9
|
import { noop } from 'lodash-es';
|
|
10
10
|
import SplitPane from 'react-split-pane';
|
|
11
|
-
import { CodeEditor } from "
|
|
12
|
-
import { CodePreview } from "
|
|
11
|
+
import { CodeEditor } from "dumi/theme/slots/CodeEditor";
|
|
12
|
+
import { CodePreview } from "dumi/theme/slots/CodePreview";
|
|
13
13
|
import { CodeHeader } from "../CodePreview/CodeHeader";
|
|
14
14
|
import { getDemoInfo } from "./utils";
|
|
15
|
-
import { NotFound } from "
|
|
15
|
+
import { NotFound } from "dumi/theme/slots/404";
|
|
16
16
|
import { ic } from "../hooks";
|
|
17
17
|
/**
|
|
18
18
|
* 代码编辑器 + 代码预览区域
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
8
|
+
import { BackTop, Layout } from 'antd';
|
|
9
|
+
import { useRouteMeta } from 'dumi';
|
|
10
|
+
import React, { useMemo } from 'react';
|
|
11
|
+
import { useMedia } from 'react-use';
|
|
12
|
+
import readingTime from 'reading-time';
|
|
13
|
+
import { useMenu } from "../../hooks/useMenu";
|
|
14
|
+
import { ContentTable } from "dumi/theme/slots/ContentTable";
|
|
15
|
+
import { NavigatorBanner } from "./NavigatorBanner";
|
|
16
|
+
import ReadingTime from "./ReadingTime";
|
|
17
|
+
import styles from "./index.module.less";
|
|
18
|
+
import { usePreview } from "./usePreview";
|
|
19
|
+
export var Main = function Main(_ref) {
|
|
20
|
+
var children = _ref.children;
|
|
21
|
+
var meta = useRouteMeta();
|
|
22
|
+
var text = meta.texts.reduce(function (prev, next) {
|
|
23
|
+
return prev + next.value;
|
|
24
|
+
}, '');
|
|
25
|
+
var _readingTime = readingTime(text),
|
|
26
|
+
time = _readingTime.time;
|
|
27
|
+
var _useMenu = useMenu(),
|
|
28
|
+
_useMenu2 = _slicedToArray(_useMenu, 3),
|
|
29
|
+
selectedKey = _useMenu2[1],
|
|
30
|
+
flattenMenuItems = _useMenu2[2];
|
|
31
|
+
var _useMemo = useMemo(function () {
|
|
32
|
+
if (!flattenMenuItems) {
|
|
33
|
+
return [undefined, undefined];
|
|
34
|
+
}
|
|
35
|
+
var activeMenuItemIndex = -1;
|
|
36
|
+
flattenMenuItems.forEach(function (menuItem, i) {
|
|
37
|
+
if (menuItem && menuItem.key === selectedKey) {
|
|
38
|
+
activeMenuItemIndex = i;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var prevItem = flattenMenuItems[activeMenuItemIndex - 1];
|
|
42
|
+
var nextItem = flattenMenuItems[activeMenuItemIndex + 1];
|
|
43
|
+
return [prevItem ? {
|
|
44
|
+
slug: prevItem.link,
|
|
45
|
+
title: prevItem.title
|
|
46
|
+
} : undefined, nextItem ? {
|
|
47
|
+
slug: nextItem.link,
|
|
48
|
+
title: nextItem.title
|
|
49
|
+
} : undefined];
|
|
50
|
+
}, [flattenMenuItems, selectedKey]),
|
|
51
|
+
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
52
|
+
prev = _useMemo2[0],
|
|
53
|
+
next = _useMemo2[1];
|
|
54
|
+
var is991Wide = useMedia('(min-width: 991.99px)', true);
|
|
55
|
+
var showToc = is991Wide && meta.frontmatter.showToc !== false;
|
|
56
|
+
usePreview({}, selectedKey);
|
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Layout.Content, {
|
|
58
|
+
className: styles.content
|
|
59
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: styles.main
|
|
61
|
+
}, /*#__PURE__*/React.createElement("h1", {
|
|
62
|
+
className: styles.contentTitle
|
|
63
|
+
}, meta.frontmatter.title), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: styles.readtimeContainer
|
|
65
|
+
}, /*#__PURE__*/React.createElement(ReadingTime, {
|
|
66
|
+
readingTime: time,
|
|
67
|
+
className: styles.readtime
|
|
68
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: styles.markdown
|
|
70
|
+
}, children), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: styles.preandnext
|
|
72
|
+
}, /*#__PURE__*/React.createElement(NavigatorBanner, {
|
|
73
|
+
type: "prev",
|
|
74
|
+
post: prev
|
|
75
|
+
}), /*#__PURE__*/React.createElement(NavigatorBanner, {
|
|
76
|
+
type: "next",
|
|
77
|
+
post: next
|
|
78
|
+
}), /*#__PURE__*/React.createElement(BackTop, {
|
|
79
|
+
style: {
|
|
80
|
+
right: 32
|
|
81
|
+
}
|
|
82
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: styles.backTop
|
|
84
|
+
}, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null))))))), showToc && /*#__PURE__*/React.createElement(Layout.Sider, {
|
|
85
|
+
theme: "light",
|
|
86
|
+
width: 260
|
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: styles.toc
|
|
89
|
+
}, /*#__PURE__*/React.createElement(ContentTable, null))));
|
|
90
|
+
};
|