@umijs/plugin-docs 4.0.0-rc.9 → 4.0.2
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/LangSwitch.tsx +3 -1
- package/client/theme-doc/Layout.tsx +31 -24
- package/client/theme-doc/Logo.tsx +9 -5
- package/client/theme-doc/NavBar.tsx +101 -18
- package/client/theme-doc/Search.tsx +52 -22
- package/client/theme-doc/Sidebar.tsx +6 -3
- package/client/theme-doc/ThemeSwitch.tsx +24 -0
- package/client/theme-doc/Toc.tsx +12 -14
- package/client/theme-doc/components/Announcement.tsx +1 -0
- package/client/theme-doc/components/Features.tsx +1 -1
- package/client/theme-doc/components/Message.tsx +31 -19
- package/client/theme-doc/context.ts +11 -1
- package/client/theme-doc/firefox-polyfill.css +4 -4
- package/client/theme-doc/icons/link.svg +1 -0
- package/client/theme-doc/tailwind.css +127 -27
- package/client/theme-doc/tailwind.out.css +548 -141
- package/client/theme-doc/useLanguage.ts +8 -3
- package/client/theme-doc/utils/getLinkFromTitle.ts +15 -0
- package/client/theme-doc/utils/getTocTitle.ts +9 -0
- package/compiled/@mdx-js/mdx/index.js +1 -1
- package/compiled/remark-gfm/LICENSE +22 -0
- package/compiled/remark-gfm/index.js +1 -0
- package/compiled/remark-gfm/package.json +1 -0
- package/dist/compiler.d.ts +1 -0
- package/dist/compiler.js +55 -21
- package/dist/index.js +14 -8
- package/dist/loader.js +14 -15
- package/dist/markdown.js +3 -1
- package/package.json +16 -10
|
@@ -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,21 +9,28 @@ 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;
|
|
25
|
+
type: 'nav' | 'link';
|
|
26
|
+
dropdown?: { title: string; path: string }[];
|
|
21
27
|
children: any[];
|
|
22
28
|
}[];
|
|
23
29
|
announcement?: {
|
|
24
30
|
title: string;
|
|
25
31
|
link?: string;
|
|
26
32
|
};
|
|
33
|
+
themeSwitch?: {};
|
|
27
34
|
};
|
|
28
35
|
location: {
|
|
29
36
|
pathname: string;
|
|
@@ -31,6 +38,9 @@ interface IContext {
|
|
|
31
38
|
hash: string;
|
|
32
39
|
key: string;
|
|
33
40
|
};
|
|
41
|
+
history: {
|
|
42
|
+
push(to: string, state?: any): void;
|
|
43
|
+
};
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
export const ThemeContext = React.createContext<IContext | null>(null);
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
.g-glossy-firefox-cover {
|
|
13
13
|
display: block;
|
|
14
14
|
position: fixed;
|
|
15
|
-
top:
|
|
15
|
+
top: 0;
|
|
16
16
|
width: 100%;
|
|
17
|
-
height: 72px;
|
|
17
|
+
height: calc(var(--anchor-offset) + 72px);
|
|
18
18
|
z-index: 22;
|
|
19
19
|
background-color: white;
|
|
20
20
|
}
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
display: block;
|
|
24
24
|
position: fixed;
|
|
25
25
|
width: 100%;
|
|
26
|
-
top:
|
|
27
|
-
height: 72px;
|
|
26
|
+
top: 0;
|
|
27
|
+
height: calc(var(--anchor-offset) + 72px);
|
|
28
28
|
z-index: 24;
|
|
29
29
|
background: -moz-element(#article-body) no-repeat top;
|
|
30
30
|
filter: blur(10px);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg>
|
|
@@ -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 {
|
|
@@ -51,44 +51,130 @@ article h2 a {
|
|
|
51
51
|
@apply no-underline dark:text-white;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/* 行内代码 */
|
|
54
55
|
article code {
|
|
55
|
-
@apply bg-
|
|
56
|
+
@apply text-sky-600 dark:text-sky-300 bg-slate-800 bg-opacity-5 dark:bg-opacity-100 border border-black border-opacity-5 rounded-md;
|
|
56
57
|
font-size: 0.9em;
|
|
57
58
|
padding: 2px 0.25em;
|
|
58
59
|
box-decoration-break: clone;
|
|
59
60
|
font-feature-settings: 'rlig' 1, 'calt' 1, 'ss01' 1;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
/* 行内高亮代码 */
|
|
64
|
+
article span[data-rehype-pretty-code-fragment] code {
|
|
65
|
+
@apply bg-zinc-900 dark:bg-zinc-900;
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
/* 代码块 */
|
|
66
69
|
article pre {
|
|
67
|
-
/* content-visibility: auto; */
|
|
68
70
|
contain: paint;
|
|
69
|
-
@apply
|
|
71
|
+
@apply my-4 bg-zinc-900 dark:bg-zinc-900 text-neutral-300 dark:text-neutral-300 rounded-md font-medium subpixel-antialiased transition;
|
|
72
|
+
}
|
|
73
|
+
article pre > code {
|
|
74
|
+
@apply grid leading-relaxed p-4 text-sm text-neutral-300 dark:text-neutral-300 bg-transparent dark:bg-transparent rounded-none border-none min-w-full overflow-x-auto;
|
|
75
|
+
}
|
|
76
|
+
article div[data-rehype-pretty-code-fragment] {
|
|
77
|
+
@apply my-4;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* 代码块的标题部分 */
|
|
81
|
+
article
|
|
82
|
+
div[data-rehype-pretty-code-fragment]
|
|
83
|
+
> div[data-rehype-pretty-code-title] {
|
|
84
|
+
@apply pb-1 text-sm text-zinc-400 dark:text-neutral-400 text-center;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* 代码块的代码部分 */
|
|
88
|
+
article div[data-rehype-pretty-code-fragment] > pre {
|
|
89
|
+
@apply pt-6 my-0;
|
|
90
|
+
}
|
|
91
|
+
article div[data-rehype-pretty-code-fragment] > pre > code {
|
|
92
|
+
@apply my-0 pt-0 px-0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* 代码块的使用语言 */
|
|
96
|
+
article div[data-rehype-pretty-code-fragment] > pre::before {
|
|
97
|
+
@apply fixed top-0 right-0 px-2 text-sm uppercase bg-neutral-300 text-zinc-900 bg-opacity-80 dark:bg-opacity-60 rounded-sm;
|
|
98
|
+
content: attr(data-language);
|
|
70
99
|
}
|
|
71
100
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@apply
|
|
101
|
+
/* 代码块的代码行 */
|
|
102
|
+
article div[data-rehype-pretty-code-fragment] > pre > code .line {
|
|
103
|
+
@apply pl-3 pr-4;
|
|
75
104
|
}
|
|
76
105
|
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
/* 代码块的行内高亮文字 */
|
|
107
|
+
article div[data-rehype-pretty-code-fragment] > pre > code .line .word {
|
|
108
|
+
@apply px-1.5 inline-block bg-neutral-300 bg-opacity-20 rounded-sm;
|
|
79
109
|
}
|
|
80
110
|
|
|
81
|
-
|
|
82
|
-
|
|
111
|
+
/* 代码块的行号 */
|
|
112
|
+
article div[data-rehype-pretty-code-fragment] > pre > code {
|
|
113
|
+
counter-reset: line;
|
|
114
|
+
}
|
|
115
|
+
article div[data-rehype-pretty-code-fragment] > pre > code > .line::before {
|
|
116
|
+
@apply text-neutral-600 w-4 mr-4 inline-block text-right;
|
|
117
|
+
counter-increment: line;
|
|
118
|
+
content: counter(line);
|
|
83
119
|
}
|
|
84
120
|
|
|
121
|
+
/* 代码块的高亮行 */
|
|
122
|
+
article div[data-rehype-pretty-code-fragment] pre > code > .line {
|
|
123
|
+
@apply border-l-2 border-transparent;
|
|
124
|
+
}
|
|
125
|
+
article div[data-rehype-pretty-code-fragment] pre > code > .line.highlighted {
|
|
126
|
+
@apply bg-neutral-100 dark:bg-neutral-300 bg-opacity-10 dark:bg-opacity-10 border-l-blue-400 dark:border-l-sky-600;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* 链接 */
|
|
85
130
|
article a {
|
|
86
|
-
@apply text-
|
|
131
|
+
@apply mx-1 text-cyan-600 dark:text-fuchsia-200 hover:text-cyan-900 dark:hover:text-fuchsia-400 transition;
|
|
87
132
|
background-image: linear-gradient(
|
|
88
133
|
transparent 60%,
|
|
89
134
|
rgba(130, 199, 255, 0.28) 55%
|
|
90
135
|
);
|
|
91
136
|
}
|
|
137
|
+
.dark article a {
|
|
138
|
+
background-image: linear-gradient(
|
|
139
|
+
transparent 60%,
|
|
140
|
+
rgba(238, 157, 234, 0.28) 55%
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* 行内代码块链接 */
|
|
145
|
+
article a > code {
|
|
146
|
+
@apply text-cyan-600 dark:text-fuchsia-200 hover:text-cyan-900 dark:hover:text-fuchsia-400 transition;
|
|
147
|
+
background-image: linear-gradient(
|
|
148
|
+
transparent 60%,
|
|
149
|
+
rgba(130, 199, 255, 0.28) 55%
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
.dark article a > code {
|
|
153
|
+
background-image: linear-gradient(
|
|
154
|
+
transparent 60%,
|
|
155
|
+
rgba(238, 157, 234, 0.28) 55%
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
article table {
|
|
160
|
+
@apply table-auto w-full shadow rounded-xl text-left overflow-hidden dark:shadow-gray-800 my-8;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
article table thead {
|
|
164
|
+
@apply bg-blue-100 dark:bg-gray-800;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
article table thead th {
|
|
168
|
+
@apply py-3 px-4 text-gray-700 dark:text-white;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
article table tbody tr {
|
|
172
|
+
@apply border-b border-b-zinc-100 dark:border-b-gray-600;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
article table tbody td {
|
|
176
|
+
@apply py-2 px-4 text-gray-700 dark:text-white;
|
|
177
|
+
}
|
|
92
178
|
|
|
93
179
|
.link-with-underline {
|
|
94
180
|
@apply text-blue-600 mx-1 hover:text-blue-300 transition dark:text-blue-400;
|
|
@@ -122,6 +208,8 @@ html {
|
|
|
122
208
|
|
|
123
209
|
:root {
|
|
124
210
|
--anchor-offset: 28px;
|
|
211
|
+
|
|
212
|
+
color-scheme: var(--color-scheme, light);
|
|
125
213
|
}
|
|
126
214
|
|
|
127
215
|
/** Anchor with offset for headings */
|
|
@@ -161,39 +249,51 @@ h6 {
|
|
|
161
249
|
@apply border-l-8;
|
|
162
250
|
}
|
|
163
251
|
|
|
164
|
-
.mdx-message
|
|
252
|
+
.mdx-message code {
|
|
253
|
+
@apply dark:bg-opacity-50;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.mdx-message-text :first-child {
|
|
165
257
|
@apply mt-0;
|
|
166
258
|
}
|
|
167
259
|
|
|
260
|
+
.mdx-message-text img {
|
|
261
|
+
@apply rounded-md;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.mdx-message-text pre {
|
|
265
|
+
@apply my-2;
|
|
266
|
+
}
|
|
267
|
+
|
|
168
268
|
.mdx-message-info {
|
|
169
|
-
@apply bg-blue-50 border-blue-300 dark:bg-blue-
|
|
269
|
+
@apply bg-blue-50 border-blue-300 dark:bg-blue-900 dark:border-blue-500;
|
|
170
270
|
}
|
|
171
271
|
|
|
172
|
-
.mdx-message-info
|
|
173
|
-
@apply text-blue-
|
|
272
|
+
.mdx-message-info code {
|
|
273
|
+
@apply text-blue-800 dark:text-blue-200;
|
|
174
274
|
}
|
|
175
275
|
|
|
176
276
|
.mdx-message-success {
|
|
177
|
-
@apply bg-green-50 border-green-300 dark:bg-green-
|
|
277
|
+
@apply bg-green-50 border-green-300 dark:bg-green-700 dark:border-green-500;
|
|
178
278
|
}
|
|
179
279
|
|
|
180
|
-
.mdx-message-success
|
|
181
|
-
@apply text-green-
|
|
280
|
+
.mdx-message-success code {
|
|
281
|
+
@apply text-green-800 dark:text-green-200;
|
|
182
282
|
}
|
|
183
283
|
|
|
184
284
|
.mdx-message-warning {
|
|
185
|
-
@apply bg-orange-50 border-orange-300 dark:bg-orange-
|
|
285
|
+
@apply bg-orange-50 border-orange-300 dark:bg-orange-700 dark:border-orange-500;
|
|
186
286
|
}
|
|
187
287
|
|
|
188
|
-
.mdx-message-warning
|
|
189
|
-
@apply text-orange-
|
|
288
|
+
.mdx-message-warning code {
|
|
289
|
+
@apply text-orange-700 dark:text-orange-100;
|
|
190
290
|
}
|
|
191
291
|
|
|
192
292
|
.mdx-message-error {
|
|
193
|
-
@apply bg-red-50 border-red-300 dark:bg-
|
|
293
|
+
@apply bg-red-50 border-red-300 dark:bg-rose-700 dark:border-rose-500;
|
|
194
294
|
}
|
|
195
295
|
|
|
196
|
-
.mdx-message-error
|
|
197
|
-
@apply text-red-
|
|
296
|
+
.mdx-message-error code {
|
|
297
|
+
@apply text-red-700 dark:text-rose-100;
|
|
198
298
|
}
|
|
199
299
|
}
|