@rspress/core 2.0.0-rc.2 → 2.0.0-rc.4
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/{0~7675.989ee664.js → 0~7675.723d12b2.js} +18 -15
- package/dist/{5313.6594aba0.js → 3521.9eb6b114.js} +12 -19
- package/dist/4669.69cb6b18.js +1 -0
- package/dist/{5485.2a0273cf.js → 5485.9fc7f63d.js} +5 -5
- package/dist/6289.29817fb4.js +4 -0
- package/dist/8813.4b28f4bb.js +1 -0
- package/dist/9643.2dff683e.js +4 -0
- package/dist/_private/react/render.js +17 -4
- package/dist/cli/config/loadConfigFile.js +2 -2
- package/dist/cli/index.44f3184c.js +2 -0
- package/dist/cli/index.js +3 -3
- package/dist/eject-theme/components/Badge/index.scss +1 -0
- package/dist/eject-theme/components/Banner/index.tsx +3 -1
- package/dist/eject-theme/components/Callout/index.tsx +8 -2
- package/dist/eject-theme/components/CodeBlock/index.scss +8 -6
- package/dist/eject-theme/components/CodeBlock/index.tsx +4 -0
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
- package/dist/eject-theme/components/DocContent/doc.scss +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
- package/dist/eject-theme/components/DocContent/index.tsx +21 -4
- package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
- package/dist/eject-theme/components/HoverGroup/index.scss +4 -3
- package/dist/eject-theme/components/HoverGroup/index.tsx +104 -22
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
- package/dist/eject-theme/components/Link/index.tsx +9 -2
- package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
- package/dist/eject-theme/components/Nav/NavMenu.tsx +50 -28
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +26 -11
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
- package/dist/eject-theme/components/Overview/index.tsx +66 -6
- package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
- package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +50 -3
- package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
- package/dist/eject-theme/components/Tabs/index.scss +12 -4
- package/dist/eject-theme/components/Tabs/index.tsx +16 -0
- package/dist/eject-theme/components/Tag/index.tsx +84 -5
- package/dist/index.js +7 -11
- package/dist/node/PluginDriver.js +5 -6
- package/dist/node/auto-nav-sidebar/index.js +3 -3
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +12 -10
- package/dist/node/auto-nav-sidebar/utils.js +2 -2
- package/dist/node/auto-nav-sidebar/walk.js +13 -9
- package/dist/node/constants.d.ts +1 -0
- package/dist/node/constants.js +4 -3
- package/dist/node/eject.js +7 -10
- package/dist/node/initRsbuild.js +25 -11
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.js +1 -1
- package/dist/node/mdx/loader.7c249a26.js +12 -0
- package/dist/node/mdx/loader.js +2 -1
- package/dist/node/mdx/options.js +9 -6
- package/dist/node/mdx/processor.js +2 -2
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +4 -4
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -5
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
- package/dist/node/mdx/remarkPlugins/image.js +3 -3
- package/dist/node/mdx/remarkPlugins/link.js +3 -3
- package/dist/node/mdx/remarkPlugins/toc.js +3 -3
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +3 -3
- package/dist/node/route/extractPageData.js +5 -5
- package/dist/node/route/normalizeRoutePath.js +2 -2
- package/dist/node/runtimeModule/i18n.js +2 -2
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPage.js +2 -2
- package/dist/node/ssg/renderPageWorker.165b5d46.js +1 -0
- package/dist/node/ssg/renderPageWorker.js +2 -2
- package/dist/node/ssg/renderPages.js +3 -3
- package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +9 -3
- package/dist/node/ssg-md/llms/llmsTxt.js +2 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +141 -99
- package/dist/node/ssg-md/renderPage.js +2 -2
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +2 -2
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +2 -1
- package/dist/node/utils/flattenMdxContent.js +5 -5
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +3 -3
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/runtime/App.js +4 -2
- package/dist/runtime/initPageData.js +1 -1
- package/dist/runtime.js +1 -2
- package/dist/shiki-transformers.js +2 -2
- package/dist/theme/assets/deprecated.js +18 -0
- package/dist/theme/assets/experimental.js +21 -0
- package/dist/theme/components/Badge/index.css +1 -0
- package/dist/theme/components/Banner/index.js +2 -2
- package/dist/theme/components/Callout/index.js +5 -2
- package/dist/theme/components/CodeBlock/index.css +7 -6
- package/dist/theme/components/CodeBlock/index.js +4 -1
- package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
- package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
- package/dist/theme/components/DocContent/doc.css +1 -1
- package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
- package/dist/theme/components/DocContent/index.d.ts +11 -2
- package/dist/theme/components/DocContent/index.js +6 -5
- package/dist/theme/components/DocFooter/index.js +1 -5
- package/dist/theme/components/HoverGroup/index.css +6 -5
- package/dist/theme/components/HoverGroup/index.js +88 -17
- package/dist/theme/components/LastUpdated/index.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.js +5 -1
- package/dist/theme/components/Link/index.d.ts +1 -1
- package/dist/theme/components/Link/index.js +8 -2
- package/dist/theme/components/Nav/NavMenu.css +1 -1
- package/dist/theme/components/Nav/NavMenu.d.ts +6 -1
- package/dist/theme/components/Nav/NavMenu.js +47 -45
- package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
- package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -11
- package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
- package/dist/theme/components/Overview/index.d.ts +0 -1
- package/dist/theme/components/Overview/index.js +46 -3
- package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
- package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
- package/dist/theme/components/OverviewGroup/index.js +88 -0
- package/dist/theme/components/Search/logic/util.test.js +1 -1
- package/dist/theme/components/Tabs/index.css +6 -5
- package/dist/theme/components/Tabs/index.js +9 -0
- package/dist/theme/components/Tag/index.d.ts +3 -0
- package/dist/theme/components/Tag/index.js +63 -8
- package/dist/theme/hooks/useActiveAnchor.js +1 -1
- package/dist/theme/icons.d.ts +26 -24
- package/dist/theme/icons.js +5 -1
- package/dist/theme/index.d.ts +3 -1
- package/dist/theme/index.js +4 -2
- package/dist/theme/layout/DocLayout/index.css +0 -2
- package/dist/theme/layout/DocLayout/index.js +10 -0
- package/dist/theme/layout/HomeLayout/index.js +40 -0
- package/dist/theme/layout/Layout/index.js +11 -8
- package/dist/theme/layout/NotFountLayout/index.js +1 -1
- package/dist/theme/logic/useAppearance.js +1 -1
- package/dist/theme/logic/useMediaQuery.js +1 -1
- package/dist/theme/logic/useStorageValue.js +6 -3
- package/dist/theme/styles/base.css +1 -0
- package/dist/theme/styles/shiki.css +9 -3
- package/dist/theme/styles/vars/base-vars.css +4 -4
- package/dist/theme/styles/vars/code-vars.css +2 -0
- package/nav-json-schema.json +2 -2
- package/package.json +15 -15
- package/dist/1218.3869bad6.js +0 -2
- package/dist/4669.12208c6a.js +0 -2
- package/dist/6289.c67fe0d5.js +0 -5
- package/dist/7805.cadab34e.js +0 -4
- package/dist/8813.9da1f210.js +0 -2
- package/dist/cli/index.cb89dbd1.js +0 -3
- package/dist/node/mdx/loader.e1578c62.js +0 -13
- package/dist/node/ssg/renderPageWorker.474f9f73.js +0 -2
- package/dist/theme/components/Overview/OverviewGroup.js +0 -57
- /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
- /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss}
RENAMED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--rp-c-overview-group-bg: var(--rp-c-bg-soft);
|
|
3
|
+
--rp-c-overview-group-bg-hover: color-mix(
|
|
4
|
+
in srgb,
|
|
5
|
+
var(--rp-c-brand-lighter) 30%,
|
|
6
|
+
transparent
|
|
7
|
+
);
|
|
8
|
+
--rp-c-overview-group-border: 1px solid var(--rp-c-divider-light);
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
.rp-overview-group {
|
|
2
12
|
width: 100%;
|
|
3
13
|
display: flex;
|
|
@@ -9,7 +19,7 @@
|
|
|
9
19
|
width: 100%;
|
|
10
20
|
flex-direction: row;
|
|
11
21
|
|
|
12
|
-
border:
|
|
22
|
+
border: var(--rp-c-overview-group-border);
|
|
13
23
|
border-radius: var(--rp-radius);
|
|
14
24
|
overflow: hidden;
|
|
15
25
|
transition:
|
|
@@ -20,11 +30,7 @@
|
|
|
20
30
|
border-color: var(--rp-c-brand-light);
|
|
21
31
|
box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.04);
|
|
22
32
|
.rp-overview-group__item__title {
|
|
23
|
-
background-color:
|
|
24
|
-
in srgb,
|
|
25
|
-
var(--rp-c-brand-lighter) 30%,
|
|
26
|
-
transparent
|
|
27
|
-
) !important;
|
|
33
|
+
background-color: var(--rp-c-overview-group-bg-hover);
|
|
28
34
|
.rp-overview-group__item__title__icon {
|
|
29
35
|
color: var(--rp-c-brand-dark);
|
|
30
36
|
}
|
|
@@ -40,22 +46,25 @@
|
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
&__title {
|
|
43
|
-
width:
|
|
44
|
-
flex: 0 0
|
|
45
|
-
word-break: break-all;
|
|
49
|
+
width: 25%;
|
|
50
|
+
flex: 0 0 25%;
|
|
46
51
|
|
|
47
52
|
padding: 16px 20px;
|
|
53
|
+
|
|
54
|
+
word-break: break-all;
|
|
48
55
|
font-size: 18px;
|
|
49
56
|
font-weight: 600;
|
|
50
|
-
background-color: var(--rp-c-bg-soft);
|
|
51
57
|
color: var(--rp-c-text-1);
|
|
52
58
|
|
|
59
|
+
background-color: var(--rp-c-overview-group-bg);
|
|
60
|
+
|
|
53
61
|
overflow: hidden;
|
|
54
62
|
position: relative;
|
|
55
63
|
|
|
56
64
|
transition: background-color 0.2s ease;
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
&__link,
|
|
67
|
+
&__text {
|
|
59
68
|
color: inherit;
|
|
60
69
|
text-decoration: none;
|
|
61
70
|
|
|
@@ -121,10 +130,55 @@
|
|
|
121
130
|
}
|
|
122
131
|
}
|
|
123
132
|
}
|
|
133
|
+
|
|
134
|
+
// Grid layout for items without content (no headers/items)
|
|
135
|
+
&__grid {
|
|
136
|
+
display: grid;
|
|
137
|
+
grid-template-columns: repeat(4, 1fr);
|
|
138
|
+
gap: 20px;
|
|
139
|
+
width: 100%;
|
|
140
|
+
|
|
141
|
+
@media (max-width: 1280px) {
|
|
142
|
+
grid-template-columns: repeat(3, 1fr);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@media (max-width: 768px) {
|
|
146
|
+
grid-template-columns: repeat(2, 1fr);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (max-width: 480px) {
|
|
150
|
+
grid-template-columns: 1fr;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&__grid-item {
|
|
155
|
+
border: 1px solid var(--rp-c-divider-light);
|
|
156
|
+
border-radius: var(--rp-radius);
|
|
157
|
+
transition:
|
|
158
|
+
border-color 0.2s ease,
|
|
159
|
+
box-shadow 0.2s ease,
|
|
160
|
+
background-color 0.2s ease;
|
|
161
|
+
|
|
162
|
+
&.rp-overview-group__item__title {
|
|
163
|
+
width: 100%;
|
|
164
|
+
flex: none;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&:hover {
|
|
168
|
+
border-color: var(--rp-c-brand-light);
|
|
169
|
+
box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.04);
|
|
170
|
+
background-color: var(--rp-c-overview-group-bg-hover);
|
|
171
|
+
|
|
172
|
+
.rp-overview-group__item__title__icon {
|
|
173
|
+
color: var(--rp-c-brand-dark);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
124
177
|
}
|
|
125
178
|
|
|
126
179
|
html.rp-dark {
|
|
127
|
-
.rp-overview-group__item:hover
|
|
180
|
+
.rp-overview-group__item:hover,
|
|
181
|
+
.rp-overview-group__grid-item:hover {
|
|
128
182
|
.rp-overview-group__item__title__icon {
|
|
129
183
|
color: white;
|
|
130
184
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Link, renderInlineMarkdown } from '@theme';
|
|
2
|
-
import './
|
|
2
|
+
import './index.scss';
|
|
3
3
|
import type { Header } from '@rspress/core';
|
|
4
4
|
import { FallbackHeading, SvgWrapper } from '@theme';
|
|
5
|
+
import { useMemo } from 'react';
|
|
5
6
|
import IconPlugin from './icons/plugin.svg';
|
|
6
7
|
|
|
7
8
|
export interface GroupItem {
|
|
@@ -19,20 +20,41 @@ export interface Group {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const OverviewGroup = ({ group }: { group: Group }) => {
|
|
23
|
+
const { itemsWithContent, itemsWithoutContent } = useMemo(() => {
|
|
24
|
+
// Separate items into those with content and those without
|
|
25
|
+
const itemsWithContent = group.items.filter(
|
|
26
|
+
item =>
|
|
27
|
+
(item.headers && item.headers.length > 0) ||
|
|
28
|
+
(item.items && item.items.length > 0),
|
|
29
|
+
);
|
|
30
|
+
const itemsWithoutContent = group.items.filter(
|
|
31
|
+
item =>
|
|
32
|
+
!(item.headers && item.headers.length > 0) &&
|
|
33
|
+
!(item.items && item.items.length > 0),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return { itemsWithContent, itemsWithoutContent };
|
|
37
|
+
}, [group]);
|
|
38
|
+
|
|
22
39
|
return (
|
|
23
40
|
<>
|
|
24
41
|
<FallbackHeading level={2} title={group.name} />
|
|
25
42
|
<div className="rp-overview-group rp-not-doc">
|
|
26
|
-
{
|
|
43
|
+
{/* Render items with content in the standard split layout */}
|
|
44
|
+
{itemsWithContent.map(item => (
|
|
27
45
|
<div className="rp-overview-group__item" key={item.link}>
|
|
28
46
|
<div className="rp-overview-group__item__title">
|
|
29
47
|
{item.link ? (
|
|
30
48
|
<Link
|
|
31
49
|
href={item.link}
|
|
50
|
+
className="rp-overview-group__item__title__link"
|
|
32
51
|
{...renderInlineMarkdown(item.text)}
|
|
33
52
|
></Link>
|
|
34
53
|
) : (
|
|
35
|
-
<span
|
|
54
|
+
<span
|
|
55
|
+
className="rp-overview-group__item__title__text"
|
|
56
|
+
{...renderInlineMarkdown(item.text)}
|
|
57
|
+
/>
|
|
36
58
|
)}
|
|
37
59
|
<SvgWrapper
|
|
38
60
|
icon={IconPlugin}
|
|
@@ -69,6 +91,31 @@ export const OverviewGroup = ({ group }: { group: Group }) => {
|
|
|
69
91
|
</ul>
|
|
70
92
|
</div>
|
|
71
93
|
))}
|
|
94
|
+
|
|
95
|
+
{/* Render items without content in a grid layout */}
|
|
96
|
+
{itemsWithoutContent.length > 0 && (
|
|
97
|
+
<div className="rp-overview-group__grid">
|
|
98
|
+
{itemsWithoutContent.map(item => (
|
|
99
|
+
<div
|
|
100
|
+
className="rp-overview-group__grid-item rp-overview-group__item__title"
|
|
101
|
+
key={item.link}
|
|
102
|
+
>
|
|
103
|
+
{item.link ? (
|
|
104
|
+
<Link
|
|
105
|
+
href={item.link}
|
|
106
|
+
className="rp-overview-group__item__title__link"
|
|
107
|
+
{...renderInlineMarkdown(item.text)}
|
|
108
|
+
></Link>
|
|
109
|
+
) : (
|
|
110
|
+
<span
|
|
111
|
+
className="rp-overview-group__item__title__text"
|
|
112
|
+
{...renderInlineMarkdown(item.text)}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
))}
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
72
119
|
</div>
|
|
73
120
|
</>
|
|
74
121
|
);
|
|
@@ -3,14 +3,22 @@
|
|
|
3
3
|
border-radius: var(--rp-radius);
|
|
4
4
|
margin: 1rem 0;
|
|
5
5
|
border: var(--rp-code-block-border);
|
|
6
|
+
box-shadow: var(--rp-code-block-shadow);
|
|
7
|
+
|
|
8
|
+
// nested
|
|
9
|
+
& & {
|
|
10
|
+
border-radius: 0;
|
|
11
|
+
margin: 0;
|
|
12
|
+
border: none;
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
.rp-codeblock {
|
|
8
|
-
margin: 0
|
|
9
|
-
border-radius: 0
|
|
10
|
-
border: none
|
|
16
|
+
margin: 0;
|
|
17
|
+
border-radius: 0;
|
|
18
|
+
border: none;
|
|
11
19
|
|
|
12
20
|
.rp-codeblock__title {
|
|
13
|
-
padding: 8px
|
|
21
|
+
padding: 8px 12px;
|
|
14
22
|
}
|
|
15
23
|
}
|
|
16
24
|
|
|
@@ -122,6 +122,22 @@ export const Tabs = forwardRef(
|
|
|
122
122
|
return getTabValuesFromChildren(children, values);
|
|
123
123
|
}, [values, children]);
|
|
124
124
|
|
|
125
|
+
if (process.env.__SSR_MD__) {
|
|
126
|
+
return (
|
|
127
|
+
<>
|
|
128
|
+
{tabValues.map(({ label, content }) => {
|
|
129
|
+
return (
|
|
130
|
+
<>
|
|
131
|
+
{`\n**${label}**\n\n`}
|
|
132
|
+
{content}
|
|
133
|
+
{`\n`}
|
|
134
|
+
</>
|
|
135
|
+
);
|
|
136
|
+
})}
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
125
141
|
const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0);
|
|
126
142
|
|
|
127
143
|
const [storageIndex, setStorageIndex] = useStorageValue<string>(
|
|
@@ -1,13 +1,67 @@
|
|
|
1
1
|
import { isDataUrl, isExternalUrl } from '@rspress/core/runtime';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
IconDeprecated,
|
|
5
|
+
IconExperimental,
|
|
6
|
+
SvgWrapper,
|
|
7
|
+
Tag as WrappedTag,
|
|
8
|
+
} from '@theme';
|
|
9
|
+
import { useMemo } from 'react';
|
|
3
10
|
|
|
11
|
+
const BADGE_TAGS = {
|
|
12
|
+
tip: 'tip',
|
|
13
|
+
info: 'info',
|
|
14
|
+
warning: 'warning',
|
|
15
|
+
danger: 'danger',
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
function parseCommonTagsArrayStr(tagStr: string): string[] | null {
|
|
19
|
+
const tags = tagStr
|
|
20
|
+
.split(',')
|
|
21
|
+
.map(tag => tag.trim())
|
|
22
|
+
.filter(tag => tag.length > 0);
|
|
23
|
+
|
|
24
|
+
return tags;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const getTagType = (tag: string) => {
|
|
28
|
+
const normalizedTag = tag.trim();
|
|
29
|
+
const isSvgTagString = normalizedTag.startsWith('<svg');
|
|
30
|
+
const isPic = isExternalUrl(normalizedTag) || isDataUrl(normalizedTag);
|
|
31
|
+
|
|
32
|
+
const tagsArray = parseCommonTagsArrayStr(normalizedTag);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
isSvgTagString,
|
|
36
|
+
isPic,
|
|
37
|
+
isTagsArray: tagsArray && tagsArray?.length > 1,
|
|
38
|
+
tagsArray,
|
|
39
|
+
normalizedTag,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} [props.tag] - Supported 1.common tags 2. svg 3. dataUrl 4. externalUrl 4. 5. normal text
|
|
45
|
+
*/
|
|
4
46
|
export const Tag = ({ tag }: { tag?: string }) => {
|
|
5
47
|
if (!tag) {
|
|
6
48
|
return null;
|
|
7
49
|
}
|
|
8
|
-
|
|
9
|
-
const isSvgTagString =
|
|
10
|
-
|
|
50
|
+
|
|
51
|
+
const { isPic, isTagsArray, isSvgTagString, normalizedTag, tagsArray } =
|
|
52
|
+
useMemo(() => {
|
|
53
|
+
return getTagType(tag);
|
|
54
|
+
}, [tag]);
|
|
55
|
+
|
|
56
|
+
if (isTagsArray) {
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
{tagsArray?.map((tag, index) => {
|
|
60
|
+
return <WrappedTag tag={tag} key={`${tag}-${index}`} />;
|
|
61
|
+
})}
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
11
65
|
|
|
12
66
|
if (isSvgTagString) {
|
|
13
67
|
return (
|
|
@@ -23,5 +77,30 @@ export const Tag = ({ tag }: { tag?: string }) => {
|
|
|
23
77
|
return <img src={tag} />;
|
|
24
78
|
}
|
|
25
79
|
|
|
26
|
-
|
|
80
|
+
if (normalizedTag === 'experimental') {
|
|
81
|
+
return (
|
|
82
|
+
<Badge type="warning">
|
|
83
|
+
<SvgWrapper icon={IconExperimental} />
|
|
84
|
+
<span>experimental</span>
|
|
85
|
+
</Badge>
|
|
86
|
+
);
|
|
87
|
+
} else if (normalizedTag === 'deprecated') {
|
|
88
|
+
return (
|
|
89
|
+
<Badge type="danger">
|
|
90
|
+
<SvgWrapper icon={IconDeprecated} />
|
|
91
|
+
<span>deprecated</span>
|
|
92
|
+
</Badge>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (BADGE_TAGS[normalizedTag as keyof typeof BADGE_TAGS]) {
|
|
97
|
+
return (
|
|
98
|
+
<Badge
|
|
99
|
+
text={normalizedTag}
|
|
100
|
+
type={BADGE_TAGS[normalizedTag as keyof typeof BADGE_TAGS]}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return <Badge text={normalizedTag} type="info" />;
|
|
27
106
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "./5313.6594aba0.js";
|
|
5
|
-
export { RSPRESS_TEMP_DIR, getSidebarDataGroup, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "@rspress/shared";
|
|
6
|
-
export { logger } from "@rspress/shared/logger";
|
|
7
|
-
export { getIconUrlPath, getNodeAttribute, mergeDocConfig } from "@rspress/shared/node-utils";
|
|
8
|
-
export { matchPath } from "react-router-dom";
|
|
9
|
-
export { defineConfig } from "./cli/config/index.js";
|
|
1
|
+
export { PluginDriver } from "./node/PluginDriver.js";
|
|
2
|
+
export { RSPRESS_TEMP_DIR, getSidebarDataGroup, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "./4669.69cb6b18.js";
|
|
3
|
+
export { RouteService } from "./node/route/RouteService.js";
|
|
10
4
|
export { build } from "./node/build.js";
|
|
5
|
+
export { defineConfig } from "./cli/config/index.js";
|
|
11
6
|
export { dev } from "./node/dev.js";
|
|
7
|
+
export { getIconUrlPath, getNodeAttribute, mergeDocConfig } from "./9643.2dff683e.js";
|
|
8
|
+
export { logger } from "./6289.29817fb4.js";
|
|
9
|
+
export { matchPath } from "./3521.9eb6b114.js";
|
|
12
10
|
export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
|
|
13
11
|
export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
|
|
14
12
|
export { serve } from "./node/serve.js";
|
|
15
|
-
export { PluginDriver } from "./node/PluginDriver.js";
|
|
16
|
-
export { RouteService } from "./node/route/RouteService.js";
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../
|
|
3
|
-
import { addTrailingSlash, addLeadingSlash } from "../4669.12208c6a.js";
|
|
1
|
+
import { node_path } from "../6289.29817fb4.js";
|
|
2
|
+
import { addTrailingSlash, addLeadingSlash } from "../4669.69cb6b18.js";
|
|
4
3
|
import { createError } from "./utils/error.js";
|
|
5
|
-
import {
|
|
6
|
-
const external_path_ = __webpack_require__("path");
|
|
4
|
+
import { auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
|
|
7
5
|
class PluginDriver {
|
|
8
6
|
#config;
|
|
9
7
|
#configFilePath;
|
|
@@ -62,11 +60,12 @@ class PluginDriver {
|
|
|
62
60
|
if (-1 !== index) this.#plugins.splice(index, 1);
|
|
63
61
|
}
|
|
64
62
|
async normalizeConfig() {
|
|
63
|
+
this.#config.root ??= 'docs';
|
|
65
64
|
this.#config.ssg ??= true;
|
|
66
65
|
this.#config.llms ??= false;
|
|
67
66
|
this.#config.base = addTrailingSlash(addLeadingSlash(this.#config.base ?? '/'));
|
|
68
67
|
this.#config.lang ??= 'en';
|
|
69
|
-
this.#config.themeDir ??=
|
|
68
|
+
this.#config.themeDir ??= node_path.join(process.cwd(), 'theme');
|
|
70
69
|
}
|
|
71
70
|
async modifyConfig() {
|
|
72
71
|
this.normalizeConfig();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { node_path } from "../../6289.
|
|
2
|
-
import { DEFAULT_PAGE_EXTENSIONS } from "../../
|
|
1
|
+
import { node_path } from "../../6289.29817fb4.js";
|
|
2
|
+
import { DEFAULT_PAGE_EXTENSIONS } from "../../3521.9eb6b114.js";
|
|
3
3
|
import { processLocales, combineWalkResult } from "./locales.js";
|
|
4
4
|
import { walk } from "./walk.js";
|
|
5
5
|
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
@@ -41,4 +41,4 @@ async function modifyConfigWithAutoNavSide(config, metaFileSet = new Set(), mdFi
|
|
|
41
41
|
config.themeConfig.nav = autoNavSide.nav;
|
|
42
42
|
config.themeConfig.sidebar = autoNavSide.sidebar;
|
|
43
43
|
}
|
|
44
|
-
export { auto_nav_sidebar_haveNavSidebarConfig
|
|
44
|
+
export { auto_nav_sidebar_haveNavSidebarConfig, modifyConfigWithAutoNavSide };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { readdir, extname, stat as promises_stat, relative, logger, join } from "../../6289.
|
|
2
|
-
import { isExternalUrl, slash } from "../../4669.
|
|
3
|
-
import { PUBLIC_DIR } from "../constants.js";
|
|
1
|
+
import { readdir, extname, stat as promises_stat, relative, logger, join, picocolors } from "../../6289.29817fb4.js";
|
|
2
|
+
import { isExternalUrl, slash } from "../../4669.69cb6b18.js";
|
|
4
3
|
import { createError } from "../utils/error.js";
|
|
4
|
+
import { PUBLIC_DIR } from "../constants.js";
|
|
5
5
|
import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
|
|
6
6
|
import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
|
|
7
|
+
const AUTO_NAV_SIDEBAR_ERROR_PREFIX = '[auto-nav-sidebar] ';
|
|
7
8
|
function getFileKey(realPath, docsDir) {
|
|
8
9
|
return realPath ? slash(relative(docsDir, realPath).replace(extname(realPath), '')) : '';
|
|
9
10
|
}
|
|
@@ -12,8 +13,8 @@ async function fsDirToMetaItems(workDir, docsDir, extensions) {
|
|
|
12
13
|
try {
|
|
13
14
|
subItems = await readdir(workDir);
|
|
14
15
|
} catch (e) {
|
|
15
|
-
|
|
16
|
-
throw e;
|
|
16
|
+
const metaFilePath = join(workDir, '_meta.json');
|
|
17
|
+
throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}Failed to read directory: ${picocolors.yellow(workDir)}, maybe it does not exist. Please check it in ${picocolors.cyan(metaFilePath)}. (${e})`);
|
|
17
18
|
}
|
|
18
19
|
subItems = subItems.filter((item)=>{
|
|
19
20
|
const hasExtension = extensions.some((ext)=>item.endsWith(ext));
|
|
@@ -46,7 +47,7 @@ async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, met
|
|
|
46
47
|
if ('custom-link' === type) return metaCustomLinkItemToSidebarItem(metaItem, workDir, docsDir);
|
|
47
48
|
if ('divider' === type) return metaDividerToSidebarItem(metaItem);
|
|
48
49
|
if ('section-header' === type) return metaSectionHeaderToSidebarItem(metaItem);
|
|
49
|
-
throw createError(
|
|
50
|
+
throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}Unknown meta item type: ${metaItem.type}, please check it in "${join(workDir, '_meta.json')}".`);
|
|
50
51
|
}
|
|
51
52
|
async function detectFilePath(absolutePath, extensions) {
|
|
52
53
|
const ext = extname(absolutePath);
|
|
@@ -55,7 +56,7 @@ async function detectFilePath(absolutePath, extensions) {
|
|
|
55
56
|
const realPath = absolutePath + extension;
|
|
56
57
|
if (await pathExists(realPath)) return realPath;
|
|
57
58
|
}
|
|
58
|
-
throw createError(
|
|
59
|
+
throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}The file extension "${ext}" is not supported, please use one of the following extensions: ${extensions.join(', ')}`);
|
|
59
60
|
}
|
|
60
61
|
async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensions, mdFileSet) {
|
|
61
62
|
let metaItem = null;
|
|
@@ -64,13 +65,14 @@ async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensio
|
|
|
64
65
|
type: 'file'
|
|
65
66
|
} : metaItemRaw;
|
|
66
67
|
const { name, context, label, overviewHeaders, tag } = metaItem;
|
|
67
|
-
|
|
68
|
+
const metaFilePath = join(workDir, '_meta.json');
|
|
69
|
+
if ('string' != typeof name) throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}The file name "${name}" is not a string, please check it in ${picocolors.cyan(metaFilePath)}.`);
|
|
68
70
|
const absolutePath = join(workDir, name);
|
|
69
71
|
let absolutePathWithExt;
|
|
70
72
|
try {
|
|
71
73
|
absolutePathWithExt = await detectFilePath(absolutePath, extensions);
|
|
72
74
|
} catch {
|
|
73
|
-
throw createError(
|
|
75
|
+
throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}${picocolors.white('Missing page file:')} ${picocolors.yellow(`"${absolutePath}"`)}\n${picocolors.white('Please check')} ${picocolors.cyan(join(workDir, '_meta.json'))}.`);
|
|
74
76
|
}
|
|
75
77
|
const link = absolutePathToRoutePath(absolutePathWithExt, docsDir);
|
|
76
78
|
const info = await extractInfoFromFrontmatterWithAbsolutePath(absolutePathWithExt, docsDir);
|
|
@@ -203,7 +205,7 @@ function metaCustomLinkItemToSidebarItem(metaItem, workDir, docsDir) {
|
|
|
203
205
|
};
|
|
204
206
|
}
|
|
205
207
|
const { label } = metaItem;
|
|
206
|
-
throw createError(
|
|
208
|
+
throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}The custom link "${label}" does not have a link, please check it in "${join(workDir, '_meta.json')}".`);
|
|
207
209
|
}
|
|
208
210
|
function metaDividerToSidebarItem(metaItem) {
|
|
209
211
|
const { dashed } = metaItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { node_path, promises } from "../../6289.
|
|
2
|
-
import { loadFrontMatter, extractTextAndId } from "../../
|
|
1
|
+
import { node_path, promises } from "../../6289.29817fb4.js";
|
|
2
|
+
import { loadFrontMatter, extractTextAndId } from "../../9643.2dff683e.js";
|
|
3
3
|
async function pathExists(path) {
|
|
4
4
|
try {
|
|
5
5
|
await promises.access(path);
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { node_path,
|
|
2
|
-
import { isExternalUrl } from "../../4669.
|
|
1
|
+
import { node_path, promises } from "../../6289.29817fb4.js";
|
|
2
|
+
import { isExternalUrl } from "../../4669.69cb6b18.js";
|
|
3
|
+
import { pathExists } from "../utils/fs.js";
|
|
3
4
|
import { readJson } from "./utils.js";
|
|
5
|
+
import { createError } from "../utils/error.js";
|
|
4
6
|
import { addRoutePrefix } from "../route/RoutePage.js";
|
|
5
|
-
import { pathExists } from "../utils/fs.js";
|
|
6
7
|
import { hintNavJsonChangeThenPanic } from "../logger/hint.js";
|
|
7
8
|
import { scanSideMeta } from "./normalize.js";
|
|
8
9
|
async function scanNav(workDir, docsDir, metaFileSet) {
|
|
9
10
|
let navConfig;
|
|
10
11
|
const rootNavJson = node_path.resolve(workDir, '_nav.json');
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const isRootNavJsonExist = await pathExists(rootNavJson);
|
|
13
|
+
if (isRootNavJsonExist) {
|
|
13
14
|
metaFileSet.add(rootNavJson);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
try {
|
|
16
|
+
navConfig = await readJson(rootNavJson);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
if (e instanceof Error) throw createError(`[auto-nav-sidebar] Generate nav meta error: ${rootNavJson} failed, original error is (${e.message})`);
|
|
19
|
+
throw e;
|
|
20
|
+
}
|
|
21
|
+
} else navConfig = [];
|
|
18
22
|
navConfig.forEach((navItem)=>{
|
|
19
23
|
if ('items' in navItem) navItem.items.forEach((item)=>{
|
|
20
24
|
if ('link' in item && !isExternalUrl(item.link)) item.link = addRoutePrefix(workDir, docsDir, item.link);
|
package/dist/node/constants.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const importStatementRegex: RegExp;
|
|
|
4
4
|
export declare const inlineThemeScript: string;
|
|
5
5
|
export declare const PACKAGE_ROOT: string;
|
|
6
6
|
export declare const DEFAULT_THEME: string;
|
|
7
|
+
export declare const EJECTED_THEME: string;
|
|
7
8
|
export declare const TEMPLATE_PATH: string;
|
|
8
9
|
export declare const CSR_CLIENT_ENTRY: string;
|
|
9
10
|
export declare const SSR_CLIENT_ENTRY: string;
|
package/dist/node/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire, package_namespaceObject } from "../5485.
|
|
2
|
-
import { node_path } from "../6289.
|
|
1
|
+
import { createRequire, package_namespaceObject } from "../5485.9fc7f63d.js";
|
|
2
|
+
import { node_path } from "../6289.29817fb4.js";
|
|
3
3
|
const constants_require = createRequire(import.meta.url);
|
|
4
4
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
5
5
|
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
|
@@ -15,6 +15,7 @@ const inlineThemeScript = `{
|
|
|
15
15
|
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
16
16
|
const PACKAGE_ROOT = node_path.dirname(constants_require.resolve('@rspress/core/package.json'));
|
|
17
17
|
const DEFAULT_THEME = node_path.join(PACKAGE_ROOT, 'dist/theme');
|
|
18
|
+
const EJECTED_THEME = node_path.join(PACKAGE_ROOT, 'dist/eject-theme');
|
|
18
19
|
const TEMPLATE_PATH = node_path.join(PACKAGE_ROOT, 'index.html');
|
|
19
20
|
const CSR_CLIENT_ENTRY = node_path.join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
|
|
20
21
|
const SSR_CLIENT_ENTRY = node_path.join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
|
|
@@ -30,4 +31,4 @@ const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
|
|
|
30
31
|
const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
|
|
31
32
|
const NODE_SSG_MD_BUNDLE_FOLDER = '__ssg_md__';
|
|
32
33
|
const NODE_SSG_MD_BUNDLE_NAME = 'rspress-ssg-md-entry.cjs';
|
|
33
|
-
export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, PUBLIC_DIR, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, importStatementRegex, inlineThemeScript, isProduction };
|
|
34
|
+
export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, PUBLIC_DIR, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, importStatementRegex, inlineThemeScript, isProduction };
|
package/dist/node/eject.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { node_path, logger, promises, picocolors } from "../6289.
|
|
2
|
-
import {
|
|
3
|
-
const eject_filename = fileURLToPath(import.meta.url);
|
|
4
|
-
const eject_dirname = node_path.dirname(eject_filename);
|
|
1
|
+
import { node_path, logger, promises, picocolors } from "../6289.29817fb4.js";
|
|
2
|
+
import { EJECTED_THEME } from "./constants.js";
|
|
5
3
|
let _themeComponentsPathOverride;
|
|
6
|
-
function __setThemeComponentsPathForTesting(themePath) {
|
|
7
|
-
_themeComponentsPathOverride = themePath;
|
|
8
|
-
}
|
|
9
4
|
function getThemeComponentsPath() {
|
|
10
5
|
if (_themeComponentsPathOverride) return _themeComponentsPathOverride;
|
|
11
|
-
return node_path.join(
|
|
6
|
+
return node_path.join(EJECTED_THEME, 'components');
|
|
12
7
|
}
|
|
13
8
|
async function getAvailableComponents() {
|
|
14
9
|
return [
|
|
@@ -21,11 +16,13 @@ async function getAvailableComponents() {
|
|
|
21
16
|
'HomeHero',
|
|
22
17
|
'HomeBackground',
|
|
23
18
|
'HomeFooter',
|
|
19
|
+
'SourceCode',
|
|
24
20
|
'Toc',
|
|
25
21
|
'Tabs',
|
|
22
|
+
'Tag',
|
|
26
23
|
'PackageManagerTabs',
|
|
27
24
|
'PrevNextPage',
|
|
28
|
-
'
|
|
25
|
+
'OverviewGroup',
|
|
29
26
|
'Root',
|
|
30
27
|
'SocialLinks',
|
|
31
28
|
'Steps'
|
|
@@ -108,4 +105,4 @@ async function listComponents() {
|
|
|
108
105
|
});
|
|
109
106
|
logger.info(`💡 Usage: ${picocolors.dim('rspress eject <ComponentName>')}\n`);
|
|
110
107
|
}
|
|
111
|
-
export {
|
|
108
|
+
export { ejectComponent, listComponents };
|