@antv/dumi-theme-antv 0.5.5-beta.0 → 0.5.5
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/package.json +3 -5
- 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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/dumi-theme-antv",
|
|
3
|
-
"version": "0.5.5
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "AntV website theme based on dumi2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dumi",
|
|
@@ -115,8 +115,7 @@
|
|
|
115
115
|
"lint-staged": "^13.3.0",
|
|
116
116
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
117
117
|
"prettier-plugin-packagejson": "^2.5.3",
|
|
118
|
-
"stylelint": "^14.16.1"
|
|
119
|
-
"sylvanas": "^0.6.1"
|
|
118
|
+
"stylelint": "^14.16.1"
|
|
120
119
|
},
|
|
121
120
|
"peerDependencies": {
|
|
122
121
|
"dumi": "^2.0.0",
|
|
@@ -124,8 +123,7 @@
|
|
|
124
123
|
"react-dom": ">=16.9.0"
|
|
125
124
|
},
|
|
126
125
|
"publishConfig": {
|
|
127
|
-
"access": "public"
|
|
128
|
-
"tag": "beta"
|
|
126
|
+
"access": "public"
|
|
129
127
|
},
|
|
130
128
|
"authors": [
|
|
131
129
|
"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
|
-
});
|