@rspress/shared 1.5.0 → 1.6.0
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 +20 -10
- package/dist/index.js +10 -0
- package/dist/index.mjs +8 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -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.
|
@@ -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;
|
@@ -664,10 +672,12 @@ declare const isProduction: () => boolean;
|
|
664
672
|
declare const isDebugMode: () => boolean;
|
665
673
|
declare const cleanUrl: (url: string) => string;
|
666
674
|
declare function slash(str: string): string;
|
675
|
+
declare function removeHash(str: string): string;
|
667
676
|
declare function normalizePosixPath(id: string): string;
|
668
677
|
declare const inBrowser: () => boolean;
|
669
678
|
declare function addLeadingSlash(url: string): string;
|
670
679
|
declare function removeLeadingSlash(url: string): string;
|
680
|
+
declare function addTrailingSlash(url: string): string;
|
671
681
|
declare function removeTrailingSlash(url: string): string;
|
672
682
|
declare function normalizeSlash(url: string): string;
|
673
683
|
declare function isExternalUrl(url: string): boolean;
|
@@ -699,4 +709,4 @@ declare function removeBase(url: string, base: string): string;
|
|
699
709
|
declare function withoutHash(url: string): string;
|
700
710
|
declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
|
701
711
|
|
702
|
-
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 };
|
712
|
+
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, removeHash, 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,
|
@@ -40,6 +41,7 @@ __export(src_exports, {
|
|
40
41
|
omit: () => omit,
|
41
42
|
parseUrl: () => parseUrl,
|
42
43
|
removeBase: () => removeBase,
|
44
|
+
removeHash: () => removeHash,
|
43
45
|
removeLeadingSlash: () => removeLeadingSlash,
|
44
46
|
removeTrailingSlash: () => removeTrailingSlash,
|
45
47
|
replaceLang: () => replaceLang,
|
@@ -1121,6 +1123,9 @@ var cleanUrl = (url) => url.replace(HASH_REGEXP, "").replace(QUERY_REGEXP, "");
|
|
1121
1123
|
function slash(str) {
|
1122
1124
|
return str.replace(/\\/g, "/");
|
1123
1125
|
}
|
1126
|
+
function removeHash(str) {
|
1127
|
+
return str.replace(/#.*$/, "");
|
1128
|
+
}
|
1124
1129
|
function normalizePosixPath(id) {
|
1125
1130
|
const path = slash(id);
|
1126
1131
|
const isAbsolutePath = path.startsWith("/");
|
@@ -1152,6 +1157,9 @@ function addLeadingSlash(url) {
|
|
1152
1157
|
function removeLeadingSlash(url) {
|
1153
1158
|
return url.charAt(0) === "/" ? url.slice(1) : url;
|
1154
1159
|
}
|
1160
|
+
function addTrailingSlash(url) {
|
1161
|
+
return url.charAt(url.length - 1) === "/" ? url : `${url}/`;
|
1162
|
+
}
|
1155
1163
|
function removeTrailingSlash(url) {
|
1156
1164
|
return url.charAt(url.length - 1) === "/" ? url.slice(0, -1) : url;
|
1157
1165
|
}
|
@@ -1290,6 +1298,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1290
1298
|
RSPRESS_TEMP_DIR,
|
1291
1299
|
SEARCH_INDEX_NAME,
|
1292
1300
|
addLeadingSlash,
|
1301
|
+
addTrailingSlash,
|
1293
1302
|
cleanUrl,
|
1294
1303
|
inBrowser,
|
1295
1304
|
isDebugMode,
|
@@ -1303,6 +1312,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1303
1312
|
omit,
|
1304
1313
|
parseUrl,
|
1305
1314
|
removeBase,
|
1315
|
+
removeHash,
|
1306
1316
|
removeLeadingSlash,
|
1307
1317
|
removeTrailingSlash,
|
1308
1318
|
replaceLang,
|
package/dist/index.mjs
CHANGED
@@ -1067,6 +1067,9 @@ var cleanUrl = (url) => url.replace(HASH_REGEXP, "").replace(QUERY_REGEXP, "");
|
|
1067
1067
|
function slash(str) {
|
1068
1068
|
return str.replace(/\\/g, "/");
|
1069
1069
|
}
|
1070
|
+
function removeHash(str) {
|
1071
|
+
return str.replace(/#.*$/, "");
|
1072
|
+
}
|
1070
1073
|
function normalizePosixPath(id) {
|
1071
1074
|
const path = slash(id);
|
1072
1075
|
const isAbsolutePath = path.startsWith("/");
|
@@ -1098,6 +1101,9 @@ function addLeadingSlash(url) {
|
|
1098
1101
|
function removeLeadingSlash(url) {
|
1099
1102
|
return url.charAt(0) === "/" ? url.slice(1) : url;
|
1100
1103
|
}
|
1104
|
+
function addTrailingSlash(url) {
|
1105
|
+
return url.charAt(url.length - 1) === "/" ? url : `${url}/`;
|
1106
|
+
}
|
1101
1107
|
function removeTrailingSlash(url) {
|
1102
1108
|
return url.charAt(url.length - 1) === "/" ? url.slice(0, -1) : url;
|
1103
1109
|
}
|
@@ -1235,6 +1241,7 @@ export {
|
|
1235
1241
|
RSPRESS_TEMP_DIR,
|
1236
1242
|
SEARCH_INDEX_NAME,
|
1237
1243
|
addLeadingSlash,
|
1244
|
+
addTrailingSlash,
|
1238
1245
|
cleanUrl,
|
1239
1246
|
inBrowser,
|
1240
1247
|
isDebugMode,
|
@@ -1248,6 +1255,7 @@ export {
|
|
1248
1255
|
omit,
|
1249
1256
|
parseUrl,
|
1250
1257
|
removeBase,
|
1258
|
+
removeHash,
|
1251
1259
|
removeLeadingSlash,
|
1252
1260
|
removeTrailingSlash,
|
1253
1261
|
replaceLang,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.6.0",
|
4
4
|
"types": "./dist/index.d.ts",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.mjs",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
}
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@rsbuild/core": "0.0.
|
25
|
+
"@rsbuild/core": "0.0.14",
|
26
26
|
"unified": "10.1.2",
|
27
27
|
"chalk": "4.1.2",
|
28
28
|
"rslog": "^1.1.0"
|