@rspress/shared 0.2.0 → 1.0.0-beta.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 CHANGED
@@ -479,6 +479,7 @@ interface SiteData<ThemeConfig = NormalizedConfig> {
479
479
  root: string;
480
480
  base: string;
481
481
  lang: string;
482
+ route: RouteOptions;
482
483
  locales: {
483
484
  lang: string;
484
485
  label: string;
@@ -572,14 +573,6 @@ interface PageData {
572
573
  };
573
574
  }
574
575
  interface RouteOptions {
575
- /**
576
- * The directory to search for pages
577
- */
578
- root?: string;
579
- /**
580
- * The basename of the site
581
- */
582
- prefix?: string;
583
576
  /**
584
577
  * The extension name of the filepath that will be converted to a route
585
578
  * @default ['js','jsx','ts','tsx','md','mdx']
@@ -593,6 +586,10 @@ interface RouteOptions {
593
586
  * Exclude files from being converted to routes
594
587
  */
595
588
  exclude?: string[];
589
+ /**
590
+ * use links without .html files
591
+ */
592
+ cleanUrls?: boolean;
596
593
  }
597
594
  interface SearchHooks {
598
595
  /**
@@ -658,7 +655,7 @@ declare const parseUrl: (url: string) => {
658
655
  url: string;
659
656
  hash: string;
660
657
  };
661
- declare function normalizeHref(url?: string): string;
658
+ declare function normalizeHref(url?: string, cleanUrls?: boolean): string;
662
659
  declare function withoutLang(path: string, langs: string[]): string;
663
660
  declare function withoutBase(path: string, base?: string): string;
664
661
  declare function withBase(url?: string, base?: string): string;
package/dist/index.js CHANGED
@@ -1204,7 +1204,7 @@ var parseUrl = (url) => {
1204
1204
  hash
1205
1205
  };
1206
1206
  };
1207
- function normalizeHref(url) {
1207
+ function normalizeHref(url, cleanUrls = false) {
1208
1208
  if (!url) {
1209
1209
  return "/";
1210
1210
  }
@@ -1215,7 +1215,7 @@ function normalizeHref(url) {
1215
1215
  if (url.startsWith("mailto:") || url.startsWith("tel:")) {
1216
1216
  return url;
1217
1217
  }
1218
- if (!cleanUrl2.endsWith(".html")) {
1218
+ if (!cleanUrls && !cleanUrl2.endsWith(".html")) {
1219
1219
  if (cleanUrl2.endsWith("/")) {
1220
1220
  cleanUrl2 += "index.html";
1221
1221
  } else {
package/dist/index.mjs CHANGED
@@ -1159,7 +1159,7 @@ var parseUrl = (url) => {
1159
1159
  hash
1160
1160
  };
1161
1161
  };
1162
- function normalizeHref(url) {
1162
+ function normalizeHref(url, cleanUrls = false) {
1163
1163
  if (!url) {
1164
1164
  return "/";
1165
1165
  }
@@ -1170,7 +1170,7 @@ function normalizeHref(url) {
1170
1170
  if (url.startsWith("mailto:") || url.startsWith("tel:")) {
1171
1171
  return url;
1172
1172
  }
1173
- if (!cleanUrl2.endsWith(".html")) {
1173
+ if (!cleanUrls && !cleanUrl2.endsWith(".html")) {
1174
1174
  if (cleanUrl2.endsWith("/")) {
1175
1175
  cleanUrl2 += "index.html";
1176
1176
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "0.2.0",
3
+ "version": "1.0.0-beta.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",