@rspress/shared 2.0.23 → 2.1.0-beta.2

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 CHANGED
@@ -4,6 +4,7 @@ import type { PluggableList } from 'unified';
4
4
  import type { ReactElement } from 'react';
5
5
  import type { RehypeShikiOptions } from '@shikijs/rehype';
6
6
  import type { RsbuildConfig } from '@rsbuild/core';
7
+ import type { TransformContext } from '@rsbuild/core';
7
8
 
8
9
  /**
9
10
  * There are two ways to define what addition routes represent.
@@ -22,10 +23,16 @@ export declare function addTrailingSlash(url: string): string;
22
23
 
23
24
  export declare type BaseRuntimePageInfo = Omit<RemoveUnderscoreProps<PageIndexInfo>, 'id' | 'content' | 'domain'>;
24
25
 
26
+ declare type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
27
+
25
28
  export declare const cleanUrl: (url: string) => string;
26
29
 
27
30
  export declare type Config = UserConfig | Promise<UserConfig> | ((...args: Parameters<typeof loadConfig>) => UserConfig | Promise<UserConfig>);
28
31
 
32
+ declare interface CustomMaps {
33
+ [routePath: string]: Sitemap;
34
+ }
35
+
29
36
  export declare type DarkMode = boolean | NormalizedDarkMode;
30
37
 
31
38
  export declare interface EditLink {
@@ -165,6 +172,10 @@ export declare interface I18nText {
165
172
  codeButtonGroupWrapButtonText?: I18nTextValue;
166
173
  notFoundText?: I18nTextValue;
167
174
  takeMeHomeText?: I18nTextValue;
175
+ errorTitleText?: I18nTextValue;
176
+ errorDescriptionText?: I18nTextValue;
177
+ reloadPageText?: I18nTextValue;
178
+ errorDetailsText?: I18nTextValue;
168
179
  promptCopyText?: I18nTextValue;
169
180
  promptCopiedText?: I18nTextValue;
170
181
  promptExpandText?: I18nTextValue;
@@ -369,7 +380,7 @@ export declare interface MarkdownOptions {
369
380
  */
370
381
  rehypePlugins?: PluggableList;
371
382
  /**
372
- * @default { checkDeadLinks: true, checkAnchors: false, autoPrefix: true }
383
+ * @default { checkDeadLinks: true, checkAnchors: true, autoPrefix: true }
373
384
  */
374
385
  link?: RemarkLinkOptions;
375
386
  /**
@@ -567,6 +578,8 @@ export declare const parseUrl: (url: string) => {
567
578
  search: string;
568
579
  };
569
580
 
581
+ declare type Priority = '0.0' | '0.1' | '0.2' | '0.3' | '0.4' | '0.5' | '0.6' | '0.7' | '0.8' | '0.9' | '1.0';
582
+
570
583
  export declare const QUERY_REGEXP: RegExp;
571
584
 
572
585
  export declare type RemarkImageOptions = {
@@ -589,7 +602,7 @@ export declare type RemarkLinkOptions = {
589
602
  };
590
603
  /**
591
604
  * Whether to enable dead anchor checks
592
- * @default false
605
+ * @default true
593
606
  */
594
607
  checkAnchors?: boolean | {
595
608
  excludes: string[] | ((url: string) => boolean);
@@ -712,7 +725,7 @@ export declare interface RouteOptions {
712
725
  excludeConvention?: string[];
713
726
  /**
714
727
  * use links without .html files
715
- * @default false
728
+ * @default true
716
729
  */
717
730
  cleanUrls?: boolean;
718
731
  /**
@@ -779,6 +792,10 @@ declare interface RspressPlugin {
779
792
  config?: (config: UserConfig, utils: {
780
793
  addPlugin: (plugin: RspressPlugin) => void;
781
794
  removePlugin: (pluginName: string) => void;
795
+ /**
796
+ * Read the shared i18n data for the current build.
797
+ */
798
+ getI18nData: (context?: Pick<TransformContext, 'addDependency' | 'addMissingDependency'>) => Promise<Record<string, Record<string, string>>>;
782
799
  }, isProd: boolean) => UserConfig | Promise<UserConfig>;
