@umijs/plugin-docs 4.0.0-rc.2 โ†’ 4.0.0-rc.20

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.
Files changed (34) hide show
  1. package/client/theme-doc/Head.tsx +28 -16
  2. package/client/theme-doc/LangSwitch.tsx +13 -4
  3. package/client/theme-doc/Layout.tsx +36 -25
  4. package/client/theme-doc/Logo.tsx +13 -5
  5. package/client/theme-doc/NavBar.tsx +58 -15
  6. package/client/theme-doc/Search.tsx +54 -24
  7. package/client/theme-doc/Sidebar.tsx +6 -3
  8. package/client/theme-doc/ThemeSwitch.tsx +10 -2
  9. package/client/theme-doc/Toc.tsx +12 -14
  10. package/client/theme-doc/components/Announcement.tsx +1 -0
  11. package/client/theme-doc/components/Features.tsx +1 -1
  12. package/client/theme-doc/components/Message.tsx +39 -21
  13. package/client/theme-doc/context.ts +10 -1
  14. package/client/theme-doc/firefox-polyfill.css +6 -5
  15. package/client/theme-doc/tailwind.css +168 -20
  16. package/client/theme-doc/tailwind.out.css +556 -166
  17. package/client/theme-doc/useLanguage.ts +15 -5
  18. package/client/theme-doc/utils/getLinkFromTitle.ts +15 -0
  19. package/client/theme-doc/utils/getTocTitle.ts +9 -0
  20. package/compiled/@mdx-js/mdx/LICENSE +21 -0
  21. package/compiled/@mdx-js/mdx/index.js +8 -0
  22. package/compiled/@mdx-js/mdx/package.json +1 -0
  23. package/compiled/rehype-slug/LICENSE +22 -0
  24. package/compiled/rehype-slug/index.js +1 -0
  25. package/compiled/rehype-slug/package.json +1 -0
  26. package/compiled/remark-gfm/LICENSE +22 -0
  27. package/compiled/remark-gfm/index.js +1 -0
  28. package/compiled/remark-gfm/package.json +1 -0
  29. package/dist/compiler.d.ts +1 -0
  30. package/dist/compiler.js +55 -21
  31. package/dist/index.js +49 -22
  32. package/dist/loader.js +14 -15
  33. package/dist/markdown.js +3 -1
  34. package/package.json +18 -10
@@ -9,41 +9,59 @@ 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
- let bgColor = 'bg-blue-50';
17
- let textColor = 'text-blue-900';
17
+ const messageType = props.type || MessageType.Info;
18
+ const messageTitle = props.title;
19
+ const propsChildren = props.children;
18
20
 
19
- switch (props.type) {
21
+ let messageClass: string;
22
+ switch (messageType) {
20
23
  case MessageType.Success:
21
- bgColor = 'bg-green-50';
22
- textColor = 'text-green-900';
24
+ messageClass = 'mdx-message-success';
23
25
  break;
24
26
  case MessageType.Warning:
25
- bgColor = 'bg-orange-50';
26
- textColor = 'text-orange-900';
27
+ messageClass = 'mdx-message-warning';
27
28
  break;
28
29
  case MessageType.Error:
29
- bgColor = 'bg-red-50';
30
- textColor = 'text-red-900';
30
+ messageClass = 'mdx-message-error';
31
31
  break;
32
+ default:
33
+ messageClass = 'mdx-message-info';
34
+ }
35
+
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
+ }
32
51
  }
33
52
 
34
53
  return (
35
- <>
36
- <div
37
- className={`w-full py-3 px-4 ${bgColor} ${textColor} rounded-lg my-2`}
38
- >
39
- {props.emoji && (
40
- <span role="img" className="mr-3">
41
- {props.emoji}
42
- </span>
43
- )}
44
- {props.children}
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>
45
63
  </div>
46
- </>
64
+ </div>
47
65
  );
48
66
  }
49
67
 
@@ -9,21 +9,27 @@ 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
+ dropdown?: { title: string; path: string }[];
21
26
  children: any[];
22
27
  }[];
23
28
  announcement?: {
24
29
  title: string;
25
30
  link?: string;
26
31
  };
32
+ themeSwitch?: {};
27
33
  };
28
34
  location: {
29
35
  pathname: string;
@@ -31,6 +37,9 @@ interface IContext {
31
37
  hash: string;
32
38
  key: string;
33
39
  };
40
+ history: {
41
+ push(to: string, state?: any): void;
42
+ };
34
43
  }
35
44
 
36
45
  export const ThemeContext = React.createContext<IContext | null>(null);
@@ -3,7 +3,8 @@
3
3
  https://www.cnblogs.com/coco1s/p/14953143.html
4
4
  */
5
5
 
