@rspress/shared 2.0.18 → 2.0.20

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/91.js ADDED
@@ -0,0 +1 @@
1
+ export { logger } from "@rsbuild/core";
@@ -2042,7 +2042,7 @@ __webpack_require__.add({
2042
2042
  digits = [];
2043
2043
  if ('+-'.indexOf(value[0]) >= 0) value = value.slice(1);
2044
2044
  if ('.inf' === value) return 1 === sign ? 1 / 0 : -1 / 0;
2045
- if ('.nan' === value) return NaN;
2045
+ if ('.nan' === value) return 0 / 0;
2046
2046
  if (value.indexOf(':') >= 0) {
2047
2047
  value.split(':').forEach(function(v) {
2048
2048
  digits.unshift(parseFloat(v, 10));
package/dist/index.d.ts CHANGED
@@ -76,6 +76,7 @@ export declare interface FrontMatterMeta {
76
76
  pageType?: PageType;
77
77
  features?: Feature[];
78
78
  hero?: Hero;
79
+ icon?: string;
79
80
  tag?: string;
80
81
  navbar?: boolean;
81
82
  sidebar?: boolean | 'placeholder';
@@ -290,8 +291,11 @@ export declare interface LlmsTxtSection {
290
291
  */
291
292
  export declare type LlmsUI = {
292
293
  /**
293
- * Whether to inject a hidden hint into SSG HTML pages that points LLMs
294
- * to llms.txt and llms-full.txt.
294
+ * Whether to inject an LLM directive hint into generated pages. In SSG
295
+ * HTML output, it is rendered as a visually hidden plain-text DOM element
296
+ * with llms.txt, llms-full.txt, and the current page's Markdown version.
297
+ * In SSG-MD Markdown output, it is rendered as a leading blockquote
298
+ * string.
295
299
  * @default true
296
300
  */
297
301
  injectLlmsHint?: boolean;
@@ -446,6 +450,7 @@ export declare type NavItem = NavItemWithLink | NavItemWithChildren | NavItemWit
446
450
 
447
451
  export declare interface NavItemWithChildren {
448
452
  text?: string;
453
+ icon?: string;
449
454
  tag?: string;
450
455
  items: NavItem[];
451
456
  position?: 'left' | 'right';
@@ -455,6 +460,7 @@ export declare type NavItemWithLink = {
455
460
  text: string;
456
461
  link: string;
457
462
  download?: boolean;
463
+ icon?: string;
458
464
  tag?: string;
459
465
  activeMatch?: string;
460
466
  position?: 'left' | 'right';
@@ -466,6 +472,7 @@ export declare interface NavItemWithLinkAndChildren {
466
472
  text: string;
467
473
  link: string;
468
474
  items: NavItem[];
475
+ icon?: string;
469
476
  tag?: string;
470
477
  activeMatch?: string;
471
478
  position?: 'left' | 'right';
@@ -707,6 +714,23 @@ export declare interface RouteOptions {
707
714
  * @default false
708
715
  */
709
716
  cleanUrls?: boolean;
717
+ /**
718
+ * Normalize non-canonical browser URLs to the format selected by `cleanUrls`
719
+ * with the History API.
720
+ *
721
+ * When `cleanUrls` is enabled, regular page routes omit the trailing slash
722
+ * while directory index routes retain it. Otherwise, routes use `.html`
723
+ * URLs. This client-side fallback does not replace server-side 301/308
724
+ * redirects.
725
+ * @default true
726
+ */
727
+ cleanUrlsRedirect?: boolean;
728
+ /**
729
+ * How to redirect first-time visitors to the closest configured locale
730
+ * based on their browser language.
731
+ * @default 'auto'
732
+ */
733
+ localeRedirect?: 'auto' | 'never' | 'only-default-lang';
710
734
  /**
711
735
  * Enable concurrent, optimized routing for internal links rendered by
712
736
  * Rspress' default Link component.
@@ -821,6 +845,7 @@ export declare type SidebarDivider = {
821
845
  export declare interface SidebarGroup {
822
846
  text: string;
823
847
  link?: string;
848
+ icon?: string;
824
849
  tag?: string;
825
850
  items: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
826
851
  collapsible?: boolean;
@@ -836,6 +861,7 @@ export declare interface SidebarGroup {
836
861
  export declare type SidebarItem = {
837
862
  text: string;
838
863
  link: string;
864
+ icon?: string;
839
865
  tag?: string;
840
866
  /**
841
867
  * For hmr usage in development
@@ -847,6 +873,7 @@ export declare type SidebarItem = {
847
873
 
848
874
  export declare type SidebarSectionHeader = {
849
875
  sectionHeaderText: string;
876
+ icon?: string;
850
877
  tag?: string;
851
878
  };
852
879
 
@@ -971,7 +998,8 @@ declare type ThemeConfig = {
971
998
  */
972
999
  enableScrollToTop?: boolean;
973
1000
  /**
974
- * Whether to redirect to the closest locale when the user visits the site
1001
+ * Whether to redirect to the closest locale when the user visits the site.
1002
+ * @deprecated Use `route.localeRedirect` instead.
975
1003
  * @default 'auto'
976
1004
  */
977
1005
  localeRedirect?: 'auto' | 'never' | 'only-default-lang';
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ function normalizePosixPath(id) {
35
35
  if (isAbsolutePath) normalizedPath = `/${normalizedPath}`;
36
36
  return normalizedPath;
37
37
  }
38
- const inBrowser = ()=>false;
38
+ const inBrowser = ()=>!import.meta.env.SSR;
39
39
  function addLeadingSlash(url) {
40
40
  return '/' === url.charAt(0) || isExternalUrl(url) ? url : `/${url}`;
41
41
  }
@@ -62,14 +62,13 @@ function replaceLang(rawUrl, lang, version, base = '', cleanUrls = false, isPage
62
62
  if (url.endsWith('/')) url += cleanUrls ? '/index' : '/index.html';
63
63
  let versionPart = '';
64
64
  let langPart = '';
65
- let purePathPart = '';
66
65
  const parts = url.split('/').filter(Boolean);
67
66
  if (version.current && version.current !== version.default) versionPart = parts.shift() || '';
68
67
  if (lang.target !== lang.default) {
69
68
  langPart = lang.target;
70
69
  if (lang.current !== lang.default) parts.shift();
71
70
  } else parts.shift();
72
- purePathPart = parts.join('/') || '';
71
+ let purePathPart = parts.join('/') || '';
73
72
  if ((versionPart || langPart) && !purePathPart) purePathPart = cleanUrls ? 'index' : 'index.html';
74
73
  return addLeadingSlash([
75
74
  versionPart,
package/dist/logger.js CHANGED
@@ -1 +1 @@
1
- export { logger } from "@rsbuild/core";
1
+ export { logger } from "./91.js";
@@ -73,6 +73,7 @@ declare interface FrontMatterMeta {
73
73
  pageType?: PageType;
74
74
  features?: Feature[];
75
75
  hero?: Hero;
76
+ icon?: string;
76
77
  tag?: string;
77
78
  navbar?: boolean;
78
79
  sidebar?: boolean | 'placeholder';
@@ -277,8 +278,11 @@ declare interface LlmsTxtSection {
277
278
  */
278
279
  declare type LlmsUI = {
279
280
  /**
280
- * Whether to inject a hidden hint into SSG HTML pages that points LLMs
281
- * to llms.txt and llms-full.txt.
281
+ * Whether to inject an LLM directive hint into generated pages. In SSG
282
+ * HTML output, it is rendered as a visually hidden plain-text DOM element
283
+ * with llms.txt, llms-full.txt, and the current page's Markdown version.
284
+ * In SSG-MD Markdown output, it is rendered as a leading blockquote
285
+ * string.
282
286
  * @default true
283
287
  */
284
288
  injectLlmsHint?: boolean;
@@ -430,6 +434,7 @@ declare type NavItem = NavItemWithLink | NavItemWithChildren | NavItemWithLinkAn
430
434
 
431
435
  declare interface NavItemWithChildren {
432
436
  text?: string;
437
+ icon?: string;
433
438
  tag?: string;
434
439
  items: NavItem[];
435
440
  position?: 'left' | 'right';
@@ -439,6 +444,7 @@ declare type NavItemWithLink = {
439
444
  text: string;
440
445
  link: string;
441
446
  download?: boolean;
447
+ icon?: string;
442
448
  tag?: string;
443
449
  activeMatch?: string;
444
450
  position?: 'left' | 'right';
@@ -450,6 +456,7 @@ declare interface NavItemWithLinkAndChildren {
450
456
  text: string;
451
457
  link: string;
452
458
  items: NavItem[];
459
+ icon?: string;
453
460
  tag?: string;
454
461
  activeMatch?: string;
455
462
  position?: 'left' | 'right';
@@ -581,6 +588,23 @@ declare interface RouteOptions {
581
588
  * @default false
582
589
  */
583
590
  cleanUrls?: boolean;
591
+ /**
592
+ * Normalize non-canonical browser URLs to the format selected by `cleanUrls`
593
+ * with the History API.
594
+ *
595
+ * When `cleanUrls` is enabled, regular page routes omit the trailing slash
596
+ * while directory index routes retain it. Otherwise, routes use `.html`
597
+ * URLs. This client-side fallback does not replace server-side 301/308
598
+ * redirects.
599
+ * @default true
600
+ */
601
+ cleanUrlsRedirect?: boolean;
602
+ /**
603
+ * How to redirect first-time visitors to the closest configured locale
604
+ * based on their browser language.
605
+ * @default 'auto'
606
+ */
607
+ localeRedirect?: 'auto' | 'never' | 'only-default-lang';
584
608
  /**
585
609
  * Enable concurrent, optimized routing for internal links rendered by
586
610
  * Rspress' default Link component.
@@ -687,6 +711,7 @@ declare type SidebarDivider = {
687
711
  declare interface SidebarGroup {
688
712
  text: string;
689
713
  link?: string;
714
+ icon?: string;
690
715
  tag?: string;
691
716
  items: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
692
717
  collapsible?: boolean;
@@ -702,6 +727,7 @@ declare interface SidebarGroup {
702
727
  declare type SidebarItem = {
703
728
  text: string;
704
729
  link: string;
730
+ icon?: string;
705
731
  tag?: string;
706
732
  /**
707
733
  * For hmr usage in development
@@ -713,6 +739,7 @@ declare type SidebarItem = {
713
739
 
714
740
  declare type SidebarSectionHeader = {
715
741
  sectionHeaderText: string;
742
+ icon?: string;
716
743
  tag?: string;
717
744
  };
718
745
 
@@ -804,7 +831,8 @@ declare type ThemeConfig = {
804
831
  */
805
832
  enableScrollToTop?: boolean;
806
833
  /**
807
- * Whether to redirect to the closest locale when the user visits the site
834
+ * Whether to redirect to the closest locale when the user visits the site.
835
+ * @deprecated Use `route.localeRedirect` instead.
808
836
  * @default 'auto'
809
837
  */
810
838
  localeRedirect?: 'auto' | 'never' | 'only-default-lang';
@@ -1,7 +1,7 @@
1
1
  import node_path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { grayMatter } from "./gray-matter.js";
4
- import { logger } from "./logger.js";
4
+ import { logger } from "./91.js";
5
5
  import { mergeWith as lodash_es_mergeWith } from "./584.js";
6
6
  const extractTextAndId = (title)=>{
7
7
  if (!title) return [
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/web-infra-dev/rspress.git",
7
7
  "directory": "packages/shared"
8
8
  },
9
9
  "license": "MIT",
10
+ "sideEffects": false,
10
11
  "type": "module",
11
12
  "exports": {
12
13
  ".": {
@@ -44,23 +45,24 @@
44
45
  "dist"
45
46
  ],
46
47
  "dependencies": {
47
- "@rsbuild/core": "^2.1.5",
48
+ "@rsbuild/core": "^2.1.13",
48
49
  "@shikijs/rehype": "^4.2.0",
50
+ "@types/react": "^19.2.18",
51
+ "mdast-util-mdx-jsx": "^3.2.0",
49
52
  "unified": "^11.0.5"
50
53
  },
51
54
  "devDependencies": {
52
- "@rslib/core": "0.23.2",
55
+ "@rslib/core": "1.0.0-rc.0",
53
56
  "@types/lodash-es": "^4.17.12",
54
57
  "@types/node": "^22.8.1",
55
- "@types/react": "^19.2.17",
56
58
  "github-slugger": "^2.0.0",
57
59
  "gray-matter": "4.0.3",
58
60
  "lodash-es": "^4.18.1",
59
- "mdast-util-mdx-jsx": "^3.2.0",
60
61
  "medium-zoom": "1.1.0",
61
62
  "rimraf": "^6.1.3",
62
63
  "rsbuild-plugin-publint": "^1.0.0",
63
- "typescript": "^6.0.3"
64
+ "typescript": "^6.0.3",
65
+ "@rspress/config": "1.0.0"
64
66
  },
65
67
  "publishConfig": {
66
68
  "access": "public",