783
800
  /**
784
801
  * Callback before build
@@ -894,6 +911,8 @@ export declare interface SiteData {
894
911
  logo: string | {
895
912
  dark: string;
896
913
  light: string;
914
+ width?: number;
915
+ height?: number;
897
916
  };
898
917
  logoText: string;
899
918
  logoHref: string;
@@ -909,6 +928,20 @@ export declare interface SiteData {
909
928
  };
910
929
  }
911
930
 
931
+ declare interface Sitemap {
932
+ loc: string;
933
+ lastmod?: string;
934
+ changefreq?: ChangeFreq;
935
+ priority?: Priority;
936
+ }
937
+
938
+ export declare interface SitemapOptions {
939
+ siteUrl?: string;
940
+ customMaps?: CustomMaps;
941
+ defaultPriority?: Priority;
942
+ defaultChangeFreq?: ChangeFreq;
943
+ }
944
+
912
945
  export declare function slash(str: string): string;
913
946
 
914
947
  export declare interface SocialLink {
@@ -1028,12 +1061,15 @@ export declare interface UserConfig {
1028
1061
  */
1029
1062
  root?: string;
1030
1063
  /**
1031
- * Path to the logo file in nav bar.
1064
+ * Path to the logo file in nav bar. The object form can also provide the
1065
+ * image's intrinsic dimensions to avoid layout shifts.
1032
1066
  * @default ''
1033
1067
  */
1034
1068
  logo?: string | {
1035
1069
  dark: string;
1036
1070
  light: string;
1071
+ width?: number;
1072
+ height?: number;
1037
1073
  };
1038
1074
  /**
1039
1075
  * The text of the logo in nav bar.
@@ -1054,6 +1090,11 @@ export declare interface UserConfig {
1054
1090
  * Origin of the site, such as `https://example.com`.
1055
1091
  */
1056
1092
  siteOrigin?: string;
1093
+ /**
1094
+ * Generate sitemap.xml during production builds.
1095
+ * @default true
1096
+ */
1097
+ sitemap?: boolean | SitemapOptions;
1057
1098
  /**
1058
1099
  * Path to html icon file.
1059
1100
  * @default ''
@@ -1141,7 +1182,10 @@ export declare interface UserConfig {
1141
1182
  */
1142
1183
  search?: SearchOptions;
1143
1184
  /**
1144
- * Whether to enable ssg
1185
+ * Whether to prerender page content into HTML at build time (SSG).
1186
+ * Set to `false` to generate HTML shells for client-side rendering instead.
1187
+ * This does not disable SSG-MD or llms.txt generation, which are controlled
1188
+ * independently by `llms`.
1145
1189
  * @default true
1146
1190
  */
