@rspress/shared 0.0.0-next-20230927072732 → 0.0.0-next-20231020055855
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 +37 -11
- package/dist/index.js +29 -2
- package/dist/index.mjs +703 -678
- package/dist/logger.d.ts +1 -12
- package/dist/logger.js +4 -38
- package/dist/logger.mjs +2 -26
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
@@ -57,7 +57,7 @@ interface Config$1 {
|
|
57
57
|
/**
|
58
58
|
* Custom outline title in the aside component.
|
59
59
|
*
|
60
|
-
* @default '
|
60
|
+
* @default 'ON THIS PAGE'
|
61
61
|
*/
|
62
62
|
outlineTitle?: string;
|
63
63
|
/**
|
@@ -119,13 +119,9 @@ interface Config$1 {
|
|
119
119
|
*/
|
120
120
|
search?: boolean;
|
121
121
|
/**
|
122
|
-
*
|
122
|
+
* The behavior of hiding navbar
|
123
123
|
*/
|
124
|
-
|
125
|
-
/**
|
126
|
-
* Whether to hide the navbar
|
127
|
-
*/
|
128
|
-
hideNavbar?: boolean;
|
124
|
+
hideNavbar?: 'always' | 'auto' | 'never';
|
129
125
|
/**
|
130
126
|
* Whether to enable the animation for translation pages
|
131
127
|
*/
|
@@ -292,7 +288,10 @@ interface RspressPlugin {
|
|
292
288
|
/**
|
293
289
|
* Modify doc config.
|
294
290
|
*/
|
295
|
-
config?: (config: UserConfig
|
291
|
+
config?: (config: UserConfig, utils: {
|
292
|
+
addPlugin: (plugin: RspressPlugin) => void;
|
293
|
+
removePlugin: (pluginName: string) => void;
|
294
|
+
}) => UserConfig | Promise<UserConfig>;
|
296
295
|
/**
|
297
296
|
* Callback before build
|
298
297
|
*/
|
@@ -479,6 +478,7 @@ interface SiteData<ThemeConfig = NormalizedConfig> {
|
|
479
478
|
root: string;
|
480
479
|
base: string;
|
481
480
|
lang: string;
|
481
|
+
route: RouteOptions;
|
482
482
|
locales: {
|
483
483
|
lang: string;
|
484
484
|
label: string;
|
@@ -585,6 +585,10 @@ interface RouteOptions {
|
|
585
585
|
* Exclude files from being converted to routes
|
586
586
|
*/
|
587
587
|
exclude?: string[];
|
588
|
+
/**
|
589
|
+
* use links without .html files
|
590
|
+
*/
|
591
|
+
cleanUrls?: boolean;
|
588
592
|
}
|
589
593
|
interface SearchHooks {
|
590
594
|
/**
|
@@ -610,10 +614,27 @@ type SearchOptions = LocalSearchOptions | RemoteSearchOptions | false;
|
|
610
614
|
interface MarkdownOptions {
|
611
615
|
remarkPlugins?: PluggableList;
|
612
616
|
rehypePlugins?: PluggableList;
|
617
|
+
/**
|
618
|
+
* Whether to enable check dead links, default is false
|
619
|
+
*/
|
613
620
|
checkDeadLinks?: boolean;
|
614
|
-
experimentalMdxRs?: boolean;
|
615
621
|
showLineNumbers?: boolean;
|
622
|
+
/**
|
623
|
+
* Register global components in mdx files
|
624
|
+
*/
|
616
625
|
globalComponents?: string[];
|
626
|
+
/**
|
627
|
+
* Register prism languages
|
628
|
+
*/
|
629
|
+
highlightLanguages?: (string | [string, string])[];
|
630
|
+
/**
|
631
|
+
* Whether to enable mdx-rs, default is true
|
632
|
+
*/
|
633
|
+
mdxRs?: boolean;
|
634
|
+
/**
|
635
|
+
* @deprecated, use `mdxRs` instead
|
636
|
+
*/
|
637
|
+
experimentalMdxRs?: boolean;
|
617
638
|
}
|
618
639
|
type Config = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
|
619
640
|
|
@@ -643,6 +664,11 @@ declare function replaceLang(rawUrl: string, lang: {
|
|
643
664
|
current: string;
|
644
665
|
default: string;
|
645
666
|
}, base?: string): string;
|
667
|
+
declare function replaceVersion(rawUrl: string, version: {
|
668
|
+
current: string;
|
669
|
+
target: string;
|
670
|
+
default: string;
|
671
|
+
}, base?: string): string;
|
646
672
|
declare const omit: (obj: Record<string, unknown>, keys: string[]) => {
|
647
673
|
[x: string]: unknown;
|
648
674
|
};
|
@@ -650,7 +676,7 @@ declare const parseUrl: (url: string) => {
|
|
650
676
|
url: string;
|
651
677
|
hash: string;
|
652
678
|
};
|
653
|
-
declare function normalizeHref(url?: string): string;
|
679
|
+
declare function normalizeHref(url?: string, cleanUrls?: boolean): string;
|
654
680
|
declare function withoutLang(path: string, langs: string[]): string;
|
655
681
|
declare function withoutBase(path: string, base?: string): string;
|
656
682
|
declare function withBase(url?: string, base?: string): string;
|
@@ -658,4 +684,4 @@ declare function removeBase(url: string, base: string): string;
|
|
658
684
|
declare function withoutHash(url: string): string;
|
659
685
|
declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
|
660
686
|
|
661
|
-
export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeLeadingSlash, removeTrailingSlash, replaceLang, slash, withBase, withoutBase, withoutHash, withoutLang };
|
687
|
+
export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
|
package/dist/index.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"use strict";
|
1
2
|
var __defProp = Object.defineProperty;
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
@@ -42,6 +43,7 @@ __export(src_exports, {
|
|
42
43
|
removeLeadingSlash: () => removeLeadingSlash,
|
43
44
|
removeTrailingSlash: () => removeTrailingSlash,
|
44
45
|
replaceLang: () => replaceLang,
|
46
|
+
replaceVersion: () => replaceVersion,
|
45
47
|
slash: () => slash,
|
46
48
|
withBase: () => withBase,
|
47
49
|
withoutBase: () => withoutBase,
|
@@ -1190,6 +1192,30 @@ function replaceLang(rawUrl, lang, version, base = "") {
|
|
1190
1192
|
base
|
1191
1193
|
);
|
1192
1194
|
}
|
1195
|
+
function replaceVersion(rawUrl, version, base = "") {
|
1196
|
+
let url = removeBase(rawUrl, base);
|
1197
|
+
if (!url) {
|
1198
|
+
url = "/index.html";
|
1199
|
+
}
|
1200
|
+
let versionPart = "";
|
1201
|
+
const parts = url.split("/").filter(Boolean);
|
1202
|
+
if (version.target !== version.default) {
|
1203
|
+
versionPart = version.target;
|
1204
|
+
if (version.current !== version.default) {
|
1205
|
+
parts.shift();
|
1206
|
+
}
|
1207
|
+
} else {
|
1208
|
+
parts.shift();
|
1209
|
+
}
|
1210
|
+
let restPart = parts.join("/") || "";
|
1211
|
+
if (versionPart && !restPart) {
|
1212
|
+
restPart = "index.html";
|
1213
|
+
}
|
1214
|
+
return withBase(
|
1215
|
+
addLeadingSlash([versionPart, restPart].filter(Boolean).join("/")),
|
1216
|
+
base
|
1217
|
+
);
|
1218
|
+
}
|
1193
1219
|
var omit = (obj, keys) => {
|
1194
1220
|
const ret = { ...obj };
|
1195
1221
|
for (const key of keys) {
|
@@ -1204,7 +1230,7 @@ var parseUrl = (url) => {
|
|
1204
1230
|
hash
|
1205
1231
|
};
|
1206
1232
|
};
|
1207
|
-
function normalizeHref(url) {
|
1233
|
+
function normalizeHref(url, cleanUrls = false) {
|
1208
1234
|
if (!url) {
|
1209
1235
|
return "/";
|
1210
1236
|
}
|
@@ -1215,7 +1241,7 @@ function normalizeHref(url) {
|
|
1215
1241
|
if (url.startsWith("mailto:") || url.startsWith("tel:")) {
|
1216
1242
|
return url;
|
1217
1243
|
}
|
1218
|
-
if (!cleanUrl2.endsWith(".html")) {
|
1244
|
+
if (!cleanUrls && !cleanUrl2.endsWith(".html")) {
|
1219
1245
|
if (cleanUrl2.endsWith("/")) {
|
1220
1246
|
cleanUrl2 += "index.html";
|
1221
1247
|
} else {
|
@@ -1277,6 +1303,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1277
1303
|
removeLeadingSlash,
|
1278
1304
|
removeTrailingSlash,
|
1279
1305
|
replaceLang,
|
1306
|
+
replaceVersion,
|
1280
1307
|
slash,
|
1281
1308
|
withBase,
|
1282
1309
|
withoutBase,
|