6
- .g-glossy-firefox, .g-glossy-firefox-cover {
6
+ .g-glossy-firefox,
7
+ .g-glossy-firefox-cover {
7
8
  display: none;
8
9
  }
9
10
 
@@ -11,9 +12,9 @@
11
12
  .g-glossy-firefox-cover {
12
13
  display: block;
13
14
  position: fixed;
14
- top: var(--anchor-offset);
15
+ top: 0;
15
16
  width: 100%;
16
- height: 72px;
17
+ height: calc(var(--anchor-offset) + 72px);
17
18
  z-index: 22;
18
19
  background-color: white;
19
20
  }
@@ -22,8 +23,8 @@
22
23
  display: block;
23
24
  position: fixed;
24
25
  width: 100%;
25
- top: var(--anchor-offset);
26
- height: 72px;
26
+ top: 0;
27
+ height: calc(var(--anchor-offset) + 72px);
27
28
  z-index: 24;
28
29
  background: -moz-element(#article-body) no-repeat top;
29
30
  filter: blur(10px);
@@ -28,7 +28,7 @@ article h6 {
28
28
  }
29
29
 
30
30
  article p {
31
- @apply text-base font-light leading-8 mt-4 text-gray-700 dark:text-white;
31
+ @apply text-base leading-8 mt-4 text-gray-700 dark:text-white;
32
32
  }
33
33
 
34
34
  article ul {
@@ -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,45 +51,137 @@ article h2 a {
51
51
  @apply no-underline dark:text-white;
52
52
  }
53
53
 
54
+ /* ่กŒๅ†…ไปฃ็  */
54
55
  article code {
55
- @apply bg-black bg-opacity-5 border border-black border-opacity-5 rounded-md dark:text-white;
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
- article inlinecode {
63
- @apply bg-black bg-opacity-5 border border-black border-opacity-5 rounded-md px-1.5 py-0.5 text-xs dark:text-white dark:bg-gray-700;
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 p-4 bg-slate-100 dark:bg-slate-800 rounded-xl my-8 overflow-x-auto font-medium subpixel-antialiased dark:text-white;
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;
70
85
  }
71
86
 
72
- article pre code {
73
- line-height: 1.25rem;
74
- @apply relative p-0 text-sm text-current bg-transparent rounded-none border-none inline-block min-w-full dark:text-white;
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);
75
99
  }
76
100
 
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;
101
+ /* ไปฃ็ ๅ—็š„ไปฃ็ ่กŒ */
102
+ article div[data-rehype-pretty-code-fragment] > pre > code .line {
103
+ @apply pl-3 pr-4;
79
104
  }
80
105
 
81
- article a code {
82
- @apply text-current no-underline dark:text-white;
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;
83
109
  }
84
110
 
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);
119
+ }
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-blue-600 mx-1 hover:text-blue-300 transition dark:text-blue-400;
87
- background-image: linear-gradient(transparent 60%, rgba(130, 199, 255, 0.28) 55%);
131
+ @apply mx-1 text-cyan-600 dark:text-fuchsia-200 hover:text-cyan-900 dark:hover:text-fuchsia-400 transition;
132
+ background-image: linear-gradient(
133
+ transparent 60%,
134
+ rgba(130, 199, 255, 0.28) 55%
135
+ );
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;
88
177
  }
89
178
 
90
179
  .link-with-underline {
91
180
  @apply text-blue-600 mx-1 hover:text-blue-300 transition dark:text-blue-400;
92
- background-image: linear-gradient(transparent 60%, rgba(130, 199, 255, 0.28) 55%);
181
+ background-image: linear-gradient(
182
+ transparent 60%,
183
+ rgba(130, 199, 255, 0.28) 55%
184
+ );
93
185
  }
94
186
 
95
187
  /*article pre {*/
@@ -111,7 +203,7 @@ article hr {
111
203
  }
112
204
 
113
205
  html {
114
- scroll-behavior: smooth
206
+ scroll-behavior: smooth;
115
207
  }
116
208
 
117
209
  :root {
@@ -119,12 +211,16 @@ html {
119
211
  }
120
212
 
121
213
  /** Anchor with offset for headings */
122
- h1, h2, h3, h4, h5, h6 {
214
+ h1,
215
+ h2,
216
+ h3,
217
+ h4,
218
+ h5,
219
+ h6 {
123
220
  scroll-margin-top: calc(var(--anchor-offset) + 88px);
124
221
  }
125
222
 
126
223
  @layer components {
127
-
128
224
  .features-dark {
129
225
  @apply bg-gray-900;
130
226
  background-image: radial-gradient(#2a2a2a 20%, transparent 20%);
@@ -146,4 +242,56 @@ h1, h2, h3, h4, h5, h6 {
146
242
  .features::-webkit-scrollbar {
147
243
  display: none;
148
244
  }
245
+
246
+ .mdx-message {
247
+ @apply border-l-8;
248
+ }
249
+
250
+ .mdx-message code {
251
+ @apply dark:bg-opacity-50;
252
+ }
253
+
254
+ .mdx-message-text :first-child {
255
+ @apply mt-0;
256
+ }
257
+
258
+ .mdx-message-text img {
259
+ @apply rounded-md;
260
+ }
261
+
262
+ .mdx-message-text pre {
263
+ @apply my-2;
264
+ }
265
+
266
+ .mdx-message-info {
267
+ @apply bg-blue-50 border-blue-300 dark:bg-blue-900 dark:border-blue-500;
268
+ }
269
+
270
+ .mdx-message-info code {
271
+ @apply text-blue-800 dark:text-blue-200;
272
+ }
273
+
274
+ .mdx-message-success {
275
+ @apply bg-green-50 border-green-300 dark:bg-green-700 dark:border-green-500;
276
+ }
277
+
278
+ .mdx-message-success code {
279
+ @apply text-green-800 dark:text-green-200;
280
+ }
281
+
282
+ .mdx-message-warning {
283
+ @apply bg-orange-50 border-orange-300 dark:bg-orange-700 dark:border-orange-500;
284
+ }
285
+
286
+ .mdx-message-warning code {
287
+ @apply text-orange-700 dark:text-orange-100;
288
+ }
289
+
290
+ .mdx-message-error {
291
+ @apply bg-red-50 border-red-300 dark:bg-rose-700 dark:border-rose-500;
292
+ }
293
+
294
+ .mdx-message-error code {
295
+ @apply text-red-700 dark:text-rose-100;
296
+ }
149
297
  }