1147
1191
  ssg?: boolean | {
@@ -1152,14 +1196,18 @@ export declare interface UserConfig {
1152
1196
  experimentalWorker?: boolean;
1153
1197
  /**
1154
1198
  * After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
1199
+ * Only affects SSG, not SSG-MD. If excluded pages are not SSR-compatible,
1200
+ * fix their SSR compatibility or set `llms: false` to disable SSG-MD.
1155
1201
  * @default []
1156
1202
  */
1157
1203
  experimentalExcludeRoutePaths?: (string | RegExp)[];
1158
1204
  };
1159
1205
  /**
1160
- * Whether to enable llms and ssg-md
1161
- * @default false
1162
- * @experimental
1206
+ * Whether to render pages to Markdown (SSG-MD) and generate llms.txt and
1207
+ * llms-full.txt at build time.
1208
+ * Independent of `ssg`: these files are still generated when `ssg: false`.
1209
+ * Set to `false` to disable these outputs without affecting SSG.
1210
+ * @default true
1163
1211
  */
1164
1212
  llms?: boolean | {
1165
1213
  /**
@@ -1172,6 +1220,15 @@ export declare interface UserConfig {
1172
1220
  */
1173
1221
  remarkSplitMdxOptions?: RemarkSplitMdxOptions;
1174
1222
  };
1223
+ /**
1224
+ * Expose built-in documentation tools through the browser WebMCP API.
1225
+ * Markdown tools require `llms: true` in production.
1226
+ * @default true
1227
+ * @experimental
1228
+ */
1229
+ webMcp?: boolean | {
1230
+ exposedTo?: string[];
1231
+ };
1175
1232
  /**
1176
1233
  * Whether to enable medium-zoom
1177
1234
  * @default true
@@ -6,6 +6,7 @@ import type { MdxJsxTextElement } from 'mdast-util-mdx-jsx';
6
6
  import type { PluggableList } from 'unified';
7
7
  import type { RehypeShikiOptions } from '@shikijs/rehype';
8
8
  import type { RsbuildConfig } from '@rsbuild/core';
9
+ import type { TransformContext } from '@rsbuild/core';
9
10
 
10
11
  /**
11
12
  * There are two ways to define what addition routes represent.
@@ -18,6 +19,12 @@ declare interface AdditionalPage {
18
19
  filepath?: string;
19
20
  }
20
21
 
22
+ declare type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
23
+
24
+ declare interface CustomMaps {
25
+ [routePath: string]: Sitemap;
26
+ }
27
+
21
28
  declare type DarkMode = boolean | NormalizedDarkMode;
22
29
 
23
30
  declare interface EditLink {
@@ -166,6 +173,10 @@ declare interface I18nText {
166
173
  codeButtonGroupWrapButtonText?: I18nTextValue;
167
174
  notFoundText?: I18nTextValue;
168
175
  takeMeHomeText?: I18nTextValue;
176
+ errorTitleText?: I18nTextValue;
177
+ errorDescriptionText?: I18nTextValue;
178
+ reloadPageText?: I18nTextValue;
179
+ errorDetailsText?: I18nTextValue;
169
180
  promptCopyText?: I18nTextValue;
170
181
  promptCopiedText?: I18nTextValue;
171
182
  promptExpandText?: I18nTextValue;
@@ -362,7 +373,7 @@ declare interface MarkdownOptions {
362
373
  */
363
374
  rehypePlugins?: PluggableList;
364
375
  /**
365
- * @default { checkDeadLinks: true, checkAnchors: false, autoPrefix: true }
376
+ * @default { checkDeadLinks: true, checkAnchors: true, autoPrefix: true }
366
377
  */
367
378
  link?: RemarkLinkOptions;
368
379
  /**
@@ -487,6 +498,8 @@ declare interface PageIndexInfo {
487
498
 
488
499
  declare type PageType = 'home' | 'doc' | 'doc-wide' | 'custom' | '404' | 'blank';
489
500
 
501
+ declare type Priority = '0.0' | '0.1' | '0.2' | '0.3' | '0.4' | '0.5' | '0.6' | '0.7' | '0.8' | '0.9' | '1.0';
502
+
490
503
  declare type RemarkImageOptions = {
491
504
  /**
492
505
  * Whether to enable check dead images
@@ -507,7 +520,7 @@ declare type RemarkLinkOptions = {
507
520
  };
508
521
  /**
509
522
  * Whether to enable dead anchor checks
510
- * @default false
523
+ * @default true
511
524
  */
512
525
  checkAnchors?: boolean | {
513
526
  excludes: string[] | ((url: string) => boolean);
@@ -586,7 +599,7 @@ declare interface RouteOptions {
586
599
  excludeConvention?: string[];
587
600
  /**
588
601
  * use links without .html files
589
- * @default false
602
+ * @default true
590
603
  */
591
604
  cleanUrls?: boolean;
592
605
  /**
@@ -651,6 +664,10 @@ declare interface RspressPlugin {
651
664
  config?: (config: UserConfig, utils: {
652
665
  addPlugin: (plugin: RspressPlugin) => void;
653
666
  removePlugin: (pluginName: string) => void;
667
+ /**
668
+ * Read the shared i18n data for the current build.
669
+ */
670
+ getI18nData: (context?: Pick<TransformContext, 'addDependency' | 'addMissingDependency'>) => Promise<Record<string, Record<string, string>>>;
654
671
  }, isProd: boolean) => UserConfig | Promise<UserConfig>;
655
672
  /**
656
673
  * Callback before build
@@ -744,6 +761,20 @@ declare type SidebarSectionHeader = {
744
761
  tag?: string;
745
762
  };
746
763
 
764
+ declare interface Sitemap {
765
+ loc: string;
766
+ lastmod?: string;
767
+ changefreq?: ChangeFreq;
768
+ priority?: Priority;
769
+ }
770
+
771
+ declare interface SitemapOptions {
772
+ siteUrl?: string;
773
+ customMaps?: CustomMaps;
774
+ defaultPriority?: Priority;
775
+ defaultChangeFreq?: ChangeFreq;
776
+ }
777
+
747
778
  declare interface SocialLink {
748
779
  icon: SocialLinkIcon;
749
780
  mode: 'link' | 'text' | 'img' | 'dom' | 'github-stars';
@@ -857,12 +888,15 @@ declare interface UserConfig {
857
888
  */
858
889
  root?: string;
859
890
  /**
860
- * Path to the logo file in nav bar.
891
+ * Path to the logo file in nav bar. The object form can also provide the
892
+ * image's intrinsic dimensions to avoid layout shifts.
861
893
  * @default ''
862
894
  */
863
895
  logo?: string | {
864
896
  dark: string;
865
897
  light: string;
898
+ width?: number;
899
+ height?: number;
866
900
  };
867
901
  /**
868
902
  * The text of the logo in nav bar.
@@ -883,6 +917,11 @@ declare interface UserConfig {
883
917
  * Origin of the site, such as `https://example.com`.
884
918
  */
885
919
  siteOrigin?: string;
920
+ /**
921
+ * Generate sitemap.xml during production builds.
922
+ * @default true
923
+ */
924
+ sitemap?: boolean | SitemapOptions;
886
925
  /**
887
926
  * Path to html icon file.
888
927
  * @default ''
@@ -970,7 +1009,10 @@ declare interface UserConfig {
970
1009
  */
971
1010
  search?: SearchOptions;
972
1011
  /**
973
- * Whether to enable ssg
1012
+ * Whether to prerender page content into HTML at build time (SSG).
1013
+ * Set to `false` to generate HTML shells for client-side rendering instead.
1014
+ * This does not disable SSG-MD or llms.txt generation, which are controlled
1015
+ * independently by `llms`.
974
1016
  * @default true
975
1017
  */
976
1018
  ssg?: boolean | {
@@ -981,14 +1023,18 @@ declare interface UserConfig {
981
1023
  experimentalWorker?: boolean;
982
1024
  /**
983
1025
  * After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
1026
+ * Only affects SSG, not SSG-MD. If excluded pages are not SSR-compatible,
1027
+ * fix their SSR compatibility or set `llms: false` to disable SSG-MD.
984
1028
  * @default []
985
1029
  */
986
1030
  experimentalExcludeRoutePaths?: (string | RegExp)[];
987
1031
  };
988
1032
  /**
989
- * Whether to enable llms and ssg-md
990
- * @default false
991
- * @experimental
1033
+ * Whether to render pages to Markdown (SSG-MD) and generate llms.txt and
1034
+ * llms-full.txt at build time.
1035
+ * Independent of `ssg`: these files are still generated when `ssg: false`.
1036
+ * Set to `false` to disable these outputs without affecting SSG.
1037
+ * @default true
992
1038
  */
993
1039
  llms?: boolean | {
994
1040
  /**
@@ -1001,6 +1047,15 @@ declare interface UserConfig {
1001
1047
  */
1002
1048
  remarkSplitMdxOptions?: RemarkSplitMdxOptions;
1003
1049
  };
1050
+ /**
1051
+ * Expose built-in documentation tools through the browser WebMCP API.
1052
+ * Markdown tools require `llms: true` in production.
1053
+ * @default true
1054
+ * @experimental
1055
+ */
1056
+ webMcp?: boolean | {
1057
+ exposedTo?: string[];
1058
+ };
1004
1059
  /**
1005
1060
  * Whether to enable medium-zoom
1006
1061
  * @default true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "2.0.23",
3
+ "version": "2.1.0-beta.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/web-infra-dev/rspress.git",
@@ -45,9 +45,9 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@rsbuild/core": "^2.2.10",
48
+ "@rsbuild/core": "^2.2.14",
49
49
  "@shikijs/rehype": "^4.2.0",
50
- "@types/react": "^19.2.18",
50
+ "@types/react": "^19.3.0",
51
51
  "mdast-util-mdx-jsx": "^3.2.0",
52
52
  "unified": "^11.0.5"
53
53
  },