@rspress/shared 2.0.0-beta.25 → 2.0.0-beta.27

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
@@ -28,8 +28,6 @@ export declare const cleanUrl: (url: string) => string;
28
28
 
29
29
  export declare type Config = UserConfig | Promise<UserConfig> | ((...args: Parameters<typeof loadConfig>) => UserConfig | Promise<UserConfig>);
30
30
 
31
- export declare const DEFAULT_HIGHLIGHT_LANGUAGES: string[][];
32
-
33
31
  export declare interface DefaultThemeConfig {
34
32
  /**
35
33
  * Whether to enable dark mode.
@@ -420,7 +418,7 @@ export declare interface NormalizedSidebar {
420
418
  }
421
419
 
422
420
  export declare interface NormalizedSidebarGroup extends Omit<SidebarGroup, 'items'> {
423
- items: (SidebarDivider | SidebarItem | SidebarSectionHeader | NormalizedSidebarGroup)[];
421
+ items: SidebarData;
424
422
  collapsible: boolean;
425
423
  collapsed: boolean;
426
424
  }
@@ -666,6 +664,8 @@ export declare interface Sidebar {
666
664
  [path: string]: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
667
665
  }
668
666
 
667
+ export declare type SidebarData = (SidebarDivider | SidebarItem | SidebarSectionHeader | NormalizedSidebarGroup)[];
668
+
669
669
  export declare type SidebarDivider = {
670
670
  dividerType: 'dashed' | 'solid';
671
671
  };
package/dist/index.js CHANGED
@@ -19,32 +19,6 @@ const MDX_OR_MD_REGEXP = /\.mdx?$/;
19
19
  const APPEARANCE_KEY = 'rspress-theme-appearance';
20
20
  const SEARCH_INDEX_NAME = 'search_index';
21
21
  const RSPRESS_TEMP_DIR = '.rspress';
22
- const DEFAULT_HIGHLIGHT_LANGUAGES = [
23
- [
24
- 'js',
25
- "javascript"
26
- ],
27
- [
28
- 'ts',
29
- "typescript"
30
- ],
31
- [
32
- 'jsx',
33
- 'tsx'
34
- ],
35
- [
36
- 'xml',
37
- 'xml-doc'
38
- ],
39
- [
40
- 'md',
41
- 'markdown'
42
- ],
43
- [
44
- 'mdx',
45
- 'tsx'
46
- ]
47
- ];
48
22
  const isProduction = ()=>'production' === process.env.NODE_ENV;
49
23
  const isDebugMode = ()=>{
50
24
  if (!process.env.DEBUG) return false;
@@ -147,12 +121,13 @@ function normalizeHref(url, cleanUrls = false) {
147
121
  if (!url) return '/';
148
122
  if (isExternalUrl(url)) return url;
149
123
  if (url.startsWith('#')) return url;
124
+ if (!url.startsWith('/')) return url;
150
125
  let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
151
126
  if (cleanUrls) {
152
127
  if (cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
153
128
  if (cleanUrls && cleanUrl.endsWith('/index')) cleanUrl = cleanUrl.replace(/\/index$/, '/');
154
129
  } else {
155
- const hasExt = /\.[a-zA-Z]\w*$/.test(cleanUrl);
130
+ const hasExt = cleanUrl.endsWith('.html');
156
131
  if (!hasExt) if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
157
132
  else cleanUrl += '.html';
158
133
  }
@@ -170,4 +145,4 @@ function withBase(url, base) {
170
145
  function removeBase(url, base) {
171
146
  return addLeadingSlash(url).replace(new RegExp(`^${normalizeSlash(base)}`), '');
172
147
  }
173
- export { APPEARANCE_KEY, DEFAULT_HIGHLIGHT_LANGUAGES, HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, utils_cleanUrl as cleanUrl, getSidebarDataGroup, inBrowser, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath, normalizeSlash, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutLang };
148
+ export { APPEARANCE_KEY, HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, utils_cleanUrl as cleanUrl, getSidebarDataGroup, inBrowser, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath, normalizeSlash, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutLang };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "2.0.0-beta.25",
3
+ "version": "2.0.0-beta.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/web-infra-dev/rspress.git",
@@ -32,14 +32,14 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@rsbuild/core": "~1.4.13",
36
- "@shikijs/rehype": "^3.8.1",
35
+ "@rsbuild/core": "~1.4.15",
36
+ "@shikijs/rehype": "^3.9.2",
37
37
  "gray-matter": "4.0.3",
38
38
  "lodash-es": "^4.17.21",
39
39
  "unified": "^11.0.5"
40
40
  },
41
41
  "devDependencies": {
42
- "@rslib/core": "0.11.1",
42
+ "@rslib/core": "0.11.2",
43
43
  "@types/jest": "~29.5.14",
44
44
  "@types/lodash-es": "^4.17.12",
45
45
  "@types/node": "^22.8.1",
@@ -47,7 +47,7 @@
47
47
  "mdast-util-mdx-jsx": "^3.2.0",
48
48
  "medium-zoom": "1.1.0",
49
49
  "rimraf": "^6.0.1",
50
- "rsbuild-plugin-publint": "^0.3.2",
50
+ "rsbuild-plugin-publint": "^0.3.3",
51
51
  "typescript": "^5.8.2"
52
52
  },
53
53
  "publishConfig": {
@@ -57,6 +57,7 @@
57
57
  "scripts": {
58
58
  "build": "rslib build",
59
59
  "build:watch": "rslib build -w",
60
+ "dev": "rslib build -w",
60
61
  "reset": "rimraf ./**/node_modules"
61
62
  }
62
63
  }