@umijs/plugin-docs 4.0.0-rc.12 → 4.0.0-rc.13
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/client/theme-doc/Head.tsx +28 -16
- package/client/theme-doc/Layout.tsx +23 -22
- package/client/theme-doc/Logo.tsx +5 -4
- package/client/theme-doc/Search.tsx +1 -1
- package/client/theme-doc/Sidebar.tsx +1 -1
- package/client/theme-doc/ThemeSwitch.tsx +8 -0
- package/client/theme-doc/Toc.tsx +1 -1
- package/client/theme-doc/components/Message.tsx +31 -19
- package/client/theme-doc/context.ts +6 -1
- package/client/theme-doc/tailwind.css +40 -28
- package/client/theme-doc/tailwind.out.css +175 -94
- package/compiled/remark-gfm/index.js +1 -0
- package/compiled/remark-gfm/package.json +1 -18
- package/dist/compiler.js +16 -1
- package/dist/loader.js +13 -4
- package/package.json +12 -6
- package/compiled/remark-gfm/index.cjs +0 -15
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useThemeContext } from './context';
|
|
3
4
|
import Github from './Github';
|
|
4
5
|
import LangSwitch from './LangSwitch';
|
|
5
6
|
import Logo from './Logo';
|
|
@@ -13,27 +14,41 @@ interface HeadProps {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export default (props: HeadProps) => {
|
|
17
|
+
const { themeConfig } = useThemeContext()!;
|
|
16
18
|
return (
|
|
17
19
|
<div
|
|
18
20
|
className="w-full flex flex-row items-center justify-between
|
|
19
|
-
border-b-gray-100 border-b-2 pt-4 pb-4 px-
|
|
21
|
+
border-b-gray-100 border-b-2 pt-4 pb-4 px-4 lg:px-12 dark:border-b-gray-800"
|
|
20
22
|
>
|
|
21
|
-
<
|
|
23
|
+
<div className="flex flex-row items-center">
|
|
24
|
+
<Logo />
|
|
25
|
+
{themeConfig.extraNavLeft && <themeConfig.extraNavLeft />}
|
|
26
|
+
</div>
|
|
22
27
|
<div className="flex flex-row items-center">
|
|
23
28
|
<Search />
|
|
24
|
-
|
|
29
|
+
{/* 小屏幕显示打开菜单的按钮 */}
|
|
30
|
+
<div
|
|
31
|
+
className="block lg:hidden ml-2 cursor-pointer"
|
|
32
|
+
onClick={() => props.setMenuOpened((o) => !o)}
|
|
33
|
+
>
|
|
34
|
+
<HamburgerButton {...props} />
|
|
35
|
+
</div>
|
|
36
|
+
{/* 大屏幕显示完整的操作按钮 */}
|
|
25
37
|
<div className="hidden lg:block">
|
|
26
38
|
<NavBar />
|
|
27
39
|
</div>
|
|
28
40
|
<div className="ml-4 hidden lg:block">
|
|
29
41
|
<LangSwitch />
|
|
30
42
|
</div>
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
43
|
+
{themeConfig.themeSwitch && (
|
|
44
|
+
<div className="ml-4 hidden lg:block">
|
|
45
|
+
<ThemeSwitch />
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
34
48
|
<div className="ml-4 hidden lg:block">
|
|
35
49
|
<Github />
|
|
36
50
|
</div>
|
|
51
|
+
{themeConfig.extraNavRight && <themeConfig.extraNavRight />}
|
|
37
52
|
</div>
|
|
38
53
|
</div>
|
|
39
54
|
);
|
|
@@ -41,30 +56,27 @@ export default (props: HeadProps) => {
|
|
|
41
56
|
|
|
42
57
|
interface HamburgerButtonProps {
|
|
43
58
|
isMenuOpened: boolean;
|
|
44
|
-
setMenuOpened: React.Dispatch<React.SetStateAction<boolean>>;
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
function HamburgerButton(props: HamburgerButtonProps) {
|
|
62
|
+
const { isMenuOpened } = props;
|
|
48
63
|
const barClass =
|
|
49
|
-
'
|
|
50
|
-
'
|
|
64
|
+
'absolute h-0.5 w-5 -translate-x-2.5 bg-current transform dark:bg-white ' +
|
|
65
|
+
'transition duration-500 ease-in-out';
|
|
51
66
|
|
|
52
67
|
return (
|
|
53
|
-
<div
|
|
54
|
-
className="relative py-3 sm:max-w-xl mx-auto mx-5 lg:hidden"
|
|
55
|
-
onClick={() => props.setMenuOpened((o) => !o)}
|
|
56
|
-
>
|
|
68
|
+
<div className="p-4">
|
|
57
69
|
<span
|
|
58
70
|
className={cx(
|
|
59
71
|
barClass,
|
|
60
|
-
|
|
72
|
+
isMenuOpened ? 'rotate-45 ' : '-translate-y-1.5',
|
|
61
73
|
)}
|
|
62
74
|
/>
|
|
63
|
-
<span className={cx(barClass,
|
|
75
|
+
<span className={cx(barClass, isMenuOpened && 'opacity-0')} />
|
|
64
76
|
<span
|
|
65
77
|
className={cx(
|
|
66
78
|
barClass,
|
|
67
|
-
|
|
79
|
+
isMenuOpened ? '-rotate-45' : 'translate-y-1.5',
|
|
68
80
|
)}
|
|
69
81
|
/>
|
|
70
82
|
</div>
|
|
@@ -75,31 +75,32 @@ export default (props: any) => {
|
|
|
75
75
|
id="article-body"
|
|
76
76
|
className="w-full flex flex-row justify-center overflow-x-hidden"
|
|
77
77
|
>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
{/* 左侧菜单 */}
|
|
79
|
+
<div
|
|
80
|
+
className="fixed left-0 top-0 w-1/4 flex flex-row
|
|
81
|
+
justify-center h-screen z-10 pt-20"
|
|
82
|
+
>
|
|
83
|
+
<div className="container flex flex-row justify-end">
|
|
84
|
+
<div className="hidden lg:block">
|
|
85
|
+
<Sidebar />
|
|
86
|
+
</div>
|
|
81
87
|
</div>
|
|
82
88
|
</div>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
justify-center h-screen z-10 pt-20"
|
|
88
|
-
>
|
|
89
|
-
<div className="container flex flex-row justify-end">
|
|
90
|
-
<div className="hidden lg:block">
|
|
91
|
-
<Sidebar />
|
|
89
|
+
{/* 文章内容 */}
|
|
90
|
+
<div className="container flex flex-row justify-center">
|
|
91
|
+
<div className="w-full lg:w-1/2 px-4 lg:px-2 m-8 z-20 lg:pb-12 lg:pt-6">
|
|
92
|
+
<article className="flex-1">{props.children}</article>
|
|
92
93
|
</div>
|
|
93
94
|
</div>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
{/* 右侧 Toc */}
|
|
96
|
+
<div
|
|
97
|
+
className="fixed right-0 top-0 w-1/4 hidden lg:block flex-row
|
|
98
|
+
justify-center h-screen z-10 pt-20"
|
|
99
|
+
>
|
|
100
|
+
<div className="container flex flex-row justify-start">
|
|
101
|
+
<div className="w-2/3 top-32">
|
|
102
|
+
<Toc />
|
|
103
|
+
</div>
|
|
103
104
|
</div>
|
|
104
105
|
</div>
|
|
105
106
|
</div>
|
|
@@ -110,7 +111,7 @@ export default (props: any) => {
|
|
|
110
111
|
<div
|
|
111
112
|
className={cx(
|
|
112
113
|
'fixed top-12 w-screen bg-white z-20 dark:bg-gray-800',
|
|
113
|
-
'overflow-hidden transition-all duration-500',
|
|
114
|
+
'overflow-hidden transition-all duration-500 lg:hidden',
|
|
114
115
|
isMenuOpened ? 'max-h-screen' : 'max-h-0',
|
|
115
116
|
)}
|
|
116
117
|
>
|
|
@@ -5,14 +5,15 @@ import useLanguage from './useLanguage';
|
|
|
5
5
|
export default () => {
|
|
6
6
|
const { themeConfig, components } = useThemeContext()!;
|
|
7
7
|
const { isFromPath, currentLanguage } = useLanguage();
|
|
8
|
-
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
const { logo } = themeConfig;
|
|
8
|
+
const Logo = themeConfig.logo;
|
|
11
9
|
|
|
12
10
|
return (
|
|
13
11
|
<components.Link to={isFromPath ? '/' + currentLanguage?.locale : '/'}>
|
|
14
12
|
<div className="flex flex-row items-center">
|
|
15
|
-
|
|
13
|
+
{typeof Logo === 'string' && (
|
|
14
|
+
<img src={Logo} className="w-8 h-8" alt="logo" />
|
|
15
|
+
)}
|
|
16
|
+
{typeof Logo === 'function' && <Logo />}
|
|
16
17
|
<div className="text-xl font-extrabold ml-2 dark:text-white">
|
|
17
18
|
{themeConfig.title}
|
|
18
19
|
</div>
|
|
@@ -74,7 +74,7 @@ export default () => {
|
|
|
74
74
|
value={keyword}
|
|
75
75
|
onChange={(e) => setKeyword(e.target.value)}
|
|
76
76
|
id="search-input"
|
|
77
|
-
className="w-full bg-transparent outline-none text-sm px-4 py-2
|
|
77
|
+
className="w-full bg-transparent outline-none text-sm px-4 py-2"
|
|
78
78
|
placeholder={render('Search anything ...')}
|
|
79
79
|
/>
|
|
80
80
|
<div
|
|
@@ -28,7 +28,7 @@ export default (props: SidebarProps) => {
|
|
|
28
28
|
<ul
|
|
29
29
|
className={cx(
|
|
30
30
|
'h-screen lg:h-[calc(100vh-8rem)] overflow-y-scroll',
|
|
31
|
-
'lg:w-64
|
|
31
|
+
'lg:w-64 px-8 pt-12 lg:pt-8 pb-36 fadeout w-full',
|
|
32
32
|
)}
|
|
33
33
|
>
|
|
34
34
|
{(matchedNav.children || []).map((item) => {
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { useThemeContext } from './context';
|
|
3
4
|
import MoonIcon from './icons/moon.png';
|
|
4
5
|
import SunIcon from './icons/sun.png';
|
|
5
6
|
|
|
6
7
|
export default () => {
|
|
7
8
|
const [toggle, setToggle] = useState<Boolean>();
|
|
9
|
+
const { themeConfig } = useThemeContext()!;
|
|
8
10
|
|
|
9
11
|
useEffect(() => {
|
|
12
|
+
// If themeConfig disabled the themeSwitch, just set to light theme
|
|
13
|
+
if (!themeConfig.themeSwitch) {
|
|
14
|
+
document.body.classList.remove('dark');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
// 初始化,获取过去曾经设定过的主题,或是系统当前的主题
|
|
11
19
|
if (toggle === undefined) {
|
|
12
20
|
if (localStorage.getItem('theme') === 'dark') {
|
package/client/theme-doc/Toc.tsx
CHANGED
|
@@ -9,11 +9,14 @@ enum MessageType {
|
|
|
9
9
|
|
|
10
10
|
interface MessageProps {
|
|
11
11
|
type?: MessageType;
|
|
12
|
-
emoji?: string;
|
|
12
|
+
emoji?: string | boolean;
|
|
13
|
+
title?: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
function Message(props: PropsWithChildren<MessageProps>) {
|
|
16
|
-
const messageType = props.type ||
|
|
17
|
+
const messageType = props.type || MessageType.Info;
|
|
18
|
+
const messageTitle = props.title;
|
|
19
|
+
const propsChildren = props.children;
|
|
17
20
|
|
|
18
21
|
let messageClass: string;
|
|
19
22
|
switch (messageType) {
|
|
@@ -30,26 +33,35 @@ function Message(props: PropsWithChildren<MessageProps>) {
|
|
|
30
33
|
messageClass = 'mdx-message-info';
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
let messageEmoji = props.emoji;
|
|
37
|
+
if (!messageEmoji && messageEmoji !== false) {
|
|
38
|
+
switch (messageType) {
|
|
39
|
+
case MessageType.Success:
|
|
40
|
+
messageEmoji = '🏆︎';
|
|
41
|
+
break;
|
|
42
|
+
case MessageType.Warning:
|
|
43
|
+
messageEmoji = '🛎️';
|
|
44
|
+
break;
|
|
45
|
+
case MessageType.Error:
|
|
46
|
+
messageEmoji = '⚠️';
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
messageEmoji = '💡';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
37
52
|
|
|
38
53
|
return (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)}
|
|
49
|
-
{messageText}
|
|
50
|
-
</p>
|
|
54
|
+
<div
|
|
55
|
+
className={`flex w-full py-5 px-4 rounded-lg my-4 mdx-message ${messageClass}`}
|
|
56
|
+
>
|
|
57
|
+
<span role="img" className="mr-3 dark:text-white">
|
|
58
|
+
{messageEmoji}
|
|
59
|
+
</span>
|
|
60
|
+
<div className="flex-grow">
|
|
61
|
+
{messageTitle && <h5 className="mt-0 mb-3">{messageTitle}</h5>}
|
|
62
|
+
<div className="mdx-message-text">{propsChildren}</div>
|
|
51
63
|
</div>
|
|
52
|
-
|
|
64
|
+
</div>
|
|
53
65
|
);
|
|
54
66
|
}
|
|
55
67
|
|
|
@@ -9,12 +9,16 @@ interface IContext {
|
|
|
9
9
|
github: string;
|
|
10
10
|
// 键盘搜索的快捷键,参考 https://github.com/madrobby/keymaster
|
|
11
11
|
searchHotKey?: string | { macos: string; windows: string };
|
|
12
|
-
logo: string;
|
|
12
|
+
logo: string | React.ComponentType;
|
|
13
13
|
// 在设置文件中声明该项目的国际化功能支持的语言
|
|
14
14
|
i18n?: { locale: string; text: string }[];
|
|
15
15
|
// 插件会从 docs/locales 内将所有 json 文件注入到 themeConfig 中
|
|
16
16
|
// 供 useLanguage 使用
|
|
17
17
|
locales: { [locale: string]: { [key: string]: string } };
|
|
18
|
+
// 顶部导航栏右侧自定义组件
|
|
19
|
+
extraNavRight?: React.ComponentType;
|
|
20
|
+
// 底部导航栏左侧自定义组件
|
|
21
|
+
extraNavLeft?: React.ComponentType;
|
|
18
22
|
navs: {
|
|
19
23
|
path: string;
|
|
20
24
|
title: string;
|
|
@@ -24,6 +28,7 @@ interface IContext {
|
|
|
24
28
|
title: string;
|
|
25
29
|
link?: string;
|
|
26
30
|
};
|
|
31
|
+
themeSwitch?: {};
|
|
27
32
|
};
|
|
28
33
|
location: {
|
|
29
34
|
pathname: string;
|
|
@@ -36,7 +36,7 @@ article ul {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
article li {
|
|
39
|
-
@apply mt-2 dark:text-white;
|
|
39
|
+
@apply text-base mt-2 leading-7 text-gray-700 dark:text-white;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
article ol {
|
|
@@ -52,7 +52,7 @@ article h2 a {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
article code {
|
|
55
|
-
@apply bg-
|
|
55
|
+
@apply text-sky-800 dark:text-sky-300 bg-slate-800 bg-opacity-5 dark:bg-opacity-100 border border-black border-opacity-5 rounded-md;
|
|
56
56
|
font-size: 0.9em;
|
|
57
57
|
padding: 2px 0.25em;
|
|
58
58
|
box-decoration-break: clone;
|
|
@@ -66,48 +66,48 @@ article inlinecode {
|
|
|
66
66
|
article pre {
|
|
67
67
|
/* content-visibility: auto; */
|
|
68
68
|
contain: paint;
|
|
69
|
-
@apply p-4 bg-
|
|
69
|
+
@apply p-4 bg-zinc-900 dark:bg-zinc-900 rounded-xl my-4 overflow-x-auto font-medium subpixel-antialiased dark:text-white transition;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
article pre code {
|
|
73
73
|
line-height: 1.25rem;
|
|
74
|
-
@apply relative p-0 text-sm text-
|
|
74
|
+
@apply relative p-0 text-sm text-neutral-300 dark:text-neutral-300 bg-transparent dark:bg-transparent rounded-none border-none inline-block min-w-full transition;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
article pre code .line.highlighted {
|
|
78
|
-
@apply before:block before:absolute before:h-5 before:bg-gray-500 before:bg-opacity-10 before:-inset-x-4 before:pointer-events-none before:select-none dark:text-white;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
article a code {
|
|
82
|
-
@apply text-current no-underline dark:text-white;
|
|
78
|
+
@apply before:block before:absolute before:h-5 before:bg-gray-500 before:bg-opacity-10 before:-inset-x-4 before:pointer-events-none before:select-none dark:text-white transition;
|
|
83
79
|
}
|
|
84
80
|
|
|
85
81
|
article a {
|
|
86
|
-
@apply text-
|
|
82
|
+
@apply mx-1 text-cyan-600 dark:text-fuchsia-200 hover:text-cyan-900 dark:hover:text-fuchsia-400 transition;
|
|
87
83
|
background-image: linear-gradient(
|
|
88
84
|
transparent 60%,
|
|
89
85
|
rgba(130, 199, 255, 0.28) 55%
|
|
90
86
|
);
|
|
91
87
|
}
|
|
92
88
|
|
|
89
|
+
article a code {
|
|
90
|
+
@apply text-cyan-600 dark:text-fuchsia-200 hover:text-cyan-900 dark:hover:text-fuchsia-400 transition;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
93
|
article table {
|
|
94
|
-
@apply table-auto w-full shadow rounded-xl text-left overflow-hidden dark:shadow-gray-800 my-8
|
|
94
|
+
@apply table-auto w-full shadow rounded-xl text-left overflow-hidden dark:shadow-gray-800 my-8;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
article table thead {
|
|
98
|
-
@apply bg-blue-100 dark:bg-gray-800
|
|
98
|
+
@apply bg-blue-100 dark:bg-gray-800;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
article table thead th {
|
|
102
|
-
@apply py-3 px-4 text-gray-700 dark:text-white
|
|
102
|
+
@apply py-3 px-4 text-gray-700 dark:text-white;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
article table tbody tr {
|
|
106
|
-
@apply border-b border-b-zinc-100 dark:border-b-gray-600
|
|
106
|
+
@apply border-b border-b-zinc-100 dark:border-b-gray-600;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
article table tbody td {
|
|
110
|
-
@apply py-2 px-4 text-gray-700 dark:text-white
|
|
110
|
+
@apply py-2 px-4 text-gray-700 dark:text-white;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
.link-with-underline {
|
|
@@ -181,39 +181,51 @@ h6 {
|
|
|
181
181
|
@apply border-l-8;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
.mdx-message
|
|
184
|
+
.mdx-message code {
|
|
185
|
+
@apply dark:bg-opacity-50;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.mdx-message-text :first-child {
|
|
185
189
|
@apply mt-0;
|
|
186
190
|
}
|
|
187
191
|
|
|
192
|
+
.mdx-message-text img {
|
|
193
|
+
@apply rounded-md;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.mdx-message-text pre {
|
|
197
|
+
@apply my-2;
|
|
198
|
+
}
|
|
199
|
+
|
|
188
200
|
.mdx-message-info {
|
|
189
|
-
@apply bg-blue-50 border-blue-300 dark:bg-blue-
|
|
201
|
+
@apply bg-blue-50 border-blue-300 dark:bg-blue-900 dark:border-blue-500;
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
.mdx-message-info
|
|
193
|
-
@apply text-blue-
|
|
204
|
+
.mdx-message-info code {
|
|
205
|
+
@apply text-blue-800 dark:text-blue-200;
|
|
194
206
|
}
|
|
195
207
|
|
|
196
208
|
.mdx-message-success {
|
|
197
|
-
@apply bg-green-50 border-green-300 dark:bg-green-
|
|
209
|
+
@apply bg-green-50 border-green-300 dark:bg-green-700 dark:border-green-500;
|
|
198
210
|
}
|
|
199
211
|
|
|
200
|
-
.mdx-message-success
|
|
201
|
-
@apply text-green-
|
|
212
|
+
.mdx-message-success code {
|
|
213
|
+
@apply text-green-800 dark:text-green-200;
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
.mdx-message-warning {
|
|
205
|
-
@apply bg-orange-50 border-orange-300 dark:bg-orange-
|
|
217
|
+
@apply bg-orange-50 border-orange-300 dark:bg-orange-700 dark:border-orange-500;
|
|
206
218
|
}
|
|
207
219
|
|
|
208
|
-
.mdx-message-warning
|
|
209
|
-
@apply text-orange-
|
|
220
|
+
.mdx-message-warning code {
|
|
221
|
+
@apply text-orange-700 dark:text-orange-100;
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
.mdx-message-error {
|
|
213
|
-
@apply bg-red-50 border-red-300 dark:bg-
|
|
225
|
+
@apply bg-red-50 border-red-300 dark:bg-rose-700 dark:border-rose-500;
|
|
214
226
|
}
|
|
215
227
|
|
|
216
|
-
.mdx-message-error
|
|
217
|
-
@apply text-red-
|
|
228
|
+
.mdx-message-error code {
|
|
229
|
+
@apply text-red-700 dark:text-rose-100;
|
|
218
230
|
}
|
|
219
231
|
}
|