@antv/dumi-theme-antv 0.5.5-beta.1 → 0.5.6
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/hooks/useMenu.js +1 -11
- package/dist/plugin/index.js +0 -3
- package/dist/slots/Header/index.js +10 -4
- package/package.json +3 -4
- package/dist/plugin/antVReactTechStack.js +0 -101
package/dist/hooks/useMenu.js
CHANGED
|
@@ -106,15 +106,5 @@ export var useMenu = function useMenu() {
|
|
|
106
106
|
var flattedMenuData = useMemo(function () {
|
|
107
107
|
return flattenMenu(menuData);
|
|
108
108
|
}, [menuData]);
|
|
109
|
-
|
|
110
|
-
// 如果当前路径不在菜单中,选中第一个菜单项
|
|
111
|
-
if (!flattedMenuData.find(function (item) {
|
|
112
|
-
return item.link === selectedKey;
|
|
113
|
-
})) {
|
|
114
|
-
var firstValidMenuItem = flattedMenuData.find(function (item) {
|
|
115
|
-
return item.link;
|
|
116
|
-
});
|
|
117
|
-
navigate(firstValidMenuItem.link);
|
|
118
|
-
}
|
|
119
|
-
return [menuData, selectedKey, flattedMenuData];
|
|
109
|
+
return [menuData, pathname, flattedMenuData];
|
|
120
110
|
};
|
package/dist/plugin/index.js
CHANGED
|
@@ -34,7 +34,6 @@ __export(plugin_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(plugin_exports);
|
|
35
35
|
var import_plugin_utils = require("dumi/plugin-utils");
|
|
36
36
|
var path = __toESM(require("path"));
|
|
37
|
-
var import_antVReactTechStack = require("./antVReactTechStack");
|
|
38
37
|
var import_examples = require("./examples");
|
|
39
38
|
var import_rehypeObservable = __toESM(require("./rehypeObservable"));
|
|
40
39
|
var PAGES_DIR = (0, import_plugin_utils.winPath)(path.join(__dirname, "../pages"));
|
|
@@ -136,6 +135,4 @@ export default function ThemeAntVContextWrapper() {
|
|
|
136
135
|
return routes;
|
|
137
136
|
});
|
|
138
137
|
api.addTmpGenerateWatcherPaths(() => [path.resolve(process.cwd(), "examples")]);
|
|
139
|
-
console.log("api", api);
|
|
140
|
-
api.registerTechStack(() => new import_antVReactTechStack.AntVReactTechStack());
|
|
141
138
|
};
|
|
@@ -10,7 +10,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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; }
|
|
11
11
|
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; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
// import { navigate } from 'gatsby';
|
|
14
13
|
import { CaretDownFilled, CheckOutlined, DownOutlined, GithubOutlined, LinkOutlined, MenuOutlined, WechatOutlined } from '@ant-design/icons';
|
|
15
14
|
import { Alert, Button, Dropdown, Menu, Modal, Popover, Select } from 'antd';
|
|
16
15
|
import cx from 'classnames';
|
|
@@ -24,6 +23,8 @@ import { Navs } from "./Navs";
|
|
|
24
23
|
import { Products } from "./Products";
|
|
25
24
|
import { Search } from "./Search";
|
|
26
25
|
import { findVersion, getLangUrl } from "./utils";
|
|
26
|
+
import { Assistant } from '@petercatai/assistant';
|
|
27
|
+
import '@petercatai/assistant/style';
|
|
27
28
|
import styles from "./index.module.less";
|
|
28
29
|
function redirectChinaMirror(chinaMirrorOrigin) {
|
|
29
30
|
window.location.href = window.location.href.replace(window.location.origin, chinaMirrorOrigin);
|
|
@@ -454,7 +455,8 @@ export var Header = function Header(props) {
|
|
|
454
455
|
ecosystems = themeConfig.ecosystems,
|
|
455
456
|
navs = themeConfig.navs,
|
|
456
457
|
docsearchOptions = themeConfig.docsearchOptions,
|
|
457
|
-
announcement = themeConfig.announcement
|
|
458
|
+
announcement = themeConfig.announcement,
|
|
459
|
+
petercat = themeConfig.petercat;
|
|
458
460
|
var searchOptions = {
|
|
459
461
|
docsearchOptions: docsearchOptions
|
|
460
462
|
};
|
|
@@ -482,7 +484,11 @@ export var Header = function Header(props) {
|
|
|
482
484
|
searchOptions: searchOptions,
|
|
483
485
|
isHomePage: isHomePage,
|
|
484
486
|
transparent: isHomePage && isAntVSite,
|
|
485
|
-
announcement: announcement
|
|
487
|
+
announcement: announcement,
|
|
488
|
+
petercat: petercat
|
|
486
489
|
};
|
|
487
|
-
return /*#__PURE__*/React.createElement(HeaderComponent, Object.assign({}, headerProps, props))
|
|
490
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HeaderComponent, Object.assign({}, headerProps, props)), (petercat === null || petercat === void 0 ? void 0 : petercat.show) && /*#__PURE__*/React.createElement(Assistant, {
|
|
491
|
+
token: petercat === null || petercat === void 0 ? void 0 : petercat.token,
|
|
492
|
+
apiDomain: "https://api.petercat.ai"
|
|
493
|
+
}));
|
|
488
494
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/dumi-theme-antv",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "AntV website theme based on dumi2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dumi",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"d3-dsv": "^3.0.1",
|
|
57
57
|
"docsearch.js": "^2.6.3",
|
|
58
58
|
"front-matter": "^4.0.2",
|
|
59
|
+
"@petercatai/assistant": "^2.0.17",
|
|
59
60
|
"fs-extra": "^10.1.0",
|
|
60
61
|
"glob": "^8.1.0",
|
|
61
62
|
"hast": "^1.0.0",
|
|
@@ -84,7 +85,6 @@
|
|
|
84
85
|
"semver": "^7.6.3",
|
|
85
86
|
"size-sensor": "^1.0.2",
|
|
86
87
|
"slick-carousel": "^1.8.1",
|
|
87
|
-
"sylvanas": "^0.6.1",
|
|
88
88
|
"unified": "^10.1.2",
|
|
89
89
|
"unist-util-visit": "^4.1.2",
|
|
90
90
|
"uri-parse": "^1.0.0",
|
|
@@ -124,8 +124,7 @@
|
|
|
124
124
|
"react-dom": ">=16.9.0"
|
|
125
125
|
},
|
|
126
126
|
"publishConfig": {
|
|
127
|
-
"access": "public"
|
|
128
|
-
"tag": "beta"
|
|
127
|
+
"access": "public"
|
|
129
128
|
},
|
|
130
129
|
"authors": [
|
|
131
130
|
"dumi",
|
|
@@ -1,101 +0,0 @@
|
|
|
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/antVReactTechStack.ts
|
|
30
|
-
var antVReactTechStack_exports = {};
|
|
31
|
-
__export(antVReactTechStack_exports, {
|
|
32
|
-
AntVReactTechStack: () => AntVReactTechStack
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(antVReactTechStack_exports);
|
|
35
|
-
var import_react = __toESM(require("dumi/dist/techStacks/react"));
|
|
36
|
-
var import_fs = __toESM(require("fs"));
|
|
37
|
-
var import_sylvanas = __toESM(require("sylvanas"));
|
|
38
|
-
var import_package = require("../../package.json");
|
|
39
|
-
var AntVReactTechStack = class extends import_react.default {
|
|
40
|
-
generatePreviewerProps(...[props, opts]) {
|
|
41
|
-
var _a;
|
|
42
|
-
props.pkgDependencyList = { ...import_package.devDependencies, ...import_package.dependencies };
|
|
43
|
-
props.jsx ?? (props.jsx = "");
|
|
44
|
-
if (opts.type === "code-block") {
|
|
45
|
-
props.jsx = (opts == null ? void 0 : opts.entryPointCode) ? import_sylvanas.default.parseText(opts.entryPointCode) : "";
|
|
46
|
-
}
|
|
47
|
-
if (opts.type === "external") {
|
|
48
|
-
const locale = (_a = opts.mdAbsPath.match(/[a-z-]+\.([a-z-]+)\.md$/i)) == null ? void 0 : _a[1];
|
|
49
|
-
const mdPath = opts.fileAbsPath.replace(/\.\w+$/, ".md");
|
|
50
|
-
const md = import_fs.default.existsSync(mdPath) ? import_fs.default.readFileSync(mdPath, "utf-8") : "";
|
|
51
|
-
const codePath = opts.fileAbsPath.replace(/\.\w+$/, ".tsx");
|
|
52
|
-
const code = import_fs.default.existsSync(codePath) ? import_fs.default.readFileSync(codePath, "utf-8") : "";
|
|
53
|
-
props.jsx = import_sylvanas.default.parseText(code);
|
|
54
|
-
if (md) {
|
|
55
|
-
const blocks = {};
|
|
56
|
-
const lines = md.split("\n");
|
|
57
|
-
let blockName = "";
|
|
58
|
-
let cacheList = [];
|
|
59
|
-
const getBlockName = (text) => {
|
|
60
|
-
if (text.startsWith("## ")) {
|
|
61
|
-
return text.replace("## ", "").trim();
|
|
62
|
-
}
|
|
63
|
-
if (text.startsWith("```css") || text.startsWith("<style>")) {
|
|
64
|
-
return "style";
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
};
|
|
68
|
-
const fillBlock = (name, lineList) => {
|
|
69
|
-
if (lineList.length) {
|
|
70
|
-
let fullText;
|
|
71
|
-
if (name === "style") {
|
|
72
|
-
fullText = lineList.join("\n").replace(/<\/?style>/g, "").replace(/```(\s*css)/g, "");
|
|
73
|
-
} else {
|
|
74
|
-
fullText = lineList.slice(1).join("\n");
|
|
75
|
-
}
|
|
76
|
-
blocks[name] = fullText;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
for (let i = 0; i < lines.length; i++) {
|
|
80
|
-
const line = lines[i];
|
|
81
|
-
const nextBlockName = getBlockName(line);
|
|
82
|
-
if (nextBlockName) {
|
|
83
|
-
fillBlock(blockName, cacheList);
|
|
84
|
-
blockName = nextBlockName;
|
|
85
|
-
cacheList = [line];
|
|
86
|
-
} else {
|
|
87
|
-
cacheList.push(line);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
fillBlock(blockName, cacheList);
|
|
91
|
-
props.description = blocks[locale];
|
|
92
|
-
props.style = blocks.style;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return props;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
-
0 && (module.exports = {
|
|
100
|
-
AntVReactTechStack
|
|
101
|
-
});
|