@rspress/shared 2.0.14 → 2.0.16
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 +52 -5
- package/dist/index.js +12 -1
- package/dist/node-utils.d.ts +37 -4
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare const cleanUrl: (url: string) => string;
|
|
|
27
27
|
|
|
28
28
|
export declare type Config = UserConfig | Promise<UserConfig> | ((...args: Parameters<typeof loadConfig>) => UserConfig | Promise<UserConfig>);
|
|
29
29
|
|
|
30
|
+
export declare type DarkMode = boolean | NormalizedDarkMode;
|
|
31
|
+
|
|
30
32
|
export declare interface EditLink {
|
|
31
33
|
/**
|
|
32
34
|
* Custom repository url for edit link.
|
|
@@ -85,9 +87,12 @@ export declare interface FrontMatterMeta {
|
|
|
85
87
|
titleSuffix?: string;
|
|
86
88
|
head?: [string, Record<string, string>][];
|
|
87
89
|
context?: string;
|
|
90
|
+
search?: boolean;
|
|
88
91
|
[key: string]: unknown;
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
export declare const getDefaultDarkModeValue: (darkMode: DarkMode | undefined) => ThemeConfigValue;
|
|
95
|
+
|
|
91
96
|
/**
|
|
92
97
|
* get the sidebar group for the current page
|
|
93
98
|
* @param sidebar const { sidebar } = useLocaleSiteData();
|
|
@@ -144,6 +149,7 @@ export declare interface I18nText {
|
|
|
144
149
|
outlineTitle?: I18nTextValue;
|
|
145
150
|
scrollToTopText?: I18nTextValue;
|
|
146
151
|
lastUpdatedText?: I18nTextValue;
|
|
152
|
+
lastUpdatedAuthorText?: I18nTextValue;
|
|
147
153
|
prevPageText?: I18nTextValue;
|
|
148
154
|
nextPageText?: I18nTextValue;
|
|
149
155
|
editLinkText?: I18nTextValue;
|
|
@@ -173,6 +179,8 @@ declare type I18nTextValue = {
|
|
|
173
179
|
|
|
174
180
|
export declare const inBrowser: () => boolean;
|
|
175
181
|
|
|
182
|
+
export declare const isDarkModeSwitchEnabled: (darkMode: DarkMode | undefined) => boolean;
|
|
183
|
+
|
|
176
184
|
export declare function isDataUrl(url?: string): boolean;
|
|
177
185
|
|
|
178
186
|
export declare const isDebugMode: () => boolean;
|
|
@@ -183,6 +191,23 @@ export declare function isExternalUrl(url?: string): boolean;
|
|
|
183
191
|
|
|
184
192
|
export declare const isProduction: () => boolean;
|
|
185
193
|
|
|
194
|
+
export declare type LastUpdated = boolean | {
|
|
195
|
+
/**
|
|
196
|
+
* Whether to display the last author of the file (from git log).
|
|
197
|
+
* - `false`: hide the author.
|
|
198
|
+
* - `true`: show the commit author's name.
|
|
199
|
+
* - function: receives `{ name, email, filePath }` and returns the display string.
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
author?: LastUpdatedAuthor;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export declare type LastUpdatedAuthor = boolean | ((info: {
|
|
206
|
+
name: string;
|
|
207
|
+
email: string;
|
|
208
|
+
filePath: string;
|
|
209
|
+
}) => string);
|
|
210
|
+
|
|
186
211
|
/**
|
|
187
212
|
* Configuration for LLMS UI components displayed on H1 headers.
|
|
188
213
|
* When enabled, LlmsCopyButton and LlmsViewOptions will be automatically
|
|
@@ -266,7 +291,7 @@ export declare interface MarkdownOptions {
|
|
|
266
291
|
*/
|
|
267
292
|
rehypePlugins?: PluggableList;
|
|
268
293
|
/**
|
|
269
|
-
* @default { checkDeadLinks: true, autoPrefix: true }
|
|
294
|
+
* @default { checkDeadLinks: true, checkAnchors: false, autoPrefix: true }
|
|
270
295
|
*/
|
|
271
296
|
link?: RemarkLinkOptions;
|
|
272
297
|
/**
|
|
@@ -374,6 +399,14 @@ export declare interface NavItemWithLinkAndChildren {
|
|
|
374
399
|
rel?: string;
|
|
375
400
|
}
|
|
376
401
|
|
|
402
|
+
export declare const normalizeDarkMode: (darkMode: DarkMode | undefined) => NormalizedDarkMode;
|
|
403
|
+
|
|
404
|
+
export declare type NormalizedDarkMode = 'light' | 'dark' | 'auto' | 'force-light' | 'force-dark' | 'force-auto';
|
|
405
|
+
|
|
406
|
+
export declare type NormalizedLastUpdated = boolean | {
|
|
407
|
+
author?: boolean;
|
|
408
|
+
};
|
|
409
|
+
|
|
377
410
|
export declare interface NormalizedLocales extends Omit<LocaleConfig, 'sidebar'> {
|
|
378
411
|
sidebar: NormalizedSidebar;
|
|
379
412
|
}
|
|
@@ -388,7 +421,8 @@ export declare interface NormalizedSidebarGroup extends Omit<SidebarGroup, 'item
|
|
|
388
421
|
collapsed: boolean;
|
|
389
422
|
}
|
|
390
423
|
|
|
391
|
-
declare interface NormalizedThemeConfig extends Omit<ThemeConfig, 'locales' | 'sidebar'> {
|
|
424
|
+
declare interface NormalizedThemeConfig extends Omit<ThemeConfig, 'lastUpdated' | 'locales' | 'sidebar'> {
|
|
425
|
+
lastUpdated?: NormalizedLastUpdated;
|
|
392
426
|
locales: NormalizedLocales[];
|
|
393
427
|
sidebar: NormalizedSidebar;
|
|
394
428
|
}
|
|
@@ -411,6 +445,7 @@ export declare interface PageDataLegacy {
|
|
|
411
445
|
headingTitle?: string;
|
|
412
446
|
pagePath: string;
|
|
413
447
|
lastUpdatedTime?: string;
|
|
448
|
+
lastUpdatedAuthor?: string;
|
|
414
449
|
description?: string;
|
|
415
450
|
pageType: PageType;
|
|
416
451
|
[key: string]: unknown;
|
|
@@ -471,6 +506,13 @@ export declare type RemarkLinkOptions = {
|
|
|
471
506
|
checkDeadLinks?: boolean | {
|
|
472
507
|
excludes: string[] | ((url: string) => boolean);
|
|
473
508
|
};
|
|
509
|
+
/**
|
|
510
|
+
* Whether to enable dead anchor checks
|
|
511
|
+
* @default false
|
|
512
|
+
*/
|
|
513
|
+
checkAnchors?: boolean | {
|
|
514
|
+
excludes: string[] | ((url: string) => boolean);
|
|
515
|
+
};
|
|
474
516
|
/**
|
|
475
517
|
* [](/v3/zh/guide) [](/zh/guide) [](/guide) will be regarded as the same [](/v3/zh/guide) according to the directory.
|
|
476
518
|
* @default true
|
|
@@ -769,10 +811,12 @@ declare type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'inst
|
|
|
769
811
|
|
|
770
812
|
declare type ThemeConfig = {
|
|
771
813
|
/**
|
|
772
|
-
* Whether to enable dark mode.
|
|
814
|
+
* Whether to enable dark mode and how to resolve the default theme.
|
|
815
|
+
* - `true`: same as `'auto'`.
|
|
816
|
+
* - `false`: same as `'force-light'`.
|
|
773
817
|
* @default true
|
|
774
818
|
*/
|
|
775
|
-
darkMode?:
|
|
819
|
+
darkMode?: DarkMode;
|
|
776
820
|
/**
|
|
777
821
|
* The nav items. When it's an object, the key is the version of current doc.
|
|
778
822
|
* @default []
|
|
@@ -791,9 +835,10 @@ declare type ThemeConfig = {
|
|
|
791
835
|
editLink?: EditLink;
|
|
792
836
|
/**
|
|
793
837
|
* Whether to display the last update time of the file.
|
|
838
|
+
* Set `author` to show the last commit author.
|
|
794
839
|
* @default false
|
|
795
840
|
*/
|
|
796
|
-
lastUpdated?:
|
|
841
|
+
lastUpdated?: LastUpdated;
|
|
797
842
|
/**
|
|
798
843
|
* The social links to be displayed at the end of the nav bar. Perfect for
|
|
799
844
|
* placing links to social services such as GitHub, X, Facebook, etc.
|
|
@@ -854,6 +899,8 @@ declare type ThemeConfig = {
|
|
|
854
899
|
export { ThemeConfig as DefaultThemeConfig }
|
|
855
900
|
export { ThemeConfig }
|
|
856
901
|
|
|
902
|
+
declare type ThemeConfigValue = 'light' | 'dark' | 'auto';
|
|
903
|
+
|
|
857
904
|
export declare interface UserConfig {
|
|
858
905
|
/**
|
|
859
906
|
* The root directory of the site.
|
package/dist/index.js
CHANGED
|
@@ -162,4 +162,15 @@ const getSidebarDataGroup = (sidebar, currentPathname)=>{
|
|
|
162
162
|
return [];
|
|
163
163
|
};
|
|
164
164
|
const matchNavbar = (item, currentPathname)=>new RegExp(item.activeMatch || normalizeHref(item.link, true)).test(currentPathname);
|
|
165
|
-
|
|
165
|
+
const normalizeDarkMode = (darkMode)=>{
|
|
166
|
+
if (false === darkMode) return 'force-light';
|
|
167
|
+
if (true === darkMode || void 0 === darkMode) return 'auto';
|
|
168
|
+
return darkMode;
|
|
169
|
+
};
|
|
170
|
+
const getDefaultDarkModeValue = (darkMode)=>{
|
|
171
|
+
const normalizedDarkMode = normalizeDarkMode(darkMode);
|
|
172
|
+
if (normalizedDarkMode.startsWith('force-')) return normalizedDarkMode.slice(6);
|
|
173
|
+
return normalizedDarkMode;
|
|
174
|
+
};
|
|
175
|
+
const isDarkModeSwitchEnabled = (darkMode)=>!normalizeDarkMode(darkMode).startsWith('force-');
|
|
176
|
+
export { HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getDefaultDarkModeValue, getSidebarDataGroup, inBrowser, isDarkModeSwitchEnabled, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeDarkMode, normalizeHref, normalizePosixPath, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, utils_cleanUrl as cleanUrl, withBase, withoutLang };
|
package/dist/node-utils.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ declare interface AdditionalPage {
|
|
|
19
19
|
filepath?: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
declare type DarkMode = boolean | NormalizedDarkMode;
|
|
23
|
+
|
|
22
24
|
declare interface EditLink {
|
|
23
25
|
/**
|
|
24
26
|
* Custom repository url for edit link.
|
|
@@ -82,6 +84,7 @@ declare interface FrontMatterMeta {
|
|
|
82
84
|
titleSuffix?: string;
|
|
83
85
|
head?: [string, Record<string, string>][];
|
|
84
86
|
context?: string;
|
|
87
|
+
search?: boolean;
|
|
85
88
|
[key: string]: unknown;
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -147,6 +150,7 @@ declare interface I18nText {
|
|
|
147
150
|
outlineTitle?: I18nTextValue;
|
|
148
151
|
scrollToTopText?: I18nTextValue;
|
|
149
152
|
lastUpdatedText?: I18nTextValue;
|
|
153
|
+
lastUpdatedAuthorText?: I18nTextValue;
|
|
150
154
|
prevPageText?: I18nTextValue;
|
|
151
155
|
nextPageText?: I18nTextValue;
|
|
152
156
|
editLinkText?: I18nTextValue;
|
|
@@ -174,6 +178,23 @@ declare type I18nTextValue = {
|
|
|
174
178
|
[key: string]: string;
|
|
175
179
|
};
|
|
176
180
|
|
|
181
|
+
declare type LastUpdated = boolean | {
|
|
182
|
+
/**
|
|
183
|
+
* Whether to display the last author of the file (from git log).
|
|
184
|
+
* - `false`: hide the author.
|
|
185
|
+
* - `true`: show the commit author's name.
|
|
186
|
+
* - function: receives `{ name, email, filePath }` and returns the display string.
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
author?: LastUpdatedAuthor;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
declare type LastUpdatedAuthor = boolean | ((info: {
|
|
193
|
+
name: string;
|
|
194
|
+
email: string;
|
|
195
|
+
filePath: string;
|
|
196
|
+
}) => string);
|
|
197
|
+
|
|
177
198
|
/**
|
|
178
199
|
* Configuration for LLMS UI components displayed on H1 headers.
|
|
179
200
|
* When enabled, LlmsCopyButton and LlmsViewOptions will be automatically
|
|
@@ -263,7 +284,7 @@ declare interface MarkdownOptions {
|
|
|
263
284
|
*/
|
|
264
285
|
rehypePlugins?: PluggableList;
|
|
265
286
|
/**
|
|
266
|
-
* @default { checkDeadLinks: true, autoPrefix: true }
|
|
287
|
+
* @default { checkDeadLinks: true, checkAnchors: false, autoPrefix: true }
|
|
267
288
|
*/
|
|
268
289
|
link?: RemarkLinkOptions;
|
|
269
290
|
/**
|
|
@@ -362,6 +383,8 @@ declare interface NavItemWithLinkAndChildren {
|
|
|
362
383
|
rel?: string;
|
|
363
384
|
}
|
|
364
385
|
|
|
386
|
+
declare type NormalizedDarkMode = 'light' | 'dark' | 'auto' | 'force-light' | 'force-dark' | 'force-auto';
|
|
387
|
+
|
|
365
388
|
/**
|
|
366
389
|
* @description search-index.json file
|
|
367
390
|
* "_foo" is the private field that won't be written to search-index.json file
|
|
@@ -401,6 +424,13 @@ declare type RemarkLinkOptions = {
|
|
|
401
424
|
checkDeadLinks?: boolean | {
|
|
402
425
|
excludes: string[] | ((url: string) => boolean);
|
|
403
426
|
};
|
|
427
|
+
/**
|
|
428
|
+
* Whether to enable dead anchor checks
|
|
429
|
+
* @default false
|
|
430
|
+
*/
|
|
431
|
+
checkAnchors?: boolean | {
|
|
432
|
+
excludes: string[] | ((url: string) => boolean);
|
|
433
|
+
};
|
|
404
434
|
/**
|
|
405
435
|
* [](/v3/zh/guide) [](/zh/guide) [](/guide) will be regarded as the same [](/v3/zh/guide) according to the directory.
|
|
406
436
|
* @default true
|
|
@@ -615,10 +645,12 @@ declare type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'inst
|
|
|
615
645
|
|
|
616
646
|
declare type ThemeConfig = {
|
|
617
647
|
/**
|
|
618
|
-
* Whether to enable dark mode.
|
|
648
|
+
* Whether to enable dark mode and how to resolve the default theme.
|
|
649
|
+
* - `true`: same as `'auto'`.
|
|
650
|
+
* - `false`: same as `'force-light'`.
|
|
619
651
|
* @default true
|
|
620
652
|
*/
|
|
621
|
-
darkMode?:
|
|
653
|
+
darkMode?: DarkMode;
|
|
622
654
|
/**
|
|
623
655
|
* The nav items. When it's an object, the key is the version of current doc.
|
|
624
656
|
* @default []
|
|
@@ -637,9 +669,10 @@ declare type ThemeConfig = {
|
|
|
637
669
|
editLink?: EditLink;
|
|
638
670
|
/**
|
|
639
671
|
* Whether to display the last update time of the file.
|
|
672
|
+
* Set `author` to show the last commit author.
|
|
640
673
|
* @default false
|
|
641
674
|
*/
|
|
642
|
-
lastUpdated?:
|
|
675
|
+
lastUpdated?: LastUpdated;
|
|
643
676
|
/**
|
|
644
677
|
* The social links to be displayed at the end of the nav bar. Perfect for
|
|
645
678
|
* placing links to social services such as GitHub, X, Facebook, etc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/shared",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
"dist"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@rsbuild/core": "^2.0.
|
|
48
|
-
"@shikijs/rehype": "^4.0
|
|
47
|
+
"@rsbuild/core": "^2.0.15",
|
|
48
|
+
"@shikijs/rehype": "^4.2.0",
|
|
49
49
|
"unified": "^11.0.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@rslib/core": "0.
|
|
52
|
+
"@rslib/core": "0.23.0",
|
|
53
53
|
"@types/lodash-es": "^4.17.12",
|
|
54
54
|
"@types/node": "^22.8.1",
|
|
55
|
-
"@types/react": "^19.2.
|
|
55
|
+
"@types/react": "^19.2.17",
|
|
56
56
|
"github-slugger": "^2.0.0",
|
|
57
57
|
"gray-matter": "4.0.3",
|
|
58
58
|
"lodash-es": "^4.18.1",
|
|
59
59
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
60
60
|
"medium-zoom": "1.1.0",
|
|
61
61
|
"rimraf": "^6.1.3",
|
|
62
|
-
"rsbuild-plugin-publint": "^0.
|
|
62
|
+
"rsbuild-plugin-publint": "^1.0.0",
|
|
63
63
|
"typescript": "^6.0.3"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|