@rspress/shared 0.0.0-next-20231020055855 → 0.0.0-next-20231108104528
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 +48 -24
- package/dist/index.js +9 -1
- package/dist/index.mjs +8 -1
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { RsbuildPlugin } from '@rsbuild/core';
|
2
|
+
import { RsbuildConfig } from '@rsbuild/core/rspack-provider';
|
2
3
|
import { PluggableList } from 'unified';
|
3
|
-
import { BuilderPlugin } from '@modern-js/builder';
|
4
4
|
|
5
5
|
interface ZoomOptions {
|
6
6
|
/**
|
@@ -65,9 +65,11 @@ interface Config$1 {
|
|
65
65
|
*/
|
66
66
|
outline?: boolean;
|
67
67
|
/**
|
68
|
-
* The nav items.
|
68
|
+
* The nav items. When it's an object, the key is the version of current doc.
|
69
69
|
*/
|
70
|
-
nav?: NavItem[]
|
70
|
+
nav?: NavItem[] | {
|
71
|
+
[key: string]: NavItem[];
|
72
|
+
};
|
71
73
|
/**
|
72
74
|
* The sidebar items.
|
73
75
|
*/
|
@@ -141,7 +143,7 @@ interface LocaleConfig {
|
|
141
143
|
/**
|
142
144
|
* Theme i18n config
|
143
145
|
*/
|
144
|
-
nav?:
|
146
|
+
nav?: Nav;
|
145
147
|
sidebar?: Sidebar;
|
146
148
|
outlineTitle?: string;
|
147
149
|
lastUpdatedText?: string;
|
@@ -151,6 +153,9 @@ interface LocaleConfig {
|
|
151
153
|
nextPageText?: string;
|
152
154
|
langRoutePrefix?: string;
|
153
155
|
}
|
156
|
+
type Nav = NavItem[] | {
|
157
|
+
[key: string]: NavItem[];
|
158
|
+
};
|
154
159
|
type NavItem = NavItemWithLink | NavItemWithChildren | NavItemWithLinkAndChildren;
|
155
160
|
type NavItemWithLink = {
|
156
161
|
text: string;
|
@@ -162,13 +167,13 @@ type NavItemWithLink = {
|
|
162
167
|
interface NavItemWithChildren {
|
163
168
|
text?: string;
|
164
169
|
tag?: string;
|
165
|
-
items:
|
170
|
+
items: NavItemWithLink[];
|
166
171
|
position?: 'left' | 'right';
|
167
172
|
}
|
168
173
|
interface NavItemWithLinkAndChildren {
|
169
174
|
text: string;
|
170
175
|
link: string;
|
171
|
-
items:
|
176
|
+
items: NavItemWithLink[];
|
172
177
|
tag?: string;
|
173
178
|
activeMatch?: string;
|
174
179
|
position?: 'left' | 'right';
|
@@ -178,13 +183,13 @@ type Image = string | {
|
|
178
183
|
alt?: string;
|
179
184
|
};
|
180
185
|
interface Sidebar {
|
181
|
-
[path: string]: (SidebarGroup | SidebarItem)[];
|
186
|
+
[path: string]: (SidebarGroup | SidebarItem | SidebarDivider)[];
|
182
187
|
}
|
183
188
|
interface SidebarGroup {
|
184
189
|
text: string;
|
185
190
|
link?: string;
|
186
191
|
tag?: string;
|
187
|
-
items: (SidebarItem | SidebarGroup | string)[];
|
192
|
+
items: (SidebarItem | SidebarDivider | SidebarGroup | string)[];
|
188
193
|
collapsible?: boolean;
|
189
194
|
collapsed?: boolean;
|
190
195
|
}
|
@@ -193,6 +198,9 @@ type SidebarItem = {
|
|
193
198
|
link: string;
|
194
199
|
tag?: string;
|
195
200
|
};
|
201
|
+
type SidebarDivider = {
|
202
|
+
dividerType: 'dashed' | 'solid';
|
203
|
+
};
|
196
204
|
interface EditLink {
|
197
205
|
/**
|
198
206
|
* Custom repository url for edit link.
|
@@ -220,7 +228,7 @@ interface SocialLink {
|
|
220
228
|
mode: 'link' | 'text' | 'img';
|
221
229
|
content: string;
|
222
230
|
}
|
223
|
-
type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'instagram' | 'linkedin' | 'slack' | 'twitter' | 'youtube' | '
|
231
|
+
type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'instagram' | 'linkedin' | 'slack' | 'twitter' | 'youtube' | 'wechat' | 'qq' | 'juejin' | 'zhihu' | 'bilibili' | 'weibo' | 'gitlab' | {
|
224
232
|
svg: string;
|
225
233
|
};
|
226
234
|
interface Footer {
|
@@ -235,12 +243,12 @@ interface LocaleLink {
|
|
235
243
|
link: string;
|
236
244
|
}
|
237
245
|
interface NormalizedSidebarGroup extends Omit<SidebarGroup, 'items'> {
|
238
|
-
items: (SidebarItem | NormalizedSidebarGroup)[];
|
246
|
+
items: (SidebarDivider | SidebarItem | NormalizedSidebarGroup)[];
|
239
247
|
collapsible: boolean;
|
240
248
|
collapsed: boolean;
|
241
249
|
}
|
242
250
|
interface NormalizedSidebar {
|
243
|
-
[path: string]: (NormalizedSidebarGroup | SidebarItem)[];
|
251
|
+
[path: string]: (NormalizedSidebarGroup | SidebarItem | SidebarDivider)[];
|
244
252
|
}
|
245
253
|
interface NormalizedLocales extends Omit<LocaleConfig, 'sidebar'> {
|
246
254
|
sidebar: NormalizedSidebar;
|
@@ -278,9 +286,9 @@ interface RspressPlugin {
|
|
278
286
|
globalComponents?: string[];
|
279
287
|
};
|
280
288
|
/**
|
281
|
-
*
|
289
|
+
* Rsbuild config.
|
282
290
|
*/
|
283
|
-
builderConfig?:
|
291
|
+
builderConfig?: RsbuildConfig;
|
284
292
|
/**
|
285
293
|
* Inject global components.
|
286
294
|
*/
|
@@ -291,29 +299,33 @@ interface RspressPlugin {
|
|
291
299
|
config?: (config: UserConfig, utils: {
|
292
300
|
addPlugin: (plugin: RspressPlugin) => void;
|
293
301
|
removePlugin: (pluginName: string) => void;
|
294
|
-
}) => UserConfig | Promise<UserConfig>;
|
302
|
+
}, isProd: boolean) => UserConfig | Promise<UserConfig>;
|
295
303
|
/**
|
296
304
|
* Callback before build
|
297
305
|
*/
|
298
|
-
beforeBuild?: (config: UserConfig, isProd: boolean) => Promise<void>;
|
306
|
+
beforeBuild?: (config: UserConfig, isProd: boolean) => void | Promise<void>;
|
299
307
|
/**
|
300
308
|
* Callback after build
|
301
309
|
*/
|
302
|
-
afterBuild?: (config: UserConfig, isProd: boolean) => Promise<void>;
|
310
|
+
afterBuild?: (config: UserConfig, isProd: boolean) => void | Promise<void>;
|
303
311
|
/**
|
304
312
|
* Extend every page's data
|
305
313
|
*/
|
306
314
|
extendPageData?: (pageData: PageIndexInfo & {
|
307
315
|
[key: string]: unknown;
|
308
|
-
}) => void | Promise<void>;
|
316
|
+
}, isProd: boolean) => void | Promise<void>;
|
309
317
|
/**
|
310
318
|
* Add custom route
|
311
319
|
*/
|
312
320
|
addPages?: (config: UserConfig, isProd: boolean) => AdditionalPage[] | Promise<AdditionalPage[]>;
|
321
|
+
/**
|
322
|
+
* Add runtime modules
|
323
|
+
*/
|
324
|
+
addRuntimeModules?: (config: UserConfig, isProd: boolean) => Record<string, string> | Promise<Record<string, string>>;
|
313
325
|
/**
|
314
326
|
* Callback after route generated
|
315
327
|
*/
|
316
|
-
routeGenerated?: (routes: RouteMeta[]) => Promise<void> | void;
|
328
|
+
routeGenerated?: (routes: RouteMeta[], isProd: boolean) => Promise<void> | void;
|
317
329
|
/**
|
318
330
|
* Add addition ssg routes, for dynamic routes.
|
319
331
|
*/
|
@@ -326,7 +338,7 @@ interface RspressPlugin {
|
|
326
338
|
* @private
|
327
339
|
* Modify search index data.
|
328
340
|
*/
|
329
|
-
modifySearchIndexData?: (data: PageIndexInfo[]) => void | Promise<void>;
|
341
|
+
modifySearchIndexData?: (data: PageIndexInfo[], isProd: boolean) => void | Promise<void>;
|
330
342
|
}
|
331
343
|
|
332
344
|
interface Route {
|
@@ -409,9 +421,9 @@ interface UserConfig<ThemeConfig = Config$1> {
|
|
409
421
|
*/
|
410
422
|
themeConfig?: ThemeConfig;
|
411
423
|
/**
|
412
|
-
*
|
424
|
+
* Rsbuild Configuration
|
413
425
|
*/
|
414
|
-
builderConfig?:
|
426
|
+
builderConfig?: RsbuildConfig;
|
415
427
|
/**
|
416
428
|
* The custom config of vite-plugin-route
|
417
429
|
*/
|
@@ -448,6 +460,10 @@ interface UserConfig<ThemeConfig = Config$1> {
|
|
448
460
|
* Search options
|
449
461
|
*/
|
450
462
|
search?: SearchOptions;
|
463
|
+
/**
|
464
|
+
* Whether to enable ssg, default is true
|
465
|
+
*/
|
466
|
+
ssg?: boolean;
|
451
467
|
/**
|
452
468
|
* Whether to enable medium-zoom, default is true
|
453
469
|
*/
|
@@ -458,7 +474,7 @@ interface UserConfig<ThemeConfig = Config$1> {
|
|
458
474
|
/**
|
459
475
|
* Add some extra builder plugins
|
460
476
|
*/
|
461
|
-
builderPlugins?:
|
477
|
+
builderPlugins?: RsbuildPlugin[];
|
462
478
|
/**
|
463
479
|
* Multi version config
|
464
480
|
*/
|
@@ -493,8 +509,10 @@ interface SiteData<ThemeConfig = NormalizedConfig> {
|
|
493
509
|
};
|
494
510
|
pages: BaseRuntimePageInfo[];
|
495
511
|
search: SearchOptions;
|
512
|
+
ssg: boolean;
|
496
513
|
markdown: {
|
497
514
|
showLineNumbers: boolean;
|
515
|
+
defaultWrapCode: boolean;
|
498
516
|
};
|
499
517
|
multiVersion: {
|
500
518
|
default: string;
|
@@ -540,6 +558,7 @@ interface Feature {
|
|
540
558
|
icon: string;
|
541
559
|
title: string;
|
542
560
|
details: string;
|
561
|
+
span?: number;
|
543
562
|
link?: string;
|
544
563
|
}
|
545
564
|
interface PageModule<T extends React.ComponentType<unknown>> {
|
@@ -619,6 +638,10 @@ interface MarkdownOptions {
|
|
619
638
|
*/
|
620
639
|
checkDeadLinks?: boolean;
|
621
640
|
showLineNumbers?: boolean;
|
641
|
+
/**
|
642
|
+
* Whether to wrap code by default, default is false
|
643
|
+
*/
|
644
|
+
defaultWrapCode?: boolean;
|
622
645
|
/**
|
623
646
|
* Register global components in mdx files
|
624
647
|
*/
|
@@ -653,6 +676,7 @@ declare function normalizePosixPath(id: string): string;
|
|
653
676
|
declare const inBrowser: () => boolean;
|
654
677
|
declare function addLeadingSlash(url: string): string;
|
655
678
|
declare function removeLeadingSlash(url: string): string;
|
679
|
+
declare function addTrailingSlash(url: string): string;
|
656
680
|
declare function removeTrailingSlash(url: string): string;
|
657
681
|
declare function normalizeSlash(url: string): string;
|
658
682
|
declare function isExternalUrl(url: string): boolean;
|
@@ -684,4 +708,4 @@ declare function removeBase(url: string, base: string): string;
|
|
684
708
|
declare function withoutHash(url: string): string;
|
685
709
|
declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
|
686
710
|
|
687
|
-
export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
|
711
|
+
export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarDivider, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
|
package/dist/index.js
CHANGED
@@ -27,6 +27,7 @@ __export(src_exports, {
|
|
27
27
|
RSPRESS_TEMP_DIR: () => RSPRESS_TEMP_DIR,
|
28
28
|
SEARCH_INDEX_NAME: () => SEARCH_INDEX_NAME,
|
29
29
|
addLeadingSlash: () => addLeadingSlash,
|
30
|
+
addTrailingSlash: () => addTrailingSlash,
|
30
31
|
cleanUrl: () => cleanUrl,
|
31
32
|
inBrowser: () => inBrowser,
|
32
33
|
isDebugMode: () => isDebugMode,
|
@@ -1152,6 +1153,9 @@ function addLeadingSlash(url) {
|
|
1152
1153
|
function removeLeadingSlash(url) {
|
1153
1154
|
return url.charAt(0) === "/" ? url.slice(1) : url;
|
1154
1155
|
}
|
1156
|
+
function addTrailingSlash(url) {
|
1157
|
+
return url.charAt(url.length - 1) === "/" ? url : `${url}/`;
|
1158
|
+
}
|
1155
1159
|
function removeTrailingSlash(url) {
|
1156
1160
|
return url.charAt(url.length - 1) === "/" ? url.slice(0, -1) : url;
|
1157
1161
|
}
|
@@ -1263,7 +1267,10 @@ function withBase(url = "/", base = "") {
|
|
1263
1267
|
return normalizedUrl.startsWith(normalizedBase) ? normalizedUrl : `${normalizedBase}${normalizedUrl}`;
|
1264
1268
|
}
|
1265
1269
|
function removeBase(url, base) {
|
1266
|
-
return addLeadingSlash(url).replace(
|
1270
|
+
return addLeadingSlash(url).replace(
|
1271
|
+
new RegExp(`^${normalizeSlash(base)}`),
|
1272
|
+
""
|
1273
|
+
);
|
1267
1274
|
}
|
1268
1275
|
function withoutHash(url) {
|
1269
1276
|
return url.split("#")[0];
|
@@ -1287,6 +1294,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1287
1294
|
RSPRESS_TEMP_DIR,
|
1288
1295
|
SEARCH_INDEX_NAME,
|
1289
1296
|
addLeadingSlash,
|
1297
|
+
addTrailingSlash,
|
1290
1298
|
cleanUrl,
|
1291
1299
|
inBrowser,
|
1292
1300
|
isDebugMode,
|
package/dist/index.mjs
CHANGED
@@ -1098,6 +1098,9 @@ function addLeadingSlash(url) {
|
|
1098
1098
|
function removeLeadingSlash(url) {
|
1099
1099
|
return url.charAt(0) === "/" ? url.slice(1) : url;
|
1100
1100
|
}
|
1101
|
+
function addTrailingSlash(url) {
|
1102
|
+
return url.charAt(url.length - 1) === "/" ? url : `${url}/`;
|
1103
|
+
}
|
1101
1104
|
function removeTrailingSlash(url) {
|
1102
1105
|
return url.charAt(url.length - 1) === "/" ? url.slice(0, -1) : url;
|
1103
1106
|
}
|
@@ -1209,7 +1212,10 @@ function withBase(url = "/", base = "") {
|
|
1209
1212
|
return normalizedUrl.startsWith(normalizedBase) ? normalizedUrl : `${normalizedBase}${normalizedUrl}`;
|
1210
1213
|
}
|
1211
1214
|
function removeBase(url, base) {
|
1212
|
-
return addLeadingSlash(url).replace(
|
1215
|
+
return addLeadingSlash(url).replace(
|
1216
|
+
new RegExp(`^${normalizeSlash(base)}`),
|
1217
|
+
""
|
1218
|
+
);
|
1213
1219
|
}
|
1214
1220
|
function withoutHash(url) {
|
1215
1221
|
return url.split("#")[0];
|
@@ -1232,6 +1238,7 @@ export {
|
|
1232
1238
|
RSPRESS_TEMP_DIR,
|
1233
1239
|
SEARCH_INDEX_NAME,
|
1234
1240
|
addLeadingSlash,
|
1241
|
+
addTrailingSlash,
|
1235
1242
|
cleanUrl,
|
1236
1243
|
inBrowser,
|
1237
1244
|
isDebugMode,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "0.0.0-next-
|
3
|
+
"version": "0.0.0-next-20231108104528",
|
4
4
|
"types": "./dist/index.d.ts",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.mjs",
|
@@ -22,8 +22,7 @@
|
|
22
22
|
}
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@
|
26
|
-
"@modern-js/builder-rspack-provider": "2.37.1",
|
25
|
+
"@rsbuild/core": "0.0.14",
|
27
26
|
"unified": "10.1.2",
|
28
27
|
"chalk": "4.1.2",
|
29
28
|
"rslog": "^1.1.0"
|