@antv/dumi-theme-antv 0.3.0-beta.1 → 0.3.0-beta.3
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/pages/404.js +1 -0
- package/dist/plugin/examples.d.ts +6 -1
- package/dist/plugin/examples.js +16 -8
- package/dist/plugin/index.js +14 -17
- package/dist/plugin/utils.d.ts +5 -0
- package/dist/plugin/utils.js +46 -0
- package/dist/slots/CodePreview/index.module.less +4 -1
- package/dist/slots/ExampleSider/index.js +1 -1
- package/dist/typings.d.ts +5 -2
- package/package.json +1 -1
package/dist/pages/404.js
CHANGED
|
@@ -4,4 +4,9 @@
|
|
|
4
4
|
* @returns {ExamplesPage.ExampleTopic[]} 案例主题列表
|
|
5
5
|
* @author YuZhanglong <loveyzl1123@gmail.com>
|
|
6
6
|
*/
|
|
7
|
-
export declare const getExamplesPageTopics: (
|
|
7
|
+
export declare const getExamplesPageTopics: (exampleTopics: ExamplesPage.ExampleTopic[]) => {
|
|
8
|
+
id: string;
|
|
9
|
+
title: ExamplesPage.ExampleTopic;
|
|
10
|
+
icon: ExamplesPage.ExampleTopic;
|
|
11
|
+
examples: ExamplesPage.Example[];
|
|
12
|
+
}[];
|
package/dist/plugin/examples.js
CHANGED
|
@@ -35,7 +35,7 @@ var getExampleDemos = (exampleDir) => {
|
|
|
35
35
|
const demoMeta = JSON.parse(demoMetaJSON).demos;
|
|
36
36
|
const demos = demoMeta.map((item) => {
|
|
37
37
|
const { title, screenshot, filename, new: isNew } = item;
|
|
38
|
-
const id = filename.replace(/\.tsx?$/, "");
|
|
38
|
+
const id = filename.replace(/\.tsx?$/, "").replace(/\.ts?$/, "").replace(/\.jsx?$/, "").replace(/\.js?$/, "");
|
|
39
39
|
return {
|
|
40
40
|
id,
|
|
41
41
|
screenshot,
|
|
@@ -68,13 +68,21 @@ var getTopicExamples = (topicPath) => {
|
|
|
68
68
|
return example;
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
|
-
var getExamplesPageTopics = () => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
var getExamplesPageTopics = (exampleTopics) => {
|
|
72
|
+
return exampleTopics.map(({ id, slug, title, icon }) => {
|
|
73
|
+
const nid = id || slug;
|
|
74
|
+
let examples = [];
|
|
75
|
+
try {
|
|
76
|
+
examples = getTopicExamples(path.join(examplesBaseDir, nid));
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.warn(e);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
id: nid,
|
|
82
|
+
title,
|
|
83
|
+
icon,
|
|
84
|
+
examples
|
|
85
|
+
};
|
|
78
86
|
});
|
|
79
87
|
};
|
|
80
88
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
18
|
|
|
22
19
|
// src/plugin/index.ts
|
|
@@ -26,52 +23,52 @@ __export(plugin_exports, {
|
|
|
26
23
|
});
|
|
27
24
|
module.exports = __toCommonJS(plugin_exports);
|
|
28
25
|
var import_examples = require("./examples");
|
|
29
|
-
|
|
30
|
-
const res = (0, import_examples.getExamplesPageTopics)();
|
|
31
|
-
return {
|
|
32
|
-
exampleTopics: res
|
|
33
|
-
};
|
|
34
|
-
}
|
|
26
|
+
var import_utils = require("./utils");
|
|
35
27
|
var plugin_default = (api) => {
|
|
36
28
|
api.describe({ key: `dumi-theme:${require("../../package.json").name}` });
|
|
37
29
|
const pages = [
|
|
38
30
|
{
|
|
39
31
|
id: "dumi-theme-antv-example-list-zh",
|
|
40
32
|
path: "/examples/",
|
|
41
|
-
file:
|
|
33
|
+
file: (0, import_utils.myResolve)("../pages/Examples/index.tsx")
|
|
42
34
|
},
|
|
43
35
|
{
|
|
44
36
|
id: "dumi-theme-antv-example-list-lang",
|
|
45
37
|
path: "/:language/examples/",
|
|
46
|
-
file:
|
|
38
|
+
file: (0, import_utils.myResolve)("../pages/Examples/index.tsx")
|
|
47
39
|
},
|
|
48
40
|
{
|
|
49
41
|
id: "dumi-theme-antv-single-example-zh",
|
|
50
42
|
path: "/examples/:topic/:example",
|
|
51
|
-
file:
|
|
43
|
+
file: (0, import_utils.myResolve)("../pages/Example/index.tsx")
|
|
52
44
|
},
|
|
53
45
|
{
|
|
54
46
|
id: "dumi-theme-antv-single-example-lang",
|
|
55
47
|
path: "/:language/examples/:topic/:example",
|
|
56
|
-
file:
|
|
48
|
+
file: (0, import_utils.myResolve)("../pages/Example/index.tsx")
|
|
57
49
|
}
|
|
58
50
|
];
|
|
59
|
-
const contextFilePath =
|
|
51
|
+
const contextFilePath = (0, import_utils.myResolve)("../context.ts");
|
|
60
52
|
api.onGenerateFiles(() => {
|
|
61
53
|
api.writeTmpFile({
|
|
62
54
|
noPluginDir: true,
|
|
63
55
|
path: "theme-antv/ContextWrapper.tsx",
|
|
64
56
|
content: `
|
|
65
|
-
import
|
|
57
|
+
import React from 'react';
|
|
58
|
+
import { useOutlet, useSiteData } from 'dumi';
|
|
66
59
|
import { ThemeAntVContext } from '${contextFilePath}';
|
|
67
60
|
|
|
68
61
|
export default function ThemeAntVContextWrapper() {
|
|
69
62
|
const outlet = useOutlet();
|
|
63
|
+
// const { themeConfig } = useSiteData();
|
|
64
|
+
// const exampleTopics = themeConfig?.examples || [];
|
|
70
65
|
|
|
71
66
|
return (
|
|
72
67
|
<ThemeAntVContext.Provider
|
|
73
68
|
value={{
|
|
74
|
-
meta: ${JSON.stringify(
|
|
69
|
+
meta: ${JSON.stringify({
|
|
70
|
+
exampleTopics: (0, import_examples.getExamplesPageTopics)(api.config.themeConfig.examples || [])
|
|
71
|
+
})}
|
|
75
72
|
}}
|
|
76
73
|
>
|
|
77
74
|
{outlet}
|
|
@@ -95,7 +92,7 @@ export default function ThemeAntVContextWrapper() {
|
|
|
95
92
|
parentId: "DocLayout"
|
|
96
93
|
};
|
|
97
94
|
});
|
|
98
|
-
routes["404"].file =
|
|
95
|
+
routes["404"].file = (0, import_utils.myResolve)("../pages/404.tsx");
|
|
99
96
|
return routes;
|
|
100
97
|
});
|
|
101
98
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/plugin/utils.ts
|
|
23
|
+
var utils_exports = {};
|
|
24
|
+
__export(utils_exports, {
|
|
25
|
+
myResolve: () => myResolve
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(utils_exports);
|
|
28
|
+
var path = __toESM(require("path"));
|
|
29
|
+
function myResolve(p, alternateExts = [".js"]) {
|
|
30
|
+
const extname2 = path.extname(p);
|
|
31
|
+
const pathname = p.slice(0, p.length - extname2.length);
|
|
32
|
+
const exts = [extname2, ...alternateExts];
|
|
33
|
+
for (let i = 0; i < exts.length; i++) {
|
|
34
|
+
const ext = exts[i];
|
|
35
|
+
const fullpath = `${pathname}${ext}`;
|
|
36
|
+
try {
|
|
37
|
+
return require.resolve(fullpath);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
myResolve
|
|
46
|
+
});
|
|
@@ -24,8 +24,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
24
24
|
|
|
25
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
26
|
|
|
27
|
-
import { Input, Menu, Tooltip } from 'antd';
|
|
28
27
|
import React, { useEffect, useRef, useState } from 'react';
|
|
28
|
+
import { Input, Menu, Tooltip } from 'antd';
|
|
29
29
|
import { useLocale } from 'dumi';
|
|
30
30
|
import { createFromIconfontCN, SearchOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
31
31
|
import classNames from 'classnames';
|
package/dist/typings.d.ts
CHANGED
|
@@ -104,10 +104,13 @@ declare namespace ExamplesPage {
|
|
|
104
104
|
/** 案例主题 */
|
|
105
105
|
export interface ExampleTopic {
|
|
106
106
|
/**
|
|
107
|
-
* id
|
|
107
|
+
* id 和文件夹目录名保持一致
|
|
108
108
|
*/
|
|
109
109
|
id: string;
|
|
110
|
-
|
|
110
|
+
/**
|
|
111
|
+
* slug 和 id 一样,兼容旧配置
|
|
112
|
+
*/
|
|
113
|
+
slug?: string;
|
|
111
114
|
/**
|
|
112
115
|
* 标题
|
|
113
116
|
*/
|