@umijs/plugin-docs 4.0.0-rc.2 → 4.0.0-rc.5
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/LangSwitch.tsx +1 -1
- package/client/theme-doc/Layout.tsx +6 -2
- package/client/theme-doc/Logo.tsx +5 -1
- package/client/theme-doc/ThemeSwitch.tsx +2 -2
- package/client/theme-doc/Toc.tsx +1 -1
- package/client/theme-doc/components/Message.tsx +22 -16
- package/client/theme-doc/firefox-polyfill.css +2 -1
- package/client/theme-doc/tailwind.css +56 -6
- package/client/theme-doc/tailwind.out.css +135 -53
- package/client/theme-doc/useLanguage.ts +5 -3
- package/dist/index.js +36 -15
- package/package.json +2 -2
|
@@ -25,7 +25,7 @@ export default () => {
|
|
|
25
25
|
return (
|
|
26
26
|
<div>
|
|
27
27
|
<div
|
|
28
|
-
className="w-24 rounded-lg overflow-hidden cursor-pointer border
|
|
28
|
+
className="w-24 rounded-lg overflow-hidden cursor-pointer border text-center
|
|
29
29
|
border-white hover:border-gray-100 dark:border-gray-800"
|
|
30
30
|
onClick={handleClick}
|
|
31
31
|
>
|
|
@@ -31,6 +31,10 @@ export default (props: any) => {
|
|
|
31
31
|
|
|
32
32
|
const { title, description } = props.themeConfig;
|
|
33
33
|
|
|
34
|
+
const isHomePage =
|
|
35
|
+
window.location.pathname === '/' ||
|
|
36
|
+
window.location.pathname.replace(/[a-z]{2}-[A-Z]{2}\/?/, '') === '/';
|
|
37
|
+
|
|
34
38
|
return (
|
|
35
39
|
<ThemeContext.Provider
|
|
36
40
|
value={{
|
|
@@ -54,7 +58,7 @@ export default (props: any) => {
|
|
|
54
58
|
<div className="g-glossy-firefox-cover" />
|
|
55
59
|
<div className="g-glossy-firefox" id="firefox-head-bg" />
|
|
56
60
|
|
|
57
|
-
{
|
|
61
|
+
{isHomePage ? (
|
|
58
62
|
<div id="article-body">
|
|
59
63
|
<Helmet>
|
|
60
64
|
<title>
|
|
@@ -71,7 +75,7 @@ export default (props: any) => {
|
|
|
71
75
|
className="w-full flex flex-row justify-center overflow-x-hidden"
|
|
72
76
|
>
|
|
73
77
|
<div className="container flex flex-row justify-center">
|
|
74
|
-
<div className="w-full lg:w-1/2 px-4 lg:px-
|
|
78
|
+
<div className="w-full lg:w-1/2 px-4 lg:px-2 m-8 z-20 lg:py-12">
|
|
75
79
|
<article className="flex-1">{props.children}</article>
|
|
76
80
|
</div>
|
|
77
81
|
</div>
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useThemeContext } from './context';
|
|
3
|
+
import useLanguage from './useLanguage';
|
|
3
4
|
|
|
4
5
|
export default () => {
|
|
5
6
|
const { themeConfig, components } = useThemeContext()!;
|
|
7
|
+
const { isFromPath, currentLanguage } = useLanguage();
|
|
8
|
+
|
|
6
9
|
// @ts-ignore
|
|
7
10
|
const { logo } = themeConfig;
|
|
11
|
+
|
|
8
12
|
return (
|
|
9
|
-
<components.Link to=
|
|
13
|
+
<components.Link to={isFromPath ? '/' + currentLanguage?.locale : '/'}>
|
|
10
14
|
<div className="flex flex-row items-center">
|
|
11
15
|
<img src={logo} className="w-8 h-8" alt="logo" />
|
|
12
16
|
<div className="text-xl font-extrabold ml-2 dark:text-white">
|
|
@@ -36,9 +36,9 @@ export default () => {
|
|
|
36
36
|
return (
|
|
37
37
|
<div
|
|
38
38
|
className={cx(
|
|
39
|
-
'md:w-12 md:h-6 w-12 h-4 flex items-center
|
|
39
|
+
'md:w-12 md:h-6 w-12 h-4 flex items-center rounded-full ',
|
|
40
40
|
'py-1 px-1.5 cursor-pointer',
|
|
41
|
-
toggle ? 'bg-
|
|
41
|
+
toggle ? 'bg-gray-100' : 'bg-gray-700',
|
|
42
42
|
)}
|
|
43
43
|
onClick={() => setToggle(!toggle)}
|
|
44
44
|
>
|
package/client/theme-doc/Toc.tsx
CHANGED
|
@@ -40,7 +40,7 @@ export default () => {
|
|
|
40
40
|
<p className="text-lg font-extrabold dark:text-white">
|
|
41
41
|
{route.titles[0].title}
|
|
42
42
|
</p>
|
|
43
|
-
<ul className="max-h-[calc(100vh-360px)] overflow-y-
|
|
43
|
+
<ul className="max-h-[calc(100vh-360px)] overflow-y-auto py-2">
|
|
44
44
|
{titles.map((item: any) => {
|
|
45
45
|
return (
|
|
46
46
|
<li
|
|
@@ -13,35 +13,41 @@ interface MessageProps {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function Message(props: PropsWithChildren<MessageProps>) {
|
|
16
|
-
|
|
17
|
-
let textColor = 'text-blue-900';
|
|
16
|
+
const messageType = props.type || 'info';
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
let messageClass: string;
|
|
19
|
+
switch (messageType) {
|
|
20
20
|
case MessageType.Success:
|
|
21
|
-
|
|
22
|
-
textColor = 'text-green-900';
|
|
21
|
+
messageClass = 'mdx-message-success';
|
|
23
22
|
break;
|
|
24
23
|
case MessageType.Warning:
|
|
25
|
-
|
|
26
|
-
textColor = 'text-orange-900';
|
|
24
|
+
messageClass = 'mdx-message-warning';
|
|
27
25
|
break;
|
|
28
26
|
case MessageType.Error:
|
|
29
|
-
|
|
30
|
-
textColor = 'text-red-900';
|
|
27
|
+
messageClass = 'mdx-message-error';
|
|
31
28
|
break;
|
|
29
|
+
default:
|
|
30
|
+
messageClass = 'mdx-message-info';
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
const messageText =
|
|
34
|
+
typeof props.children === 'string'
|
|
35
|
+
? props.children
|
|
36
|
+
: (props.children as React.ReactElement).props.children;
|
|
37
|
+
|
|
34
38
|
return (
|
|
35
39
|
<>
|
|
36
40
|
<div
|
|
37
|
-
className={`w-full py-3 px-4
|
|
41
|
+
className={`w-full py-3 px-4 rounded-lg my-4 mdx-message ${messageClass}`}
|
|
38
42
|
>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
<p>
|
|
44
|
+
{props.emoji && (
|
|
45
|
+
<span role="img" className="mr-3 inline">
|
|
46
|
+
{props.emoji}
|
|
47
|
+
</span>
|
|
48
|
+
)}
|
|
49
|
+
{messageText}
|
|
50
|
+
</p>
|
|
45
51
|
</div>
|
|
46
52
|
</>
|
|
47
53
|
);
|
|
@@ -28,7 +28,7 @@ article h6 {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
article p {
|
|
31
|
-
@apply text-base
|
|
31
|
+
@apply text-base leading-8 mt-4 text-gray-700 dark:text-white;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
article ul {
|
|
@@ -84,12 +84,18 @@ article a code {
|
|
|
84
84
|
|
|
85
85
|
article a {
|
|
86
86
|
@apply text-blue-600 mx-1 hover:text-blue-300 transition dark:text-blue-400;
|
|
87
|
-
background-image: linear-gradient(
|
|
87
|
+
background-image: linear-gradient(
|
|
88
|
+
transparent 60%,
|
|
89
|
+
rgba(130, 199, 255, 0.28) 55%
|
|
90
|
+
);
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
.link-with-underline {
|
|
91
94
|
@apply text-blue-600 mx-1 hover:text-blue-300 transition dark:text-blue-400;
|
|
92
|
-
background-image: linear-gradient(
|
|
95
|
+
background-image: linear-gradient(
|
|
96
|
+
transparent 60%,
|
|
97
|
+
rgba(130, 199, 255, 0.28) 55%
|
|
98
|
+
);
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
/*article pre {*/
|
|
@@ -111,7 +117,7 @@ article hr {
|
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
html {
|
|
114
|
-
scroll-behavior: smooth
|
|
120
|
+
scroll-behavior: smooth;
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
:root {
|
|
@@ -119,12 +125,16 @@ html {
|
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
/** Anchor with offset for headings */
|
|
122
|
-
h1,
|
|
128
|
+
h1,
|
|
129
|
+
h2,
|
|
130
|
+
h3,
|
|
131
|
+
h4,
|
|
132
|
+
h5,
|
|
133
|
+
h6 {
|
|
123
134
|
scroll-margin-top: calc(var(--anchor-offset) + 88px);
|
|
124
135
|
}
|
|
125
136
|
|
|
126
137
|
@layer components {
|
|
127
|
-
|
|
128
138
|
.features-dark {
|
|
129
139
|
@apply bg-gray-900;
|
|
130
140
|
background-image: radial-gradient(#2a2a2a 20%, transparent 20%);
|
|
@@ -146,4 +156,44 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
146
156
|
.features::-webkit-scrollbar {
|
|
147
157
|
display: none;
|
|
148
158
|
}
|
|
159
|
+
|
|
160
|
+
.mdx-message {
|
|
161
|
+
@apply border-l-8;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.mdx-message > p {
|
|
165
|
+
@apply mt-0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.mdx-message-info {
|
|
169
|
+
@apply bg-blue-50 border-blue-300 dark:bg-blue-100 dark:border-blue-500;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.mdx-message-info > p {
|
|
173
|
+
@apply text-blue-900 dark:text-blue-900;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.mdx-message-success {
|
|
177
|
+
@apply bg-green-50 border-green-300 dark:bg-green-100 dark:border-green-500;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.mdx-message-success > p {
|
|
181
|
+
@apply text-green-900 dark:text-green-900;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.mdx-message-warning {
|
|
185
|
+
@apply bg-orange-50 border-orange-300 dark:bg-orange-100 dark:border-orange-500;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.mdx-message-warning > p {
|
|
189
|
+
@apply text-orange-900 dark:text-orange-900;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.mdx-message-error {
|
|
193
|
+
@apply bg-red-50 border-red-300 dark:bg-red-100 dark:border-red-500;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.mdx-message-error > p {
|
|
197
|
+
@apply text-red-900 dark:text-red-900;
|
|
198
|
+
}
|
|
149
199
|
}
|
|
@@ -515,6 +515,110 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
515
515
|
display: none;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
+
.mdx-message {
|
|
519
|
+
border-left-width: 8px;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.mdx-message > p {
|
|
523
|
+
margin-top: 0px;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.mdx-message-info {
|
|
527
|
+
--tw-border-opacity: 1;
|
|
528
|
+
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
|
529
|
+
--tw-bg-opacity: 1;
|
|
530
|
+
background-color: rgb(239 246 255 / var(--tw-bg-opacity));
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.dark .mdx-message-info {
|
|
534
|
+
--tw-border-opacity: 1;
|
|
535
|
+
border-color: rgb(59 130 246 / var(--tw-border-opacity));
|
|
536
|
+
--tw-bg-opacity: 1;
|
|
537
|
+
background-color: rgb(219 234 254 / var(--tw-bg-opacity));
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.mdx-message-info > p {
|
|
541
|
+
--tw-text-opacity: 1;
|
|
542
|
+
color: rgb(30 58 138 / var(--tw-text-opacity));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.dark .mdx-message-info > p {
|
|
546
|
+
--tw-text-opacity: 1;
|
|
547
|
+
color: rgb(30 58 138 / var(--tw-text-opacity));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.mdx-message-success {
|
|
551
|
+
--tw-border-opacity: 1;
|
|
552
|
+
border-color: rgb(134 239 172 / var(--tw-border-opacity));
|
|
553
|
+
--tw-bg-opacity: 1;
|
|
554
|
+
background-color: rgb(240 253 244 / var(--tw-bg-opacity));
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.dark .mdx-message-success {
|
|
558
|
+
--tw-border-opacity: 1;
|
|
559
|
+
border-color: rgb(34 197 94 / var(--tw-border-opacity));
|
|
560
|
+
--tw-bg-opacity: 1;
|
|
561
|
+
background-color: rgb(220 252 231 / var(--tw-bg-opacity));
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
.mdx-message-success > p {
|
|
565
|
+
--tw-text-opacity: 1;
|
|
566
|
+
color: rgb(20 83 45 / var(--tw-text-opacity));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.dark .mdx-message-success > p {
|
|
570
|
+
--tw-text-opacity: 1;
|
|
571
|
+
color: rgb(20 83 45 / var(--tw-text-opacity));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.mdx-message-warning {
|
|
575
|
+
--tw-border-opacity: 1;
|
|
576
|
+
border-color: rgb(253 186 116 / var(--tw-border-opacity));
|
|
577
|
+
--tw-bg-opacity: 1;
|
|
578
|
+
background-color: rgb(255 247 237 / var(--tw-bg-opacity));
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.dark .mdx-message-warning {
|
|
582
|
+
--tw-border-opacity: 1;
|
|
583
|
+
border-color: rgb(249 115 22 / var(--tw-border-opacity));
|
|
584
|
+
--tw-bg-opacity: 1;
|
|
585
|
+
background-color: rgb(255 237 213 / var(--tw-bg-opacity));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.mdx-message-warning > p {
|
|
589
|
+
--tw-text-opacity: 1;
|
|
590
|
+
color: rgb(124 45 18 / var(--tw-text-opacity));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.dark .mdx-message-warning > p {
|
|
594
|
+
--tw-text-opacity: 1;
|
|
595
|
+
color: rgb(124 45 18 / var(--tw-text-opacity));
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.mdx-message-error {
|
|
599
|
+
--tw-border-opacity: 1;
|
|
600
|
+
border-color: rgb(252 165 165 / var(--tw-border-opacity));
|
|
601
|
+
--tw-bg-opacity: 1;
|
|
602
|
+
background-color: rgb(254 242 242 / var(--tw-bg-opacity));
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.dark .mdx-message-error {
|
|
606
|
+
--tw-border-opacity: 1;
|
|
607
|
+
border-color: rgb(239 68 68 / var(--tw-border-opacity));
|
|
608
|
+
--tw-bg-opacity: 1;
|
|
609
|
+
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.mdx-message-error > p {
|
|
613
|
+
--tw-text-opacity: 1;
|
|
614
|
+
color: rgb(127 29 29 / var(--tw-text-opacity));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.dark .mdx-message-error > p {
|
|
618
|
+
--tw-text-opacity: 1;
|
|
619
|
+
color: rgb(127 29 29 / var(--tw-text-opacity));
|
|
620
|
+
}
|
|
621
|
+
|
|
518
622
|
.fixed {
|
|
519
623
|
position: fixed;
|
|
520
624
|
}
|
|
@@ -615,6 +719,11 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
615
719
|
margin-right: 0.25rem;
|
|
616
720
|
}
|
|
617
721
|
|
|
722
|
+
.my-4 {
|
|
723
|
+
margin-top: 1rem;
|
|
724
|
+
margin-bottom: 1rem;
|
|
725
|
+
}
|
|
726
|
+
|
|
618
727
|
.ml-4 {
|
|
619
728
|
margin-left: 1rem;
|
|
620
729
|
}
|
|
@@ -663,6 +772,10 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
663
772
|
display: block;
|
|
664
773
|
}
|
|
665
774
|
|
|
775
|
+
.inline {
|
|
776
|
+
display: inline;
|
|
777
|
+
}
|
|
778
|
+
|
|
666
779
|
.flex {
|
|
667
780
|
display: flex;
|
|
668
781
|
}
|
|
@@ -892,6 +1005,10 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
892
1005
|
overflow: hidden;
|
|
893
1006
|
}
|
|
894
1007
|
|
|
1008
|
+
.overflow-y-auto {
|
|
1009
|
+
overflow-y: auto;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
895
1012
|
.overflow-x-hidden {
|
|
896
1013
|
overflow-x: hidden;
|
|
897
1014
|
}
|
|
@@ -972,16 +1089,6 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
972
1089
|
background-color: rgb(239 246 255 / var(--tw-bg-opacity));
|
|
973
1090
|
}
|
|
974
1091
|
|
|
975
|
-
.bg-gray-300 {
|
|
976
|
-
--tw-bg-opacity: 1;
|
|
977
|
-
background-color: rgb(209 213 219 / var(--tw-bg-opacity));
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
.bg-blue-300 {
|
|
981
|
-
--tw-bg-opacity: 1;
|
|
982
|
-
background-color: rgb(147 197 253 / var(--tw-bg-opacity));
|
|
983
|
-
}
|
|
984
|
-
|
|
985
1092
|
.bg-gray-700 {
|
|
986
1093
|
--tw-bg-opacity: 1;
|
|
987
1094
|
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
|
|
@@ -1002,21 +1109,6 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
1002
1109
|
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
|
1003
1110
|
}
|
|
1004
1111
|
|
|
1005
|
-
.bg-green-50 {
|
|
1006
|
-
--tw-bg-opacity: 1;
|
|
1007
|
-
background-color: rgb(240 253 244 / var(--tw-bg-opacity));
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
.bg-orange-50 {
|
|
1011
|
-
--tw-bg-opacity: 1;
|
|
1012
|
-
background-color: rgb(255 247 237 / var(--tw-bg-opacity));
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
.bg-red-50 {
|
|
1016
|
-
--tw-bg-opacity: 1;
|
|
1017
|
-
background-color: rgb(254 242 242 / var(--tw-bg-opacity));
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
1112
|
.object-cover {
|
|
1021
1113
|
-o-object-fit: cover;
|
|
1022
1114
|
object-fit: cover;
|
|
@@ -1192,26 +1284,6 @@ Ensure the default browser behavior of the `hidden` attribute.
|
|
|
1192
1284
|
color: rgb(147 197 253 / var(--tw-text-opacity));
|
|
1193
1285
|
}
|
|
1194
1286
|
|
|
1195
|
-
.text-blue-900 {
|
|
1196
|
-
--tw-text-opacity: 1;
|
|
1197
|
-
color: rgb(30 58 138 / var(--tw-text-opacity));
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
.text-green-900 {
|
|
1201
|
-
--tw-text-opacity: 1;
|
|
1202
|
-
color: rgb(20 83 45 / var(--tw-text-opacity));
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
.text-orange-900 {
|
|
1206
|
-
--tw-text-opacity: 1;
|
|
1207
|
-
color: rgb(124 45 18 / var(--tw-text-opacity));
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
.text-red-900 {
|
|
1211
|
-
--tw-text-opacity: 1;
|
|
1212
|
-
color: rgb(127 29 29 / var(--tw-text-opacity));
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1287
|
.opacity-0 {
|
|
1216
1288
|
opacity: 0;
|
|
1217
1289
|
}
|
|
@@ -1408,7 +1480,6 @@ article h6 {
|
|
|
1408
1480
|
article p {
|
|
1409
1481
|
margin-top: 1rem;
|
|
1410
1482
|
font-size: 1rem;
|
|
1411
|
-
font-weight: 300;
|
|
1412
1483
|
line-height: 2rem;
|
|
1413
1484
|
--tw-text-opacity: 1;
|
|
1414
1485
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
@@ -1614,7 +1685,10 @@ article a:hover {
|
|
|
1614
1685
|
}
|
|
1615
1686
|
|
|
1616
1687
|
article a {
|
|
1617
|
-
background-image: linear-gradient(
|
|
1688
|
+
background-image: linear-gradient(
|
|
1689
|
+
transparent 60%,
|
|
1690
|
+
rgba(130, 199, 255, 0.28) 55%
|
|
1691
|
+
);
|
|
1618
1692
|
}
|
|
1619
1693
|
|
|
1620
1694
|
.link-with-underline {
|
|
@@ -1640,7 +1714,10 @@ article a {
|
|
|
1640
1714
|
}
|
|
1641
1715
|
|
|
1642
1716
|
.link-with-underline {
|
|
1643
|
-
background-image: linear-gradient(
|
|
1717
|
+
background-image: linear-gradient(
|
|
1718
|
+
transparent 60%,
|
|
1719
|
+
rgba(130, 199, 255, 0.28) 55%
|
|
1720
|
+
);
|
|
1644
1721
|
}
|
|
1645
1722
|
|
|
1646
1723
|
/*article pre {*/
|
|
@@ -1672,7 +1749,7 @@ article hr {
|
|
|
1672
1749
|
}
|
|
1673
1750
|
|
|
1674
1751
|
html {
|
|
1675
|
-
scroll-behavior: smooth
|
|
1752
|
+
scroll-behavior: smooth;
|
|
1676
1753
|
}
|
|
1677
1754
|
|
|
1678
1755
|
:root {
|
|
@@ -1681,7 +1758,12 @@ html {
|
|
|
1681
1758
|
|
|
1682
1759
|
/** Anchor with offset for headings */
|
|
1683
1760
|
|
|
1684
|
-
h1,
|
|
1761
|
+
h1,
|
|
1762
|
+
h2,
|
|
1763
|
+
h3,
|
|
1764
|
+
h4,
|
|
1765
|
+
h5,
|
|
1766
|
+
h6 {
|
|
1685
1767
|
scroll-margin-top: calc(var(--anchor-offset) + 88px);
|
|
1686
1768
|
}
|
|
1687
1769
|
|
|
@@ -1975,9 +2057,9 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
1975
2057
|
width: 75%;
|
|
1976
2058
|
}
|
|
1977
2059
|
|
|
1978
|
-
.lg\:px-
|
|
1979
|
-
padding-left:
|
|
1980
|
-
padding-right:
|
|
2060
|
+
.lg\:px-2 {
|
|
2061
|
+
padding-left: 0.5rem;
|
|
2062
|
+
padding-right: 0.5rem;
|
|
1981
2063
|
}
|
|
1982
2064
|
|
|
1983
2065
|
.lg\:py-12 {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { history } from 'umi';
|
|
1
3
|
import { useThemeContext } from './context';
|
|
2
4
|
|
|
3
5
|
interface useLanguageResult {
|
|
@@ -36,19 +38,19 @@ function useLanguage(): useLanguageResult {
|
|
|
36
38
|
let p = location.pathname.split('/');
|
|
37
39
|
p.shift();
|
|
38
40
|
p.shift();
|
|
39
|
-
|
|
41
|
+
history.push('/' + p.join('/'));
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
// 当前在默认语言,切换到其他语言
|
|
44
46
|
if (!isFromPath) {
|
|
45
|
-
|
|
47
|
+
history.push('/' + locale + location.pathname);
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
let p = location.pathname.split('/');
|
|
50
52
|
p[1] = locale;
|
|
51
|
-
|
|
53
|
+
history.push('/' + p.join('/'));
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
function render(key: string) {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,6 +29,20 @@ const fs_1 = __importStar(require("fs"));
|
|
|
25
29
|
const path_1 = require("path");
|
|
26
30
|
const markdown_1 = require("./markdown");
|
|
27
31
|
exports.default = (api) => {
|
|
32
|
+
// 把用户当前有设置在 docs/locales 下的语系放到变量 locales 中,方便后续使用
|
|
33
|
+
const locales = {};
|
|
34
|
+
const localesPath = (0, path_1.join)(api.cwd, 'docs/locales');
|
|
35
|
+
if ((0, fs_1.existsSync)(localesPath)) {
|
|
36
|
+
fs_1.default.readdirSync(localesPath).forEach((file) => {
|
|
37
|
+
if (file.endsWith('.json')) {
|
|
38
|
+
const filePath = (0, path_1.join)(localesPath, file);
|
|
39
|
+
const content = fs_1.default.readFileSync(filePath).toString();
|
|
40
|
+
const json = JSON.parse(content);
|
|
41
|
+
const localeName = file.replace('.json', '');
|
|
42
|
+
locales[localeName] = json;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
28
46
|
api.modifyDefaultConfig((memo) => {
|
|
29
47
|
memo.conventionRoutes = Object.assign(Object.assign({}, memo.conventionRoutes), { base: (0, path_1.join)(api.cwd, 'docs') });
|
|
30
48
|
memo.mdx = {
|
|
@@ -56,6 +74,22 @@ exports.default = (api) => {
|
|
|
56
74
|
}
|
|
57
75
|
}
|
|
58
76
|
});
|
|
77
|
+
// 检查路由是否存在其他语言,没有的话做 fallback 处理
|
|
78
|
+
api.modifyRoutes((r) => {
|
|
79
|
+
if (!locales)
|
|
80
|
+
return r;
|
|
81
|
+
for (const route in r) {
|
|
82
|
+
if (r[route].path.match(/^[a-z]{2}-[A-Z]{2}\/.*/))
|
|
83
|
+
continue;
|
|
84
|
+
const defaultLangFile = r[route].file.replace(/(.[a-z]{2}-[A-Z]{2})?.md$/, '');
|
|
85
|
+
Object.keys(locales).map((l) => {
|
|
86
|
+
if (r[defaultLangFile] && !r[defaultLangFile + '.' + l]) {
|
|
87
|
+
r[defaultLangFile + '.' + l] = Object.assign(Object.assign({}, r[defaultLangFile]), { path: `/${l}/${r[defaultLangFile].path}` });
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return r;
|
|
92
|
+
});
|
|
59
93
|
api.onGenerateFiles(() => {
|
|
60
94
|
var _a;
|
|
61
95
|
// theme path
|
|
@@ -67,20 +101,7 @@ exports.default = (api) => {
|
|
|
67
101
|
const themeConfigPath = (0, path_1.join)(api.cwd, 'theme.config.ts');
|
|
68
102
|
const themeExists = (0, fs_1.existsSync)(themeConfigPath);
|
|
69
103
|
// 将 docs/locales 目录下的 json 文件注入到 themeConfig.locales 中
|
|
70
|
-
let injectLocale =
|
|
71
|
-
const localesPath = (0, path_1.join)(api.cwd, 'docs/locales');
|
|
72
|
-
if ((0, fs_1.existsSync)(localesPath)) {
|
|
73
|
-
fs_1.default.readdirSync(localesPath).forEach((file) => {
|
|
74
|
-
if (file.endsWith('.json')) {
|
|
75
|
-
const filePath = (0, path_1.join)(localesPath, file);
|
|
76
|
-
const content = fs_1.default.readFileSync(filePath).toString();
|
|
77
|
-
const json = JSON.parse(content);
|
|
78
|
-
const localeName = file.replace('.json', '');
|
|
79
|
-
injectLocale += `themeConfig.locales['${localeName}'] = ${JSON.stringify(json)};
|
|
80
|
-
`;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
104
|
+
let injectLocale = `themeConfig.locales = ${JSON.stringify(locales)};`;
|
|
84
105
|
// exports don't start with $ will be MDX Component
|
|
85
106
|
const [_, exports] = (0, bundler_utils_1.parseModuleSync)({
|
|
86
107
|
content: (0, fs_1.readFileSync)(theme, 'utf-8'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugin-docs",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.5",
|
|
4
4
|
"description": "@umijs/plugin-docs",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugin-docs#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"classnames": "^2.3.1",
|
|
34
34
|
"rehype-slug": "5.0.1",
|
|
35
35
|
"tailwindcss": "^3.0.23",
|
|
36
|
-
"umi": "4.0.0-rc.
|
|
36
|
+
"umi": "4.0.0-rc.5"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|