@rspress/core 0.0.11 → 0.0.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/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/theme/bundle.css +31 -1
- package/dist/theme/bundle.d.ts +18 -2
- package/dist/theme/bundle.js +1097 -557
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +13 -15
- package/src/theme-default/components/PackageManagerTabs/icons/Bun.tsx +101 -0
- package/src/theme-default/components/PackageManagerTabs/icons/Npm.tsx +16 -0
- package/src/theme-default/components/PackageManagerTabs/icons/Pnpm.tsx +22 -0
- package/src/theme-default/components/PackageManagerTabs/icons/Yarn.tsx +18 -0
- package/src/theme-default/components/PackageManagerTabs/index.scss +5 -0
- package/src/theme-default/components/PackageManagerTabs/index.tsx +110 -0
- package/src/theme-default/components/Tabs/index.module.scss +1 -0
- package/src/theme-default/components/Tabs/index.tsx +30 -41
- package/src/theme-default/components/Toc/index.css +18 -0
- package/src/theme-default/components/Toc/index.tsx +42 -0
- package/src/theme-default/index.ts +8 -7
- package/src/theme-default/layout/DocLayout/docComponents/code.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -36,18 +36,16 @@
|
|
|
36
36
|
"dist/"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@headlessui/react": "^1.7.7",
|
|
40
39
|
"@loadable/component": "5.15.2",
|
|
41
40
|
"@mdx-js/loader": "2.2.1",
|
|
42
41
|
"@mdx-js/mdx": "2.2.1",
|
|
43
42
|
"@mdx-js/react": "2.2.1",
|
|
44
|
-
"@modern-js/builder": "2.
|
|
45
|
-
"@modern-js/builder-rspack-provider": "2.
|
|
43
|
+
"@modern-js/builder": "2.35.0",
|
|
44
|
+
"@modern-js/builder-rspack-provider": "2.35.0",
|
|
46
45
|
"@modern-js/mdx-rs-binding": "0.2.6",
|
|
47
|
-
"@modern-js/utils": "2.
|
|
46
|
+
"@modern-js/utils": "2.35.0",
|
|
48
47
|
"@types/compression": "^1.7.2",
|
|
49
48
|
"@types/polka": "^0.5.4",
|
|
50
|
-
"acorn": "^8.8.1",
|
|
51
49
|
"autoprefixer": "10.4.13",
|
|
52
50
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
53
51
|
"compression": "^1.7.4",
|
|
@@ -91,20 +89,20 @@
|
|
|
91
89
|
"unist-util-visit-children": "^2.0.1",
|
|
92
90
|
"yaml-front-matter": "^4.1.1",
|
|
93
91
|
"rspack-plugin-virtual-module": "0.1.12",
|
|
94
|
-
"@rspress/shared": "0.0.
|
|
95
|
-
"@rspress/plugin-medium-zoom": "0.0.
|
|
96
|
-
"@rspress/plugin-last-updated": "0.0.
|
|
97
|
-
"@rspress/plugin-auto-nav-sidebar": "0.0.
|
|
98
|
-
"@rspress/plugin-container-syntax": "0.0.
|
|
92
|
+
"@rspress/shared": "0.0.13",
|
|
93
|
+
"@rspress/plugin-medium-zoom": "0.0.13",
|
|
94
|
+
"@rspress/plugin-last-updated": "0.0.13",
|
|
95
|
+
"@rspress/plugin-auto-nav-sidebar": "0.0.13",
|
|
96
|
+
"@rspress/plugin-container-syntax": "0.0.13"
|
|
99
97
|
},
|
|
100
98
|
"peerDependencies": {
|
|
101
99
|
"react": ">=17"
|
|
102
100
|
},
|
|
103
101
|
"devDependencies": {
|
|
104
|
-
"@modern-js/plugin-tailwindcss": "2.
|
|
105
|
-
"@modern-js/plugin-testing": "2.
|
|
106
|
-
"@modern-js/tsconfig": "2.
|
|
107
|
-
"@modern-js/types": "2.
|
|
102
|
+
"@modern-js/plugin-tailwindcss": "2.35.0",
|
|
103
|
+
"@modern-js/plugin-testing": "2.35.0",
|
|
104
|
+
"@modern-js/tsconfig": "2.35.0",
|
|
105
|
+
"@modern-js/types": "2.35.0",
|
|
108
106
|
"@types/body-scroll-lock": "^3.1.0",
|
|
109
107
|
"@types/fs-extra": "^9.0.13",
|
|
110
108
|
"@types/hast": "^2.3.4",
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export function Bun(props: ComponentProps<'svg'>) {
|
|
4
|
+
return (
|
|
5
|
+
<svg id="Bun" width="1.2em" height="1.2em" viewBox="0 0 80 70" {...props}>
|
|
6
|
+
<path
|
|
7
|
+
id="Shadow"
|
|
8
|
+
d="M71.09,20.74c-.16-.17-.33-.34-.5-.5s-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5A26.46,26.46,0,0,1,75.5,35.7c0,16.57-16.82,30.05-37.5,30.05-11.58,0-21.94-4.23-28.83-10.86l.5.5.5.5.5.5.5.5.5.5.5.5.5.5C19.55,65.3,30.14,69.75,42,69.75c20.68,0,37.5-13.48,37.5-30C79.5,32.69,76.46,26,71.09,20.74Z"
|
|
9
|
+
/>
|
|
10
|
+
<g id="Body">
|
|
11
|
+
<path
|
|
12
|
+
id="Background"
|
|
13
|
+
d="M73,35.7c0,15.21-15.67,27.54-35,27.54S3,50.91,3,35.7C3,26.27,9,17.94,18.22,13S33.18,3,38,3s8.94,4.13,19.78,10C67,17.94,73,26.27,73,35.7Z"
|
|
14
|
+
style={{ fill: '#fbf0df' }}
|
|
15
|
+
/>
|
|
16
|
+
<path
|
|
17
|
+
id="Bottom_Shadow"
|
|
18
|
+
data-name="Bottom Shadow"
|
|
19
|
+
d="M73,35.7a21.67,21.67,0,0,0-.8-5.78c-2.73,33.3-43.35,34.9-59.32,24.94A40,40,0,0,0,38,63.24C57.3,63.24,73,50.89,73,35.7Z"
|
|
20
|
+
style={{ fill: '#f6dece' }}
|
|
21
|
+
/>
|
|
22
|
+
<path
|
|
23
|
+
id="Light_Shine"
|
|
24
|
+
data-name="Light Shine"
|
|
25
|
+
d="M24.53,11.17C29,8.49,34.94,3.46,40.78,3.45A9.29,9.29,0,0,0,38,3c-2.42,0-5,1.25-8.25,3.13-1.13.66-2.3,1.39-3.54,2.15-2.33,1.44-5,3.07-8,4.7C8.69,18.13,3,26.62,3,35.7c0,.4,0,.8,0,1.19C9.06,15.48,20.07,13.85,24.53,11.17Z"
|
|
26
|
+
style={{ fill: '#fffefc' }}
|
|
27
|
+
/>
|
|
28
|
+
<path
|
|
29
|
+
id="Top"
|
|
30
|
+
d="M35.12,5.53A16.41,16.41,0,0,1,29.49,18c-.28.25-.06.73.3.59,3.37-1.31,7.92-5.23,6-13.14C35.71,5,35.12,5.12,35.12,5.53Zm2.27,0A16.24,16.24,0,0,1,39,19c-.12.35.31.65.55.36C41.74,16.56,43.65,11,37.93,5,37.64,4.74,37.19,5.14,37.39,5.49Zm2.76-.17A16.42,16.42,0,0,1,47,17.12a.33.33,0,0,0,.65.11c.92-3.49.4-9.44-7.17-12.53C40.08,4.54,39.82,5.08,40.15,5.32ZM21.69,15.76a16.94,16.94,0,0,0,10.47-9c.18-.36.75-.22.66.18-1.73,8-7.52,9.67-11.12,9.45C21.32,16.4,21.33,15.87,21.69,15.76Z"
|
|
31
|
+
style={{ fill: '#ccbea7', fillRule: 'evenodd' }}
|
|
32
|
+
/>
|
|
33
|
+
<path
|
|
34
|
+
id="Outline"
|
|
35
|
+
d="M38,65.75C17.32,65.75.5,52.27.5,35.7c0-10,6.18-19.33,16.53-24.92,3-1.6,5.57-3.21,7.86-4.62,1.26-.78,2.45-1.51,3.6-2.19C32,1.89,35,.5,38,.5s5.62,1.2,8.9,3.14c1,.57,2,1.19,3.07,1.87,2.49,1.54,5.3,3.28,9,5.27C69.32,16.37,75.5,25.69,75.5,35.7,75.5,52.27,58.68,65.75,38,65.75ZM38,3c-2.42,0-5,1.25-8.25,3.13-1.13.66-2.3,1.39-3.54,2.15-2.33,1.44-5,3.07-8,4.7C8.69,18.13,3,26.62,3,35.7,3,50.89,18.7,63.25,38,63.25S73,50.89,73,35.7C73,26.62,67.31,18.13,57.78,13,54,11,51.05,9.12,48.66,7.64c-1.09-.67-2.09-1.29-3-1.84C42.63,4,40.42,3,38,3Z"
|
|
36
|
+
/>
|
|
37
|
+
</g>
|
|
38
|
+
<g id="Mouth">
|
|
39
|
+
<g id="Background-2" data-name="Background">
|
|
40
|
+
<path
|
|
41
|
+
d="M45.05,43a8.93,8.93,0,0,1-2.92,4.71,6.81,6.81,0,0,1-4,1.88A6.84,6.84,0,0,1,34,47.71,8.93,8.93,0,0,1,31.12,43a.72.72,0,0,1,.8-.81H44.26A.72.72,0,0,1,45.05,43Z"
|
|
42
|
+
style={{ fill: '#b71422' }}
|
|
43
|
+
/>
|
|
44
|
+
</g>
|
|
45
|
+
<g id="Tongue">
|
|
46
|
+
<path
|
|
47
|
+
id="Background-3"
|
|
48
|
+
data-name="Background"
|
|
49
|
+
d="M34,47.79a6.91,6.91,0,0,0,4.12,1.9,6.91,6.91,0,0,0,4.11-1.9,10.63,10.63,0,0,0,1-1.07,6.83,6.83,0,0,0-4.9-2.31,6.15,6.15,0,0,0-5,2.78C33.56,47.4,33.76,47.6,34,47.79Z"
|
|
50
|
+
style={{ fill: '#ff6164' }}
|
|
51
|
+
/>
|
|
52
|
+
<path
|
|
53
|
+
id="Outline-2"
|
|
54
|
+
data-name="Outline"
|
|
55
|
+
d="M34.16,47a5.36,5.36,0,0,1,4.19-2.08,6,6,0,0,1,4,1.69c.23-.25.45-.51.66-.77a7,7,0,0,0-4.71-1.93,6.36,6.36,0,0,0-4.89,2.36A9.53,9.53,0,0,0,34.16,47Z"
|
|
56
|
+
/>
|
|
57
|
+
</g>
|
|
58
|
+
<path
|
|
59
|
+
id="Outline-3"
|
|
60
|
+
data-name="Outline"
|
|
61
|
+
d="M38.09,50.19a7.42,7.42,0,0,1-4.45-2,9.52,9.52,0,0,1-3.11-5.05,1.2,1.2,0,0,1,.26-1,1.41,1.41,0,0,1,1.13-.51H44.26a1.44,1.44,0,0,1,1.13.51,1.19,1.19,0,0,1,.25,1h0a9.52,9.52,0,0,1-3.11,5.05A7.42,7.42,0,0,1,38.09,50.19Zm-6.17-7.4c-.16,0-.2.07-.21.09a8.29,8.29,0,0,0,2.73,4.37A6.23,6.23,0,0,0,38.09,49a6.28,6.28,0,0,0,3.65-1.73,8.3,8.3,0,0,0,2.72-4.37.21.21,0,0,0-.2-.09Z"
|
|
62
|
+
/>
|
|
63
|
+
</g>
|
|
64
|
+
<g id="Face">
|
|
65
|
+
<ellipse
|
|
66
|
+
id="Right_Blush"
|
|
67
|
+
data-name="Right Blush"
|
|
68
|
+
cx="53.22"
|
|
69
|
+
cy="40.18"
|
|
70
|
+
rx="5.85"
|
|
71
|
+
ry="3.44"
|
|
72
|
+
style={{
|
|
73
|
+
fill: '#febbd0',
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
<ellipse
|
|
77
|
+
id="Left_Bluch"
|
|
78
|
+
data-name="Left Bluch"
|
|
79
|
+
cx="22.95"
|
|
80
|
+
cy="40.18"
|
|
81
|
+
rx="5.85"
|
|
82
|
+
ry="3.44"
|
|
83
|
+
style={{ fill: '#febbd0' }}
|
|
84
|
+
/>
|
|
85
|
+
<path
|
|
86
|
+
id="Eyes"
|
|
87
|
+
d="M25.7,38.8a5.51,5.51,0,1,0-5.5-5.51A5.51,5.51,0,0,0,25.7,38.8Zm24.77,0A5.51,5.51,0,1,0,45,33.29,5.5,5.5,0,0,0,50.47,38.8Z"
|
|
88
|
+
style={{ fillRule: 'evenodd' }}
|
|
89
|
+
/>
|
|
90
|
+
<path
|
|
91
|
+
id="Iris"
|
|
92
|
+
d="M24,33.64a2.07,2.07,0,1,0-2.06-2.07A2.07,2.07,0,0,0,24,33.64Zm24.77,0a2.07,2.07,0,1,0-2.06-2.07A2.07,2.07,0,0,0,48.75,33.64Z"
|
|
93
|
+
style={{
|
|
94
|
+
fill: '#fff',
|
|
95
|
+
fillRule: 'evenodd',
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
</g>
|
|
99
|
+
</svg>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export function Npm(props: ComponentProps<'svg'>) {
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 256 256"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path fill="#C12127" d="M0 256V0h256v256z"></path>
|
|
13
|
+
<path fill="#FFF" d="M48 48h160v160h-32V80h-48v128H48z"></path>
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export function Pnpm(props: ComponentProps<'svg'>) {
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 128 128"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fill="#f8ab00"
|
|
14
|
+
d="M0 .004V40h39.996V.004Zm43.996 0V40h40V.004Zm44.008 0V40H128V.004Zm0 43.996v39.996H128V44Z"
|
|
15
|
+
></path>
|
|
16
|
+
<path
|
|
17
|
+
fill="#4c4c4c"
|
|
18
|
+
d="M43.996 44v39.996h40V44ZM0 87.996v40h39.996v-40Zm43.996 0v40h40v-40Zm44.008 0v40H128v-40Z"
|
|
19
|
+
></path>
|
|
20
|
+
</svg>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export function Yarn(props: ComponentProps<'svg'>) {
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 128 128"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<g fill="#2c8ebb">
|
|
13
|
+
<path d="M99.24 80.71C94.9 80.76 91.1 83 87.89 85c-6 3.71-9 3.47-9 3.47l-.1-.17c-.41-.67 1.92-6.68-.69-13.84c-2.82-7.83-7.3-9.72-6.94-10.32c1.53-2.59 5.36-6.7 6.89-14.36c.91-4.64.67-12.28-1.39-16.28c-.38-.74-3.78 1.24-3.78 1.24s-3.18-7.09-4.07-7.66c-2.87-1.84-6 7.61-6 7.61a14 14 0 0 0-11.71 4.5a9.64 9.64 0 0 1-3.85 2.27c-.41.14-.91.12-2.15 3.47c-1.9 5.07 3.24 10.81 3.24 10.81s-6.13 4.33-8.4 9.72a24.78 24.78 0 0 0-1.75 11.68s-4.36 3.78-4.64 7.68a12.87 12.87 0 0 0 1.77 7.83a1.94 1.94 0 0 0 2.63.91s-2.9 3.38-.19 4.81c2.47 1.29 6.63 2 8.83-.19c1.6-1.6 1.92-5.17 2.51-6.63c.14-.34.62.57 1.08 1a10 10 0 0 0 1.36 1s-3.9 1.68-2.3 5.51c.53 1.27 2.42 2.08 5.51 2.06c1.15 0 13.76-.72 17.12-1.53a4.33 4.33 0 0 0 2.61-1.46a63 63 0 0 0 15.49-7c4.74-3.09 6.68-3.93 10.51-4.84c3.16-.75 2.95-5.65-1.24-5.58z"></path>
|
|
14
|
+
<path d="M64 2a62 62 0 1 0 62 62A62 62 0 0 0 64 2zm37.3 87.83c-3.35.81-4.91 1.44-9.41 4.36a67 67 0 0 1-15.56 7.18a8.71 8.71 0 0 1-3.64 1.77c-3.81.93-16.88 1.63-17.91 1.63h-.24c-4 0-6.27-1.24-7.49-2.54c-3.4 1.7-7.8 1-11-.69a5.55 5.55 0 0 1-3-3.9a6 6 0 0 1 0-2.06a6.66 6.66 0 0 1-.79-1A16.38 16.38 0 0 1 30 84.52c.29-3.73 2.87-7.06 4.55-8.83A28.56 28.56 0 0 1 36.61 64a26.82 26.82 0 0 1 6.82-9c-1.65-2.78-3.33-7.06-1.7-11.42c1.17-3.11 2.13-4.84 4.24-5.58a6.84 6.84 0 0 0 2.51-1.34A17.65 17.65 0 0 1 60.34 31c.19-.48.41-1 .65-1.46c1.6-3.4 3.3-5.31 5.29-6a4.88 4.88 0 0 1 4.4.5c.65.43 1.48 1 3.9 6a4.69 4.69 0 0 1 2.85-.1a3.81 3.81 0 0 1 2.39 1.94c2.47 4.74 2.8 13.19 1.72 18.62a33.8 33.8 0 0 1-5.84 13.31a25.73 25.73 0 0 1 5.77 9.43a25.42 25.42 0 0 1 1.41 10.41A28.7 28.7 0 0 0 86 81.91c3.06-1.89 7.68-4.74 13.19-4.81a6.62 6.62 0 0 1 7 5.7a6.35 6.35 0 0 1-4.89 7.03z"></path>
|
|
15
|
+
</g>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Tabs, Tab } from '../Tabs';
|
|
2
|
+
import { Pre } from '../../layout/DocLayout/docComponents/pre';
|
|
3
|
+
import { Code } from '../../layout/DocLayout/docComponents/code';
|
|
4
|
+
import { Npm } from './icons/Npm';
|
|
5
|
+
import { Yarn } from './icons/Yarn';
|
|
6
|
+
import { Pnpm } from './icons/Pnpm';
|
|
7
|
+
import { Bun } from './icons/Bun';
|
|
8
|
+
import './index.scss';
|
|
9
|
+
|
|
10
|
+
export interface PackageManagerTabProps {
|
|
11
|
+
command:
|
|
12
|
+
| string
|
|
13
|
+
| {
|
|
14
|
+
npm: string;
|
|
15
|
+
yarn: string;
|
|
16
|
+
pnpm: string;
|
|
17
|
+
bun: string;
|
|
18
|
+
};
|
|
19
|
+
additionalTabs?: {
|
|
20
|
+
tool: string;
|
|
21
|
+
icon?: React.ReactNode;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function normalizeCommand(command: string): string {
|
|
26
|
+
if (!command.includes('install')) {
|
|
27
|
+
return command;
|
|
28
|
+
}
|
|
29
|
+
// If command include `install` and package name, replace `install` with `add`
|
|
30
|
+
const pureCommand = command
|
|
31
|
+
.split(' ')
|
|
32
|
+
.filter(item => !item.startsWith('-') && !item.startsWith('--'))
|
|
33
|
+
.join(' ');
|
|
34
|
+
if (pureCommand === 'yarn install' || pureCommand === 'bun install') {
|
|
35
|
+
return command;
|
|
36
|
+
} else {
|
|
37
|
+
return command.replace('install', 'add');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function PackageManagerTabs({
|
|
42
|
+
command,
|
|
43
|
+
additionalTabs = [],
|
|
44
|
+
}: PackageManagerTabProps) {
|
|
45
|
+
let commandInfo: {
|
|
46
|
+
npm: string;
|
|
47
|
+
yarn: string;
|
|
48
|
+
pnpm: string;
|
|
49
|
+
bun: string;
|
|
50
|
+
[key: string]: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Init Icons
|
|
54
|
+
const packageMangerToIcon = {
|
|
55
|
+
npm: <Npm />,
|
|
56
|
+
yarn: <Yarn />,
|
|
57
|
+
pnpm: <Pnpm />,
|
|
58
|
+
bun: <Bun />,
|
|
59
|
+
};
|
|
60
|
+
additionalTabs.forEach(tab => {
|
|
61
|
+
packageMangerToIcon[tab.tool] = tab.icon;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Init Command
|
|
65
|
+
if (typeof command === 'string') {
|
|
66
|
+
commandInfo = {
|
|
67
|
+
npm: `npm ${command}`,
|
|
68
|
+
yarn: `yarn ${command}`,
|
|
69
|
+
pnpm: `pnpm ${command}`,
|
|
70
|
+
bun: `bun ${command}`,
|
|
71
|
+
};
|
|
72
|
+
additionalTabs.forEach(tab => {
|
|
73
|
+
commandInfo[tab.tool] = `${tab.tool} ${command}`;
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
commandInfo = command;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Normalize yarn/bun command
|
|
80
|
+
commandInfo.yarn = normalizeCommand(commandInfo.yarn);
|
|
81
|
+
commandInfo.bun = normalizeCommand(commandInfo.bun);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Tabs
|
|
85
|
+
values={Object.entries(commandInfo).map(([key]) => (
|
|
86
|
+
<div
|
|
87
|
+
key={key}
|
|
88
|
+
style={{
|
|
89
|
+
display: 'flex',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
fontSize: 15,
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{packageMangerToIcon[key]}
|
|
95
|
+
<span style={{ marginLeft: 6, marginBottom: 2 }}>{key}</span>
|
|
96
|
+
</div>
|
|
97
|
+
))}
|
|
98
|
+
>
|
|
99
|
+
{Object.entries(commandInfo).map(([key, value]) => (
|
|
100
|
+
<Tab key={key}>
|
|
101
|
+
<Pre>
|
|
102
|
+
<Code className="language-js">{value}</Code>
|
|
103
|
+
</Pre>
|
|
104
|
+
</Tab>
|
|
105
|
+
))}
|
|
106
|
+
</Tabs>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { Tab } from '@theme';
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
ReactElement,
|
|
4
4
|
ReactNode,
|
|
5
5
|
useContext,
|
|
6
|
+
useState,
|
|
6
7
|
} from 'react';
|
|
7
|
-
import { Tab as HeadlessTab } from '@headlessui/react';
|
|
8
8
|
import { TabDataContext } from '../../logic/TabDataContext';
|
|
9
9
|
import styles from './index.module.scss';
|
|
10
10
|
|
|
@@ -68,48 +68,37 @@ export function Tabs(props: TabsProps): ReactElement {
|
|
|
68
68
|
return false;
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
const [activeIndex, setActiveIndex] = useState(defaultIndex);
|
|
71
72
|
|
|
72
73
|
return (
|
|
73
74
|
<div className={styles.container}>
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'disabled' in item &&
|
|
91
|
-
item.disabled,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<HeadlessTab
|
|
96
|
-
key={index}
|
|
97
|
-
disabled={disabled}
|
|
98
|
-
className={({ selected }) =>
|
|
99
|
-
`${styles.tab} ${
|
|
100
|
-
selected ? styles.selected : styles.notSelected
|
|
101
|
-
}`
|
|
75
|
+
<div className={tabContainerClassName}>
|
|
76
|
+
{tabValues.length ? (
|
|
77
|
+
<div className={styles.tabList}>
|
|
78
|
+
{tabValues.map((item, index) => {
|
|
79
|
+
return (
|
|
80
|
+
<div
|
|
81
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
82
|
+
key={index}
|
|
83
|
+
className={`${styles.tab} ${
|
|
84
|
+
activeIndex === index ? styles.selected : styles.notSelected
|
|
85
|
+
}`}
|
|
86
|
+
onClick={() => {
|
|
87
|
+
onChange?.(index);
|
|
88
|
+
setActiveIndex(index);
|
|
89
|
+
if (groupId) {
|
|
90
|
+
setTabData({ ...tabData, [groupId]: index });
|
|
102
91
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{renderTab(item)}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
})}
|
|
98
|
+
</div>
|
|
99
|
+
) : null}
|
|
100
|
+
</div>
|
|
101
|
+
<div>{children[activeIndex]}</div>
|
|
113
102
|
</div>
|
|
114
103
|
);
|
|
115
104
|
}
|
|
@@ -119,8 +108,8 @@ export function Tab({
|
|
|
119
108
|
...props
|
|
120
109
|
}: ComponentPropsWithRef<'div'>): ReactElement {
|
|
121
110
|
return (
|
|
122
|
-
<
|
|
111
|
+
<div {...props} className="rounded px-2">
|
|
123
112
|
{children}
|
|
124
|
-
</
|
|
113
|
+
</div>
|
|
125
114
|
);
|
|
126
115
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.toc-link {
|
|
2
|
+
padding-bottom: 1px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.toc-link-text {
|
|
6
|
+
padding: 4px 12px;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
text-overflow: ellipsis;
|
|
10
|
+
transition: all 0.2s ease-in-out;
|
|
11
|
+
border-radius: 10px 0 0 10px;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
line-height: 1.75rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.toc-link-text:hover {
|
|
17
|
+
background-color: var(--rp-c-bg-mute);
|
|
18
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Header } from '@rspress/shared';
|
|
2
|
+
import { usePageData } from '@/runtime';
|
|
3
|
+
import { scrollToTarget } from '@/theme-default';
|
|
4
|
+
import './index.css';
|
|
5
|
+
|
|
6
|
+
const TocItem = (header: Header) => {
|
|
7
|
+
return (
|
|
8
|
+
<li key={header.id} className={'py-1'}>
|
|
9
|
+
<a
|
|
10
|
+
href={`#${header.id}`}
|
|
11
|
+
className={
|
|
12
|
+
'toc-link transition-all duration-300 hover:text-text-1 text-text-2 block underline underline-offset-2'
|
|
13
|
+
}
|
|
14
|
+
style={{
|
|
15
|
+
marginLeft: header.depth * 12,
|
|
16
|
+
}}
|
|
17
|
+
onClick={e => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
window.location.hash = header.id;
|
|
20
|
+
const target = document.getElementById(header.id);
|
|
21
|
+
if (target) {
|
|
22
|
+
scrollToTarget(target, false);
|
|
23
|
+
}
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<span className={'toc-link-text block'}>{header.text}</span>
|
|
27
|
+
</a>
|
|
28
|
+
</li>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function Toc() {
|
|
33
|
+
const { page } = usePageData();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ul>
|
|
37
|
+
{page.toc.map(item => (
|
|
38
|
+
<TocItem key={item.id} {...item} />
|
|
39
|
+
))}
|
|
40
|
+
</ul>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -2,14 +2,15 @@ import { NotFoundLayout } from './layout/NotFountLayout';
|
|
|
2
2
|
import { Layout } from './layout/Layout';
|
|
3
3
|
import { HomeLayout } from './layout/HomeLayout';
|
|
4
4
|
import { setup } from './logic';
|
|
5
|
-
import { Nav } from './components/Nav';
|
|
6
|
-
import { Search } from './components/Search';
|
|
7
|
-
import { Tab, Tabs } from './components/Tabs';
|
|
8
|
-
import { Button } from './components/Button';
|
|
9
|
-
import { Link } from './components/Link';
|
|
10
|
-
import { HomeFooter } from './components/HomeFooter';
|
|
11
5
|
|
|
12
|
-
export { Nav
|
|
6
|
+
export { Nav } from './components/Nav';
|
|
7
|
+
export { Search } from './components/Search';
|
|
8
|
+
export { Tab, Tabs } from './components/Tabs';
|
|
9
|
+
export { Button } from './components/Button';
|
|
10
|
+
export { Link } from './components/Link';
|
|
11
|
+
export { HomeFooter } from './components/HomeFooter';
|
|
12
|
+
export { Toc } from './components/Toc';
|
|
13
|
+
export { PackageManagerTabs } from './components/PackageManagerTabs';
|
|
13
14
|
|
|
14
15
|
export default {
|
|
15
16
|
Layout,
|