dumi 2.1.5 → 2.1.7
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/assetParsers/atom.d.ts +2 -0
- package/dist/assetParsers/atom.js +29 -14
- package/dist/client/theme-api/types.d.ts +4 -0
- package/dist/features/configPlugins/index.js +2 -1
- package/dist/features/configPlugins/schema.js +2 -1
- package/dist/features/derivative.js +3 -0
- package/dist/features/exportStatic.js +6 -1
- package/dist/features/parser.js +7 -1
- package/dist/features/routes.js +8 -6
- package/dist/types.d.ts +1 -0
- package/package.json +6 -6
- package/theme-default/locales/en-US.json +8 -0
- package/theme-default/locales/zh-CN.json +8 -0
- package/theme-default/slots/Header/index.js +17 -2
- package/theme-default/slots/SocialIcon/index.d.ts +13 -0
- package/theme-default/slots/SocialIcon/index.js +45 -0
- package/theme-default/slots/SocialIcon/index.less +38 -0
- package/theme-default/styles/variables.less +1 -1
|
@@ -4,6 +4,7 @@ declare class AtomAssetsParser {
|
|
|
4
4
|
private resolveDir;
|
|
5
5
|
private unresolvedFiles;
|
|
6
6
|
private parser;
|
|
7
|
+
private isParsing;
|
|
7
8
|
private parseDeferrer;
|
|
8
9
|
private watcher;
|
|
9
10
|
private cbs;
|
|
@@ -21,5 +22,6 @@ declare class AtomAssetsParser {
|
|
|
21
22
|
}>;
|
|
22
23
|
watch(cb: AtomAssetsParser['cbs'][number]): void;
|
|
23
24
|
unwatch(cb: AtomAssetsParser['cbs'][number]): void;
|
|
25
|
+
destroyWorker(): void;
|
|
24
26
|
}
|
|
25
27
|
export default AtomAssetsParser;
|
|
@@ -33,6 +33,7 @@ var MAX_PARSE_SIZE = 1024 * 512;
|
|
|
33
33
|
var AtomAssetsParser = class {
|
|
34
34
|
constructor(opts) {
|
|
35
35
|
this.unresolvedFiles = [];
|
|
36
|
+
this.isParsing = false;
|
|
36
37
|
this.watcher = null;
|
|
37
38
|
this.cbs = [];
|
|
38
39
|
const absEntryFile = import_path.default.resolve(opts.resolveDir, opts.entryFile);
|
|
@@ -42,28 +43,33 @@ var AtomAssetsParser = class {
|
|
|
42
43
|
this.parser = new import_parser.SchemaParser({
|
|
43
44
|
entryPath: absEntryFile,
|
|
44
45
|
basePath: (0, import_utils.getProjectRoot)(opts.resolveDir),
|
|
45
|
-
unPkgHost: opts.unpkgHost ?? "https://unpkg.com"
|
|
46
|
+
unPkgHost: opts.unpkgHost ?? "https://unpkg.com",
|
|
47
|
+
mode: "worker"
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
async parse() {
|
|
49
|
-
if (!this.parseDeferrer || this.unresolvedFiles.length) {
|
|
51
|
+
if (!this.parseDeferrer || this.unresolvedFiles.length && !this.isParsing) {
|
|
52
|
+
this.isParsing = true;
|
|
50
53
|
this.parseDeferrer = (async () => {
|
|
51
|
-
this.unresolvedFiles.splice(0);
|
|
52
|
-
await this.parser.
|
|
53
|
-
|
|
54
|
+
await this.parser.patch(this.unresolvedFiles.splice(0));
|
|
55
|
+
const resolver = new import_parser.SchemaResolver(await this.parser.parse(), {
|
|
56
|
+
mode: "worker"
|
|
57
|
+
});
|
|
54
58
|
const result = {
|
|
55
59
|
components: {},
|
|
56
60
|
functions: {}
|
|
57
61
|
};
|
|
58
62
|
const fallbackProps = { type: "object", properties: {} };
|
|
59
63
|
const fallbackSignature = { arguments: [] };
|
|
60
|
-
resolver.componentList
|
|
64
|
+
const componentList = await resolver.componentList;
|
|
65
|
+
const functionList = await resolver.functionList;
|
|
66
|
+
for (const id of componentList) {
|
|
61
67
|
const needResolve = this.resolveFilter({
|
|
62
68
|
id,
|
|
63
69
|
type: "COMPONENT",
|
|
64
|
-
ids:
|
|
70
|
+
ids: componentList
|
|
65
71
|
});
|
|
66
|
-
let propsConfig = needResolve ? resolver.getComponent(id).props : fallbackProps;
|
|
72
|
+
let propsConfig = needResolve ? (await resolver.getComponent(id)).props : fallbackProps;
|
|
67
73
|
const size = Buffer.byteLength(JSON.stringify(propsConfig));
|
|
68
74
|
if (size > MAX_PARSE_SIZE) {
|
|
69
75
|
propsConfig = fallbackProps;
|
|
@@ -75,14 +81,14 @@ var AtomAssetsParser = class {
|
|
|
75
81
|
title: id,
|
|
76
82
|
propsConfig
|
|
77
83
|
};
|
|
78
|
-
}
|
|
79
|
-
|
|
84
|
+
}
|
|
85
|
+
for (const id of functionList) {
|
|
80
86
|
const needResolve = this.resolveFilter({
|
|
81
87
|
id,
|
|
82
88
|
type: "FUNCTION",
|
|
83
|
-
ids:
|
|
89
|
+
ids: functionList
|
|
84
90
|
});
|
|
85
|
-
let signature = needResolve ? resolver.getFunction(id).signature : fallbackSignature;
|
|
91
|
+
let signature = needResolve ? (await resolver.getFunction(id)).signature : fallbackSignature;
|
|
86
92
|
const size = Buffer.byteLength(JSON.stringify(signature));
|
|
87
93
|
if (size > MAX_PARSE_SIZE) {
|
|
88
94
|
signature = fallbackSignature;
|
|
@@ -94,7 +100,9 @@ var AtomAssetsParser = class {
|
|
|
94
100
|
title: id,
|
|
95
101
|
signature
|
|
96
102
|
};
|
|
97
|
-
}
|
|
103
|
+
}
|
|
104
|
+
resolver.$$destroyWorker();
|
|
105
|
+
this.isParsing = false;
|
|
98
106
|
return result;
|
|
99
107
|
})();
|
|
100
108
|
}
|
|
@@ -117,7 +125,7 @@ var AtomAssetsParser = class {
|
|
|
117
125
|
],
|
|
118
126
|
ignoreInitial: true
|
|
119
127
|
}).on("all", (ev, file) => {
|
|
120
|
-
if (["add", "change"].includes(ev) &&
|
|
128
|
+
if (["add", "change"].includes(ev) && /((?<!\.d)\.ts|\.(jsx?|tsx))$/.test(file)) {
|
|
121
129
|
this.unresolvedFiles.push(import_path.default.join(this.resolveDir, file));
|
|
122
130
|
lazyParse();
|
|
123
131
|
}
|
|
@@ -128,6 +136,13 @@ var AtomAssetsParser = class {
|
|
|
128
136
|
unwatch(cb) {
|
|
129
137
|
this.cbs.splice(this.cbs.indexOf(cb), 1);
|
|
130
138
|
}
|
|
139
|
+
destroyWorker() {
|
|
140
|
+
if (this.parseDeferrer) {
|
|
141
|
+
this.parseDeferrer.finally(() => this.parser.$$destroyWorker());
|
|
142
|
+
} else {
|
|
143
|
+
this.parser.$$destroyWorker();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
131
146
|
};
|
|
132
147
|
var atom_default = AtomAssetsParser;
|
|
133
148
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -159,6 +159,7 @@ export interface ISidebarGroup {
|
|
|
159
159
|
children: ISidebarItem[];
|
|
160
160
|
[key: string]: any;
|
|
161
161
|
}
|
|
162
|
+
export declare type SocialTypes = 'github' | 'weibo' | 'twitter' | 'gitlab' | 'facebook' | 'zhihu' | 'yuque' | 'linkedin';
|
|
162
163
|
export interface IThemeConfig {
|
|
163
164
|
name?: string;
|
|
164
165
|
logo?: string | false;
|
|
@@ -173,6 +174,9 @@ export interface IThemeConfig {
|
|
|
173
174
|
default: 'light' | 'dark' | 'auto';
|
|
174
175
|
switch: boolean;
|
|
175
176
|
};
|
|
177
|
+
socialLinks: {
|
|
178
|
+
[key in SocialTypes]: string;
|
|
179
|
+
};
|
|
176
180
|
[key: string]: any;
|
|
177
181
|
}
|
|
178
182
|
export declare type IRoutesById = Record<string, {
|
|
@@ -28,7 +28,8 @@ var configPlugins_default = (api) => {
|
|
|
28
28
|
resolve: {
|
|
29
29
|
docDirs: ["docs"],
|
|
30
30
|
atomDirs: [{ type: "component", dir: "src" }],
|
|
31
|
-
codeBlockMode: "active"
|
|
31
|
+
codeBlockMode: "active",
|
|
32
|
+
forceKebabCaseRouting: true
|
|
32
33
|
},
|
|
33
34
|
themeConfig: {
|
|
34
35
|
footer: `Copyright \xA9 ${new Date().getFullYear()} | Powered by <a href="https://d.umijs.org" target="_blank" rel="noreferrer">dumi</a>`,
|
|
@@ -32,7 +32,8 @@ function getSchemas() {
|
|
|
32
32
|
atomDirs: Joi.array().items(Joi.object({ type: Joi.string(), dir: Joi.string() })).optional(),
|
|
33
33
|
entityDirs: Joi.forbidden().error(new Error("`entityDirs` is already deprecated, please rename it to `atomDirs` in `.dumirc.ts`")),
|
|
34
34
|
codeBlockMode: Joi.string().valid("active", "passive").optional(),
|
|
35
|
-
entryFile: Joi.string().optional()
|
|
35
|
+
entryFile: Joi.string().optional(),
|
|
36
|
+
forceKebabCaseRouting: Joi.bool().optional()
|
|
36
37
|
}).optional(),
|
|
37
38
|
extraRemarkPlugins: getUnifiedPluginSchema,
|
|
38
39
|
extraRehypePlugins: getUnifiedPluginSchema,
|
|
@@ -50,6 +50,7 @@ var derivative_default = (api) => {
|
|
|
50
50
|
var _a, _b, _c, _d;
|
|
51
51
|
(0, import_assert.default)(!api.config.mpa, "MPA mode is not supported in dumi!");
|
|
52
52
|
(0, import_assert.default)(!api.config.vite, "Vite mode is not supported yet!");
|
|
53
|
+
(0, import_assert.default)(!api.config.phantomDependency, "PhantomDependency is not supported yet!");
|
|
53
54
|
if (typeof api.config.mfsu === "object") {
|
|
54
55
|
(0, import_assert.default)(api.config.mfsu.strategy !== "eager", "MFSU eager mode is not supported yet!");
|
|
55
56
|
(0, import_assert.default)(api.config.mfsu.esbuild !== true, "MFSU esbuild bundler is not supported yet!");
|
|
@@ -135,6 +136,8 @@ var derivative_default = (api) => {
|
|
|
135
136
|
}
|
|
136
137
|
});
|
|
137
138
|
api.registerPlugins([require.resolve("../../compiled/@umijs/plugins")]);
|
|
139
|
+
if (api.isPluginEnable("prepare"))
|
|
140
|
+
api.skipPlugins(["prepare"]);
|
|
138
141
|
};
|
|
139
142
|
// Annotate the CommonJS export names for ESM import in node:
|
|
140
143
|
0 && (module.exports = {
|
|
@@ -23,6 +23,7 @@ __export(exportStatic_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(exportStatic_exports);
|
|
25
25
|
var import_constants = require("../constants");
|
|
26
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
26
27
|
var import_assets = require("./assets");
|
|
27
28
|
var exportStatic_default = (api) => {
|
|
28
29
|
const prevExtraRoutePaths = [];
|
|
@@ -49,10 +50,14 @@ var exportStatic_default = (api) => {
|
|
|
49
50
|
memo.exportStatic.extraRoutePaths = async () => {
|
|
50
51
|
const examples = (0, import_assets.getExampleAssets)();
|
|
51
52
|
const userExtraPaths = [];
|
|
53
|
+
const isSupportDisablePrerender = import_plugin_utils.semver.gte(api.appData.umi.version, "4.0.48");
|
|
52
54
|
for (const prev of prevExtraRoutePaths) {
|
|
53
55
|
userExtraPaths.push(...typeof prev === "function" ? await prev() : prev);
|
|
54
56
|
}
|
|
55
|
-
return userExtraPaths.concat(examples.map(({ id }) =>
|
|
57
|
+
return userExtraPaths.concat(examples.map(({ id }) => {
|
|
58
|
+
const demoPath = `/${import_constants.SP_ROUTE_PREFIX}demos/${id}`;
|
|
59
|
+
return isSupportDisablePrerender ? { path: demoPath, prerender: false } : demoPath;
|
|
60
|
+
}));
|
|
56
61
|
};
|
|
57
62
|
}
|
|
58
63
|
return memo;
|
package/dist/features/parser.js
CHANGED
|
@@ -51,7 +51,7 @@ var parser_default = (api) => {
|
|
|
51
51
|
(0, import_assert.default)((_a = api.userConfig.resolve) == null ? void 0 : _a.entryFile, "`resolve.entryFile` must be configured when `apiParser` enable");
|
|
52
52
|
return memo;
|
|
53
53
|
});
|
|
54
|
-
api.
|
|
54
|
+
api.onCheckPkgJSON(async () => {
|
|
55
55
|
const {
|
|
56
56
|
default: AtomAssetsParser
|
|
57
57
|
} = require("../assetParsers/atom");
|
|
@@ -77,6 +77,12 @@ var parser_default = (api) => {
|
|
|
77
77
|
writeAtomsMetaFile(prevData);
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
+
api.onBuildComplete({
|
|
81
|
+
stage: Infinity,
|
|
82
|
+
fn() {
|
|
83
|
+
api.service.atomParser.destroyWorker();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
80
86
|
};
|
|
81
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
88
|
0 && (module.exports = {});
|
package/dist/features/routes.js
CHANGED
|
@@ -42,16 +42,17 @@ function kebabCaseRoutePath(routePath) {
|
|
|
42
42
|
};
|
|
43
43
|
return routePath.replace(/(.)?([A-Z][^A-Z/])/g, replacer).replace(/(.)?([A-Z]+)/g, replacer);
|
|
44
44
|
}
|
|
45
|
-
function localizeUmiRoute(route, locales) {
|
|
45
|
+
function localizeUmiRoute(route, locales, forceKebabCase) {
|
|
46
46
|
const locale = locales.find((locale2) => route.path.endsWith(`/${locale2.id}`) && import_path.default.parse(route.file).name.endsWith(`.${locale2.id}`));
|
|
47
|
+
const format = forceKebabCase ? kebabCaseRoutePath : (str) => str;
|
|
47
48
|
if (locale) {
|
|
48
49
|
const base = !("base" in locale) || locale.base === "/" ? "" : locale.base.replace(/^(\/)(.+)$/, "$2$1");
|
|
49
50
|
const suffix = "suffix" in locale ? locale.suffix : "";
|
|
50
|
-
route.path = `${base}${
|
|
51
|
+
route.path = `${base}${format(route.path.replace(new RegExp(`/${locale.id}$`), "").replace(/((^|\/)(index|README))$/, ""))}${suffix}`;
|
|
51
52
|
route.absPath = route.path !== "/" ? `/${route.path}` : route.path;
|
|
52
53
|
} else {
|
|
53
|
-
route.path =
|
|
54
|
-
route.absPath =
|
|
54
|
+
route.path = format(route.path);
|
|
55
|
+
route.absPath = format(route.absPath);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
function flatRoute(route, docLayoutId) {
|
|
@@ -174,7 +175,7 @@ var routes_default = (api) => {
|
|
|
174
175
|
at ${route.file}`);
|
|
175
176
|
} else if (!route.isLayout) {
|
|
176
177
|
flatRoute(route, docLayoutId);
|
|
177
|
-
localizeUmiRoute(route, api.config.locales);
|
|
178
|
+
localizeUmiRoute(route, api.config.locales, api.config.resolve.forceKebabCaseRouting);
|
|
178
179
|
}
|
|
179
180
|
});
|
|
180
181
|
if (Object.values(pages).every((route) => route.path !== "*")) {
|
|
@@ -191,7 +192,8 @@ var routes_default = (api) => {
|
|
|
191
192
|
path: `${import_constants.SP_ROUTE_PREFIX}demos/:id`,
|
|
192
193
|
absPath: `/${import_constants.SP_ROUTE_PREFIX}demos/:id`,
|
|
193
194
|
parentId: demoLayoutId,
|
|
194
|
-
file: getClientPageFile("client/pages/Demo", api.cwd)
|
|
195
|
+
file: getClientPageFile("client/pages/Demo", api.cwd),
|
|
196
|
+
prerender: false
|
|
195
197
|
};
|
|
196
198
|
return routes;
|
|
197
199
|
});
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"@swc/core": "^1.2.224",
|
|
81
81
|
"@types/hast": "^2.3.4",
|
|
82
82
|
"@types/mdast": "^3.0.10",
|
|
83
|
-
"@umijs/bundler-utils": "^4.0.
|
|
84
|
-
"@umijs/core": "^4.0.
|
|
83
|
+
"@umijs/bundler-utils": "^4.0.48",
|
|
84
|
+
"@umijs/core": "^4.0.48",
|
|
85
85
|
"animated-scroll-to": "^2.3.0",
|
|
86
86
|
"classnames": "2.3.2",
|
|
87
87
|
"codesandbox": "^2.2.3",
|
|
88
88
|
"deepmerge": "^4.2.2",
|
|
89
|
-
"dumi-afx-deps": "^1.0.0-alpha.
|
|
89
|
+
"dumi-afx-deps": "^1.0.0-alpha.12",
|
|
90
90
|
"dumi-assets-types": "2.0.0-alpha.0",
|
|
91
91
|
"enhanced-resolve": "^5.10.0",
|
|
92
92
|
"estree-util-to-js": "^1.1.0",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"remark-rehype": "^10.1.0",
|
|
123
123
|
"sass": "^1.55.0",
|
|
124
124
|
"sitemap": "^7.1.1",
|
|
125
|
-
"umi": "^4.0.
|
|
125
|
+
"umi": "^4.0.48",
|
|
126
126
|
"unified": "^10.1.2",
|
|
127
127
|
"unist-util-visit": "^4.1.0",
|
|
128
128
|
"unist-util-visit-parents": "^5.1.1",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"@types/pluralize": "^0.0.29",
|
|
142
142
|
"@types/react": "^18.0.16",
|
|
143
143
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
|
144
|
-
"@umijs/lint": "^4.0.
|
|
144
|
+
"@umijs/lint": "^4.0.48",
|
|
145
145
|
"@umijs/plugins": "4.0.32",
|
|
146
146
|
"dumi-theme-mobile": "workspace:*",
|
|
147
147
|
"eslint": "^8.20.0",
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
"header.color.mode.light": "Light Mode",
|
|
4
4
|
"header.color.mode.dark": "Dark Mode",
|
|
5
5
|
"header.color.mode.auto": "Follow System",
|
|
6
|
+
"header.social.github": "GitHub",
|
|
7
|
+
"header.social.weibo": "Weibo",
|
|
8
|
+
"header.social.twitter": "Twitter",
|
|
9
|
+
"header.social.gitlab": "GitLab",
|
|
10
|
+
"header.social.facebook": "Facebook",
|
|
11
|
+
"header.social.zhihu": "Zhihu",
|
|
12
|
+
"header.social.yuque": "Yuque",
|
|
13
|
+
"header.social.linkedin": "Linkedin",
|
|
6
14
|
"previewer.actions.code.expand": "Show Code",
|
|
7
15
|
"previewer.actions.code.shrink": "Hide Code",
|
|
8
16
|
"previewer.actions.codesandbox": "Open in CodeSandbox",
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
"header.color.mode.light": "亮色模式",
|
|
4
4
|
"header.color.mode.dark": "暗色模式",
|
|
5
5
|
"header.color.mode.auto": "跟随系统",
|
|
6
|
+
"header.social.github": "GitHub",
|
|
7
|
+
"header.social.weibo": "微博",
|
|
8
|
+
"header.social.twitter": "Twitter",
|
|
9
|
+
"header.social.gitlab": "GitLab",
|
|
10
|
+
"header.social.facebook": "Facebook",
|
|
11
|
+
"header.social.zhihu": "知乎",
|
|
12
|
+
"header.social.yuque": "语雀",
|
|
13
|
+
"header.social.linkedin": "Linkedin",
|
|
6
14
|
"previewer.actions.code.expand": "展开代码",
|
|
7
15
|
"previewer.actions.code.shrink": "收起代码",
|
|
8
16
|
"previewer.actions.codesandbox": "在 CodeSandbox 中打开",
|
|
@@ -20,7 +20,8 @@ import Logo from "dumi/theme/slots/Logo";
|
|
|
20
20
|
import Navbar from "dumi/theme/slots/Navbar";
|
|
21
21
|
import RtlSwitch from "dumi/theme/slots/RtlSwitch";
|
|
22
22
|
import SearchBar from "dumi/theme/slots/SearchBar";
|
|
23
|
-
import React, { useState } from 'react';
|
|
23
|
+
import React, { useMemo, useState } from 'react';
|
|
24
|
+
import SocialIcon from "../SocialIcon";
|
|
24
25
|
import "./index.less";
|
|
25
26
|
|
|
26
27
|
var Header = function Header() {
|
|
@@ -35,6 +36,14 @@ var Header = function Header() {
|
|
|
35
36
|
var _useSiteData = useSiteData(),
|
|
36
37
|
themeConfig = _useSiteData.themeConfig;
|
|
37
38
|
|
|
39
|
+
var socialIcons = useMemo(function () {
|
|
40
|
+
return themeConfig.socialLinks ? Object.keys(themeConfig.socialLinks).slice(0, 5).map(function (key) {
|
|
41
|
+
return {
|
|
42
|
+
icon: key,
|
|
43
|
+
link: themeConfig.socialLinks[key]
|
|
44
|
+
};
|
|
45
|
+
}) : [];
|
|
46
|
+
}, [themeConfig.socialLinks]);
|
|
38
47
|
return /*#__PURE__*/React.createElement("div", {
|
|
39
48
|
className: "dumi-default-header",
|
|
40
49
|
"data-static": Boolean(frontmatter.hero) || undefined,
|
|
@@ -50,7 +59,13 @@ var Header = function Header() {
|
|
|
50
59
|
className: "dumi-default-header-right"
|
|
51
60
|
}, /*#__PURE__*/React.createElement(Navbar, null), /*#__PURE__*/React.createElement("div", {
|
|
52
61
|
className: "dumi-default-header-right-aside"
|
|
53
|
-
}, /*#__PURE__*/React.createElement(SearchBar, null), /*#__PURE__*/React.createElement(LangSwitch, null), /*#__PURE__*/React.createElement(RtlSwitch, null), themeConfig.prefersColor.switch && /*#__PURE__*/React.createElement(ColorSwitch, null),
|
|
62
|
+
}, /*#__PURE__*/React.createElement(SearchBar, null), /*#__PURE__*/React.createElement(LangSwitch, null), /*#__PURE__*/React.createElement(RtlSwitch, null), themeConfig.prefersColor.switch && /*#__PURE__*/React.createElement(ColorSwitch, null), socialIcons.map(function (item) {
|
|
63
|
+
return /*#__PURE__*/React.createElement(SocialIcon, {
|
|
64
|
+
icon: item.icon,
|
|
65
|
+
link: item.link,
|
|
66
|
+
key: item.link
|
|
67
|
+
});
|
|
68
|
+
}), /*#__PURE__*/React.createElement(HeaderExtra, null))), /*#__PURE__*/React.createElement("button", {
|
|
54
69
|
type: "button",
|
|
55
70
|
className: "dumi-default-header-menu-btn",
|
|
56
71
|
onClick: function onClick(ev) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SocialTypes } from "../../../theme-api/types";
|
|
2
|
+
import { FunctionComponent, type FC } from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export declare type SocialIconProps = {
|
|
5
|
+
icon: SocialTypes;
|
|
6
|
+
link: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type PresetSocialIcon = {
|
|
9
|
+
Icon: FunctionComponent;
|
|
10
|
+
titleIntlId: string;
|
|
11
|
+
};
|
|
12
|
+
declare const SocialIcon: FC<SocialIconProps>;
|
|
13
|
+
export default SocialIcon;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactComponent as IconFacebook } from '@ant-design/icons-svg/inline-svg/outlined/facebook.svg';
|
|
2
|
+
import { ReactComponent as IconGitHub } from '@ant-design/icons-svg/inline-svg/outlined/github.svg';
|
|
3
|
+
import { ReactComponent as IconGitlab } from '@ant-design/icons-svg/inline-svg/outlined/gitlab.svg';
|
|
4
|
+
import { ReactComponent as IconLinkedin } from '@ant-design/icons-svg/inline-svg/outlined/linkedin.svg';
|
|
5
|
+
import { ReactComponent as IconTwitter } from '@ant-design/icons-svg/inline-svg/outlined/twitter.svg';
|
|
6
|
+
import { ReactComponent as IconWeiBo } from '@ant-design/icons-svg/inline-svg/outlined/weibo.svg';
|
|
7
|
+
import { ReactComponent as IconYuque } from '@ant-design/icons-svg/inline-svg/outlined/yuque.svg';
|
|
8
|
+
import { ReactComponent as IconZhihu } from '@ant-design/icons-svg/inline-svg/outlined/zhihu.svg';
|
|
9
|
+
import React, { useMemo } from 'react';
|
|
10
|
+
import { useIntl } from 'react-intl';
|
|
11
|
+
import "./index.less";
|
|
12
|
+
var presetIconMap = {
|
|
13
|
+
github: IconGitHub,
|
|
14
|
+
weibo: IconWeiBo,
|
|
15
|
+
twitter: IconTwitter,
|
|
16
|
+
gitlab: IconGitlab,
|
|
17
|
+
facebook: IconFacebook,
|
|
18
|
+
zhihu: IconZhihu,
|
|
19
|
+
yuque: IconYuque,
|
|
20
|
+
linkedin: IconLinkedin
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var SocialIcon = function SocialIcon(props) {
|
|
24
|
+
var icon = props.icon,
|
|
25
|
+
link = props.link;
|
|
26
|
+
var intl = useIntl();
|
|
27
|
+
var preset = useMemo(function () {
|
|
28
|
+
return {
|
|
29
|
+
Icon: presetIconMap[icon],
|
|
30
|
+
link: link
|
|
31
|
+
};
|
|
32
|
+
}, [icon, link]);
|
|
33
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
34
|
+
className: "dumi-default-icon",
|
|
35
|
+
"data-dumi-tooltip": intl.formatMessage({
|
|
36
|
+
id: "header.social.".concat(icon)
|
|
37
|
+
}),
|
|
38
|
+
"data-dumi-tooltip-bottom": true,
|
|
39
|
+
target: "_blank",
|
|
40
|
+
href: preset.link,
|
|
41
|
+
rel: "noreferrer"
|
|
42
|
+
}, /*#__PURE__*/React.createElement(preset.Icon, null));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default SocialIcon;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import (reference) '../../styles/variables.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-icon {
|
|
4
|
+
font-size: 0;
|
|
5
|
+
line-height: 0;
|
|
6
|
+
|
|
7
|
+
[class*='-switch'] + & {
|
|
8
|
+
margin-inline-start: 15px;
|
|
9
|
+
margin-inline-end: -15px;
|
|
10
|
+
padding-inline: 15px;
|
|
11
|
+
border-inline-start: 1px solid @c-border;
|
|
12
|
+
|
|
13
|
+
@{dark-selector} & {
|
|
14
|
+
border-inline-start-color: @c-border-dark;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
& + & {
|
|
19
|
+
margin-inline-start: 18px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
> svg {
|
|
23
|
+
height: 16px;
|
|
24
|
+
fill: @c-text-secondary;
|
|
25
|
+
|
|
26
|
+
@{dark-selector} & {
|
|
27
|
+
fill: @c-text-secondary-dark;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:hover svg {
|
|
32
|
+
fill: @c-primary;
|
|
33
|
+
|
|
34
|
+
@{dark-selector} & {
|
|
35
|
+
fill: @c-primary-dark;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// @dark-selector be injected by less-loader in feature/theme/index.ts
|
|
23
23
|
@dark-solid-amount: 15%;
|
|
24
24
|
@dark-light-amount: 22%;
|
|
25
|
-
@dark-border-amount:
|
|
25
|
+
@dark-border-amount: 71%;
|
|
26
26
|
@c-primary-dark: darken(@c-primary, @dark-solid-amount);
|
|
27
27
|
@c-warning-dark: darken(@c-warning, @dark-solid-amount);
|
|
28
28
|
@c-success-dark: darken(@c-success, @dark-solid-amount);
|