@rspress/core 0.0.8 → 0.0.10
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.d.ts +1 -10
- package/dist/index.js +189 -234
- package/dist/index.js.map +1 -1
- package/dist/loader.js +1 -3
- package/dist/loader.js.map +1 -1
- package/dist/theme/bundle.css +96 -159
- package/dist/theme/bundle.d.ts +1 -1
- package/dist/theme/bundle.js +930 -926
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +14 -13
- package/runtime.ts +1 -1
- package/src/theme-default/components/Aside/index.css +23 -0
- package/src/theme-default/components/Aside/index.tsx +7 -13
- package/src/theme-default/components/EditLink/index.module.scss +3 -3
- package/src/theme-default/components/EditLink/index.tsx +0 -5
- package/src/theme-default/components/HomeHero/index.module.scss +6 -0
- package/src/theme-default/components/HomeHero/index.tsx +4 -4
- package/src/theme-default/components/Nav/index.module.scss +0 -1
- package/src/theme-default/components/Nav/index.tsx +3 -3
- package/src/theme-default/components/Search/logic/providers/LocalProvider.ts +1 -2
- package/src/theme-default/components/Sidebar/SidebarGroup.tsx +180 -0
- package/src/theme-default/components/Sidebar/SidebarItem.tsx +60 -0
- package/src/theme-default/components/Sidebar/index.module.scss +22 -5
- package/src/theme-default/components/Sidebar/index.tsx +39 -248
- package/src/theme-default/components/Tabs/index.module.scss +11 -18
- package/src/theme-default/components/Tabs/index.tsx +1 -1
- package/src/theme-default/layout/DocLayout/index.module.scss +17 -18
- package/src/theme-default/layout/Layout/index.tsx +0 -1
- package/src/theme-default/logic/sideEffects.ts +3 -1
- package/src/theme-default/logic/useEditLink.ts +6 -3
- package/src/theme-default/styles/{doc/code.css → code.css} +4 -1
- package/src/theme-default/styles/index.ts +1 -3
- package/src/theme-default/styles/vars.css +2 -2
- package/src/theme-default/assets/edit.svg +0 -1
- package/src/theme-default/styles/doc/container.css +0 -103
- package/src/theme-default/styles/doc/index.css +0 -6
- /package/dist/theme/{index.ts → index.js} +0 -0
|
@@ -1,255 +1,45 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
NormalizedSidebarGroup,
|
|
4
|
+
SidebarItem as ISidebarItem,
|
|
5
|
+
} from '@rspress/shared';
|
|
6
|
+
import { matchRoutes } from 'react-router-dom';
|
|
4
7
|
import { routes } from 'virtual-routes';
|
|
5
|
-
import { Link } from '../Link';
|
|
6
8
|
import { isActive } from '../../logic';
|
|
7
|
-
import ArrowRight from '../../assets/arrow-right.svg';
|
|
8
|
-
import { Tag } from '../Tag';
|
|
9
9
|
import styles from './index.module.scss';
|
|
10
|
-
import {
|
|
10
|
+
import { SidebarItem } from './SidebarItem';
|
|
11
|
+
import { removeBase, usePageData } from '@/runtime';
|
|
11
12
|
|
|
12
|
-
interface
|
|
13
|
-
isSidebarOpen?: boolean;
|
|
14
|
-
pathname: string;
|
|
15
|
-
langRoutePrefix: string;
|
|
16
|
-
sidebarData: (NormalizedSidebarGroup | SidebarItem)[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const highlightTitleStyle = {
|
|
20
|
-
color: 'var(--rp-c-text-1)',
|
|
21
|
-
fontSize: '14px',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
interface SidebarItemProps {
|
|
13
|
+
export interface SidebarItemProps {
|
|
25
14
|
id: string;
|
|
26
|
-
item:
|
|
15
|
+
item: ISidebarItem | NormalizedSidebarGroup;
|
|
27
16
|
depth: number;
|
|
28
17
|
activeMatcher: (link: string) => boolean;
|
|
29
18
|
collapsed?: boolean;
|
|
30
19
|
setSidebarData: React.Dispatch<
|
|
31
|
-
React.SetStateAction<(NormalizedSidebarGroup |
|
|
20
|
+
React.SetStateAction<(NormalizedSidebarGroup | ISidebarItem)[]>
|
|
32
21
|
>;
|
|
33
22
|
preloadLink: (link: string) => void;
|
|
34
23
|
}
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (active) {
|
|
43
|
-
ref.current?.scrollIntoView({
|
|
44
|
-
block: 'center',
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
const { text } = item;
|
|
50
|
-
|
|
51
|
-
if ('items' in item) {
|
|
52
|
-
return (
|
|
53
|
-
<SidebarGroupComp
|
|
54
|
-
id={id}
|
|
55
|
-
key={`${item.text}-${id}`}
|
|
56
|
-
item={item}
|
|
57
|
-
depth={depth}
|
|
58
|
-
activeMatcher={activeMatcher}
|
|
59
|
-
collapsed={item.collapsed}
|
|
60
|
-
setSidebarData={setSidebarData}
|
|
61
|
-
preloadLink={props.preloadLink}
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
} else {
|
|
65
|
-
return (
|
|
66
|
-
<Link href={normalizeHref(item.link)} className={styles.menuLink}>
|
|
67
|
-
<div
|
|
68
|
-
ref={ref}
|
|
69
|
-
onMouseEnter={() => props.preloadLink(item.link)}
|
|
70
|
-
className={`${
|
|
71
|
-
active ? styles.menuItemActive : styles.menuItem
|
|
72
|
-
} mt-1 py-1.5 px-2 rounded-xl font-medium flex`}
|
|
73
|
-
style={{
|
|
74
|
-
// The first level menu item will have the same font size as the sidebar group
|
|
75
|
-
fontSize: depth === 0 ? '14px' : '13px',
|
|
76
|
-
marginLeft: depth === 0 ? 0 : '20px',
|
|
77
|
-
...(depth === 0 ? highlightTitleStyle : {}),
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
<Tag tag={item.tag} />
|
|
81
|
-
{text}
|
|
82
|
-
</div>
|
|
83
|
-
</Link>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
25
|
+
interface Props {
|
|
26
|
+
isSidebarOpen?: boolean;
|
|
27
|
+
pathname: string;
|
|
28
|
+
langRoutePrefix: string;
|
|
29
|
+
sidebarData: (NormalizedSidebarGroup | ISidebarItem)[];
|
|
86
30
|
}
|
|
87
31
|
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const initialRender = useRef(true);
|
|
95
|
-
const initialState = useRef((item as NormalizedSidebarGroup).collapsed);
|
|
96
|
-
const active = item.link && activeMatcher(item.link);
|
|
97
|
-
const { collapsed, collapsible = true } = item as NormalizedSidebarGroup;
|
|
98
|
-
const collapsibleIcon = (
|
|
99
|
-
<div
|
|
100
|
-
style={{
|
|
101
|
-
cursor: 'pointer',
|
|
102
|
-
transition: 'transform 0.2s ease-out',
|
|
103
|
-
transform: collapsed ? 'rotate(0deg)' : 'rotate(90deg)',
|
|
104
|
-
}}
|
|
105
|
-
>
|
|
106
|
-
<ArrowRight />
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (initialRender.current) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (!containerRef.current || !innerRef.current) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (transitionRef.current) {
|
|
120
|
-
clearTimeout(transitionRef.current);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const container = containerRef.current;
|
|
124
|
-
const inner = innerRef.current;
|
|
125
|
-
// We should add the margin-top(4px) of first item in list, which is a part of the height of the container
|
|
126
|
-
const contentHeight = inner.clientHeight + 4;
|
|
127
|
-
if (collapsed) {
|
|
128
|
-
container.style.maxHeight = `${contentHeight}px`;
|
|
129
|
-
container.style.transitionDuration = '0.5s';
|
|
130
|
-
inner.style.opacity = '0';
|
|
131
|
-
|
|
132
|
-
transitionRef.current = setTimeout(() => {
|
|
133
|
-
if (containerRef.current) {
|
|
134
|
-
containerRef.current.style.maxHeight = '0px';
|
|
135
|
-
}
|
|
136
|
-
}, 0);
|
|
137
|
-
} else {
|
|
138
|
-
container.style.maxHeight = `${contentHeight}px`;
|
|
139
|
-
container.style.transitionDuration = '0.3s';
|
|
140
|
-
inner.style.opacity = '1';
|
|
141
|
-
|
|
142
|
-
transitionRef.current = setTimeout(() => {
|
|
143
|
-
if (containerRef.current) {
|
|
144
|
-
containerRef.current.style.removeProperty('max-height');
|
|
145
|
-
}
|
|
146
|
-
}, 300);
|
|
147
|
-
}
|
|
148
|
-
}, [collapsed]);
|
|
149
|
-
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
initialRender.current = false;
|
|
152
|
-
}, []);
|
|
32
|
+
export const highlightTitleStyle = {
|
|
33
|
+
color: 'var(--rp-c-text-1)',
|
|
34
|
+
fontSize: '14px',
|
|
35
|
+
paddingLeft: '24px',
|
|
36
|
+
fontWeight: 'bold',
|
|
37
|
+
};
|
|
153
38
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const newSidebarData = [...sidebarData];
|
|
159
|
-
const indexes = id.split('-').map(Number);
|
|
160
|
-
const initialIndex = indexes.shift()!;
|
|
161
|
-
const root = newSidebarData[initialIndex];
|
|
162
|
-
let current = root;
|
|
163
|
-
for (const index of indexes) {
|
|
164
|
-
current = (current as NormalizedSidebarGroup).items[index];
|
|
165
|
-
}
|
|
166
|
-
if ('items' in current) {
|
|
167
|
-
current.collapsed = !current.collapsed;
|
|
168
|
-
}
|
|
169
|
-
return newSidebarData;
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<section
|
|
175
|
-
key={id}
|
|
176
|
-
className="mt-1 block"
|
|
177
|
-
style={{
|
|
178
|
-
marginLeft: depth === 0 ? 0 : '20px',
|
|
179
|
-
}}
|
|
180
|
-
>
|
|
181
|
-
<div
|
|
182
|
-
style={{
|
|
183
|
-
cursor: collapsible || item.link ? 'pointer' : 'normal',
|
|
184
|
-
}}
|
|
185
|
-
className={`flex justify-between items-center rounded-xl ${
|
|
186
|
-
// eslint-disable-next-line no-nested-ternary
|
|
187
|
-
active
|
|
188
|
-
? styles.menuItemActive
|
|
189
|
-
: collapsible || item.link
|
|
190
|
-
? styles.menuItem
|
|
191
|
-
: styles.menuItemStatic
|
|
192
|
-
}`}
|
|
193
|
-
onMouseEnter={() => item.link && props.preloadLink(item.link)}
|
|
194
|
-
onClick={e => {
|
|
195
|
-
if (item.link) {
|
|
196
|
-
navigate(withBase(normalizeHref(item.link)));
|
|
197
|
-
collapsed && toggleCollapse(e);
|
|
198
|
-
} else {
|
|
199
|
-
collapsible && toggleCollapse(e);
|
|
200
|
-
}
|
|
201
|
-
}}
|
|
202
|
-
>
|
|
203
|
-
<h2
|
|
204
|
-
className="py-1 px-2 text-sm font-medium flex"
|
|
205
|
-
style={{
|
|
206
|
-
...(depth === 0 ? highlightTitleStyle : {}),
|
|
207
|
-
}}
|
|
208
|
-
>
|
|
209
|
-
<Tag tag={item.tag} />
|
|
210
|
-
{item.text}
|
|
211
|
-
</h2>
|
|
212
|
-
{collapsible && (
|
|
213
|
-
<div
|
|
214
|
-
className={`${styles.collapseContainer} p-2 rounded-xl`}
|
|
215
|
-
onClick={toggleCollapse}
|
|
216
|
-
>
|
|
217
|
-
{collapsibleIcon}
|
|
218
|
-
</div>
|
|
219
|
-
)}
|
|
220
|
-
</div>
|
|
221
|
-
<div
|
|
222
|
-
ref={containerRef}
|
|
223
|
-
className="transition-all duration-300 ease-in-out"
|
|
224
|
-
style={{
|
|
225
|
-
overflow: 'hidden',
|
|
226
|
-
maxHeight: initialState.current ? 0 : undefined,
|
|
227
|
-
}}
|
|
228
|
-
>
|
|
229
|
-
<div
|
|
230
|
-
ref={innerRef}
|
|
231
|
-
className="rspress-sidebar-group transition-opacity duration-500 ease-in-out"
|
|
232
|
-
style={{
|
|
233
|
-
opacity: initialState.current ? 0 : 1,
|
|
234
|
-
}}
|
|
235
|
-
>
|
|
236
|
-
{(item as NormalizedSidebarGroup)?.items?.map((item, index) => (
|
|
237
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
238
|
-
<div key={index}>
|
|
239
|
-
<SidebarItemComp
|
|
240
|
-
{...props}
|
|
241
|
-
item={item}
|
|
242
|
-
depth={depth + 1}
|
|
243
|
-
id={`${id}-${index}`}
|
|
244
|
-
preloadLink={props.preloadLink}
|
|
245
|
-
/>
|
|
246
|
-
</div>
|
|
247
|
-
))}
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
</section>
|
|
251
|
-
);
|
|
252
|
-
}
|
|
39
|
+
// Note: the cache object won't be reassign in other module
|
|
40
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
41
|
+
export let matchCache: WeakMap<NormalizedSidebarGroup | ISidebarItem, boolean> =
|
|
42
|
+
new WeakMap();
|
|
253
43
|
|
|
254
44
|
export function SideBar(props: Props) {
|
|
255
45
|
const {
|
|
@@ -265,18 +55,18 @@ export function SideBar(props: Props) {
|
|
|
265
55
|
const hideNavbar =
|
|
266
56
|
frontmatter?.hideNavbar ?? themeConfig?.hideNavbar ?? false;
|
|
267
57
|
const [sidebarData, setSidebarData] = useState<
|
|
268
|
-
(
|
|
58
|
+
(ISidebarItem | NormalizedSidebarGroup)[]
|
|
269
59
|
>(rawSidebarData.filter(Boolean).flat());
|
|
270
60
|
const pathname = decodeURIComponent(rawPathname);
|
|
271
61
|
useEffect(() => {
|
|
62
|
+
if (props.sidebarData === sidebarData) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
272
65
|
// 1. Update sidebarData when pathname changes
|
|
273
66
|
// 2. For current active item, expand its parent group
|
|
274
67
|
// Cache, Avoid redundant calculation
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
boolean
|
|
278
|
-
>();
|
|
279
|
-
const match = (item: NormalizedSidebarGroup | SidebarItem) => {
|
|
68
|
+
matchCache = new WeakMap<NormalizedSidebarGroup | ISidebarItem, boolean>();
|
|
69
|
+
const match = (item: NormalizedSidebarGroup | ISidebarItem) => {
|
|
280
70
|
if (matchCache.has(item)) {
|
|
281
71
|
return matchCache.get(item);
|
|
282
72
|
}
|
|
@@ -294,7 +84,7 @@ export function SideBar(props: Props) {
|
|
|
294
84
|
matchCache.set(item, false);
|
|
295
85
|
return false;
|
|
296
86
|
};
|
|
297
|
-
const traverse = (item: NormalizedSidebarGroup |
|
|
87
|
+
const traverse = (item: NormalizedSidebarGroup | ISidebarItem) => {
|
|
298
88
|
if ('items' in item) {
|
|
299
89
|
item.items.forEach(traverse);
|
|
300
90
|
if (match(item)) {
|
|
@@ -302,8 +92,9 @@ export function SideBar(props: Props) {
|
|
|
302
92
|
}
|
|
303
93
|
}
|
|
304
94
|
};
|
|
305
|
-
sidebarData.
|
|
306
|
-
|
|
95
|
+
const newSidebarData = props.sidebarData.filter(Boolean).flat();
|
|
96
|
+
newSidebarData.forEach(traverse);
|
|
97
|
+
setSidebarData(newSidebarData);
|
|
307
98
|
}, [props.sidebarData, pathname]);
|
|
308
99
|
|
|
309
100
|
const removeLangPrefix = (path: string) => {
|
|
@@ -339,10 +130,10 @@ export function SideBar(props: Props) {
|
|
|
339
130
|
overflow: 'scroll',
|
|
340
131
|
}}
|
|
341
132
|
>
|
|
342
|
-
<nav className="pb-
|
|
133
|
+
<nav className="pb-2">
|
|
343
134
|
{sidebarData.map(
|
|
344
|
-
(item: NormalizedSidebarGroup |
|
|
345
|
-
<
|
|
135
|
+
(item: NormalizedSidebarGroup | ISidebarItem, index: number) => (
|
|
136
|
+
<SidebarItem
|
|
346
137
|
id={String(index)}
|
|
347
138
|
item={item}
|
|
348
139
|
depth={0}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
.container {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
background-color: var(--rp-code-block-bg);
|
|
3
|
+
contain: content;
|
|
4
|
+
border-radius: 16px;
|
|
5
5
|
|
|
6
|
-
:global(
|
|
7
|
-
|
|
6
|
+
:global(div[class*='language-']) {
|
|
7
|
+
margin: 6px 0;
|
|
8
|
+
code {
|
|
9
|
+
background-color: var(--rp-c-bg);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
.tab-list {
|
|
@@ -12,12 +16,7 @@
|
|
|
12
16
|
padding-top: 4px;
|
|
13
17
|
display: flex;
|
|
14
18
|
min-width: 100%;
|
|
15
|
-
|
|
16
|
-
border-color: var(--rp-c-gray-light-3);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
:global(.dark) .tab-list {
|
|
20
|
-
border-color: var(--rp-c-dark-light-1);
|
|
19
|
+
background-color: var(--rp-code-title-bg);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
.tab {
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
border-bottom: 1px solid transparent;
|
|
26
25
|
box-sizing: border-box;
|
|
27
26
|
margin-right: 10px;
|
|
28
|
-
padding: 6px
|
|
27
|
+
padding: 6px 12px;
|
|
29
28
|
margin-bottom: -1px;
|
|
30
29
|
user-select: none;
|
|
31
30
|
transition: all 0.2s ease-in-out;
|
|
@@ -38,12 +37,6 @@
|
|
|
38
37
|
.not-selected:hover {
|
|
39
38
|
color: var(--rp-c-text-1);
|
|
40
39
|
border-color: var(--rp-c-gray);
|
|
41
|
-
border-top-left-radius: 10px;
|
|
42
|
-
border-top-right-radius: 10px;
|
|
43
|
-
background-color: var(--rp-c-gray-light-5);
|
|
44
|
-
:global(.dark) & {
|
|
45
|
-
background-color: var(--rp-c-dark-light-3);
|
|
46
|
-
}
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
.selected {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
.content {
|
|
33
33
|
margin-left: var(--rp-sidebar-width);
|
|
34
34
|
width: calc(100% - var(--rp-sidebar-width));
|
|
35
|
-
padding: 48px 48px 72px
|
|
35
|
+
padding: 48px 48px 72px 0;
|
|
36
36
|
|
|
37
37
|
:global(.rspress-doc) {
|
|
38
38
|
width: 100%;
|
|
@@ -45,41 +45,40 @@
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@media (min-width: 1280px) {
|
|
48
|
-
.docLayout {
|
|
49
|
-
width: calc(1280px - 100vw + 100%);
|
|
50
|
-
margin-left: calc((100vw - 1280px) / 2);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
.aside-container {
|
|
54
49
|
display: block;
|
|
55
50
|
width: var(--rp-aside-width);
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
.content {
|
|
59
|
-
margin-left: var(--rp-sidebar-width);
|
|
60
|
-
width: calc(100% - var(--rp-sidebar-width));
|
|
61
54
|
padding: 48px 0 72px 0;
|
|
62
|
-
|
|
63
55
|
:global(.rspress-doc) {
|
|
64
|
-
|
|
56
|
+
padding: 0 48px;
|
|
57
|
+
box-sizing: content-box;
|
|
58
|
+
width: calc(100vw - var(--rp-aside-width) - var(--rp-sidebar-width));
|
|
65
59
|
}
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
|
|
69
63
|
@media (min-width: 1440px) {
|
|
70
64
|
.docLayout {
|
|
71
|
-
width:
|
|
72
|
-
margin-left:
|
|
65
|
+
width: 100%;
|
|
66
|
+
margin-left: 0;
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
.content {
|
|
76
|
-
padding: 48px 0 72px 64px;
|
|
77
|
-
|
|
78
70
|
:global(.rspress-doc) {
|
|
79
|
-
|
|
80
|
-
width: calc(
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
box-sizing: content-box;
|
|
72
|
+
width: calc(100vw - var(--rp-sidebar-width) - var(--rp-aside-width));
|
|
73
|
+
padding: 0
|
|
74
|
+
max(
|
|
75
|
+
48px,
|
|
76
|
+
calc(
|
|
77
|
+
(100vw - var(--rp-sidebar-width) - var(--rp-aside-width) - 960px) /
|
|
78
|
+
2
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
max-width: 960px;
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
}
|
|
@@ -50,7 +50,6 @@ export const Layout: React.FC<LayoutProps> = props => {
|
|
|
50
50
|
const defaultLang = siteData.lang || '';
|
|
51
51
|
const hideNavbar =
|
|
52
52
|
frontmatter?.hideNavbar ?? themeConfig?.hideNavbar ?? false;
|
|
53
|
-
|
|
54
53
|
// Priority: front matter title > h1 title
|
|
55
54
|
let title = (frontmatter?.title as string) ?? articleTitle;
|
|
56
55
|
const mainTitle = siteData.title || localesData.title;
|
|
@@ -104,7 +104,9 @@ export function bindingAsideScroll() {
|
|
|
104
104
|
const activate = (links: HTMLAnchorElement[], index: number) => {
|
|
105
105
|
if (links[index]) {
|
|
106
106
|
const id = links[index].getAttribute('href');
|
|
107
|
-
const currentLink = aside?.querySelector(
|
|
107
|
+
const currentLink = aside?.querySelector(
|
|
108
|
+
`a[href="#${id?.slice(1)}"] > span`,
|
|
109
|
+
);
|
|
108
110
|
if (currentLink) {
|
|
109
111
|
if (prevActiveLink) {
|
|
110
112
|
prevActiveLink.classList.remove('aside-active');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLocaleSiteData } from './useLocaleSiteData';
|
|
1
2
|
import { usePageData } from '@/runtime';
|
|
2
3
|
|
|
3
4
|
interface EditLink {
|
|
@@ -6,9 +7,11 @@ interface EditLink {
|
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export function useEditLink() {
|
|
9
|
-
const
|
|
10
|
+
const { siteData, page } = usePageData();
|
|
11
|
+
const locales = useLocaleSiteData();
|
|
10
12
|
|
|
11
|
-
const editLink: EditLink =
|
|
13
|
+
const editLink: EditLink =
|
|
14
|
+
locales.editLink ?? siteData.themeConfig?.editLink ?? {};
|
|
12
15
|
|
|
13
16
|
if (!editLink.docRepoBaseUrl || !editLink.text) {
|
|
14
17
|
return null;
|
|
@@ -20,7 +23,7 @@ export function useEditLink() {
|
|
|
20
23
|
docRepoBaseUrl += '/';
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
const relativePagePath =
|
|
26
|
+
const relativePagePath = page._relativePath.replace(/\\/g, '/');
|
|
24
27
|
const link = `${docRepoBaseUrl}${relativePagePath}`;
|
|
25
28
|
|
|
26
29
|
return {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
margin: 16px 0;
|
|
58
58
|
background-color: var(--rp-code-block-bg);
|
|
59
59
|
overflow-x: auto;
|
|
60
|
-
transition:
|
|
60
|
+
transition: none;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
.rspress-doc .rspress-code-title {
|
|
@@ -71,6 +71,9 @@
|
|
|
71
71
|
.rspress-doc div[class*='language-'] {
|
|
72
72
|
border-radius: 16px;
|
|
73
73
|
margin: 24px 0;
|
|
74
|
+
/* box-shadow: 0px 0.8px 2px rgba(0, 0, 0, 0.032), */
|
|
75
|
+
/* 0px 2.7px 6.7px rgba(0, 0, 0, 0.048), 0px 12px 30px rgba(0, 0, 0, 0.08); */
|
|
76
|
+
contain: content;
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg width="18" height="18" viewBox="0 0 32 32"><path fill="currentColor" d="M2 26h28v2H2zM25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"/></svg>
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Container Style, the dom structure is Related to `@modern-js/remark-container`.
|
|
3
|
-
*/
|
|
4
|
-
:root {
|
|
5
|
-
--rp-container-info-border: rgba(7, 156, 112, 0.3);
|
|
6
|
-
--rp-container-info-text: #399c70;
|
|
7
|
-
--rp-container-info-bg: rgba(7, 156, 112, 0.02);
|
|
8
|
-
--rp-container-info-code-bg: rgba(7, 156, 112, 0.1);
|
|
9
|
-
|
|
10
|
-
--rp-container-warning-border: rgba(255, 197, 23, 0.5);
|
|
11
|
-
--rp-container-warning-text: #ad850e;
|
|
12
|
-
--rp-container-warning-bg: rgba(255, 197, 23, 0.02);
|
|
13
|
-
--rp-container-warning-code-bg: rgba(255, 197, 23, 0.1);
|
|
14
|
-
|
|
15
|
-
--rp-container-danger-border: rgba(237, 60, 80, 0.5);
|
|
16
|
-
--rp-container-danger-text: #ab2131;
|
|
17
|
-
--rp-container-danger-bg: rgba(237, 60, 80, 0.02);
|
|
18
|
-
--rp-container-danger-code-bg: rgba(237, 60, 80, 0.1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.dark {
|
|
22
|
-
--rp-container-warning-border: rgba(255, 197, 23, 0.25);
|
|
23
|
-
--rp-container-warning-text: #fcd253;
|
|
24
|
-
|
|
25
|
-
--rp-container-danger-border: rgba(237, 60, 80, 0.25);
|
|
26
|
-
--rp-container-danger-text: #f54e82;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.rspress-doc .modern-directive {
|
|
30
|
-
border: 1px solid transparent;
|
|
31
|
-
border-radius: 16px;
|
|
32
|
-
padding: 20px 24px 12px;
|
|
33
|
-
line-height: 1.7;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
font-weight: 500;
|
|
36
|
-
margin: 24px 0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.rspress-doc .modern-directive .modern-directive-title {
|
|
40
|
-
margin-bottom: 8px;
|
|
41
|
-
font-weight: 600;
|
|
42
|
-
font-size: 16px;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.rspress-doc .modern-directive .modern-directive-content p {
|
|
46
|
-
margin: 8px 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.rspress-doc .modern-directive .modern-directive-icon {
|
|
50
|
-
display: inline-block;
|
|
51
|
-
width: 20px;
|
|
52
|
-
height: 20px;
|
|
53
|
-
margin-right: 3px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.rspress-doc .modern-directive p {
|
|
57
|
-
margin: 8px 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.rspress-doc .modern-directive code {
|
|
61
|
-
color: inherit;
|
|
62
|
-
font-weight: bold;
|
|
63
|
-
font-size: 13px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.rspress-doc .modern-directive.tip,
|
|
67
|
-
.rspress-doc .modern-directive.note,
|
|
68
|
-
.rspress-doc .modern-directive.info {
|
|
69
|
-
border-color: var(--rp-container-info-border);
|
|
70
|
-
color: var(--rp-container-info-text);
|
|
71
|
-
background-color: var(--rp-container-info-bg);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.rspress-doc .modern-directive.tip code,
|
|
75
|
-
.rspress-doc .modern-directive.note code {
|
|
76
|
-
background-color: var(--rp-container-info-code-bg);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.rspress-doc .modern-directive.info code {
|
|
80
|
-
background-color: var(--rp-container-info-code-bg);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.rspress-doc .modern-directive.warning {
|
|
84
|
-
border-color: var(--rp-container-warning-border);
|
|
85
|
-
color: var(--rp-container-warning-text);
|
|
86
|
-
background-color: var(--rp-container-warning-bg);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.rspress-doc .modern-directive.warning code {
|
|
90
|
-
background-color: var(--rp-container-warning-code-bg);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.rspress-doc .modern-directive.caution,
|
|
94
|
-
.rspress-doc .modern-directive.danger {
|
|
95
|
-
border-color: var(--rp-container-danger-border);
|
|
96
|
-
color: var(--rp-container-danger-text);
|
|
97
|
-
background-color: var(--rp-container-danger-bg);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.rspress-doc .modern-directive.caution code,
|
|
101
|
-
.rspress-doc .modern-directive.danger code {
|
|
102
|
-
background-color: var(--rp-container-danger-code-bg);
|
|
103
|
-
}
|
|
File without changes
|