@rspress/core 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/2711~0.js +3007 -0
- package/dist/{4538.js → 4538~0.js} +1 -1
- package/dist/{5357.js → 5357~0.js} +1 -1
- package/dist/{3553.js → 8472~0.js} +3 -3
- package/dist/{0~execa.js → 864~0.js} +11 -11
- package/dist/cli/index.js +13 -40
- package/dist/config/defineConfig.d.ts +15 -15
- package/dist/config/loadConfigFile.js +2 -3
- package/dist/eject-theme/components/HoverGroup/index.scss +16 -0
- package/dist/eject-theme/components/HoverGroup/index.tsx +22 -1
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +2 -6
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +2 -5
- package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +104 -0
- package/dist/eject-theme/components/Llms/LlmsHint.tsx +74 -0
- package/dist/eject-theme/components/Llms/getLlmsCopyContent.test.ts +21 -0
- package/dist/eject-theme/components/Llms/getLlmsCopyContent.ts +20 -0
- package/dist/eject-theme/components/Llms/index.tsx +1 -1
- package/dist/eject-theme/components/Nav/NavMenu.scss +16 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +12 -0
- package/dist/eject-theme/components/Nav/hooks.tsx +1 -2
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +18 -2
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +27 -19
- package/dist/eject-theme/components/NavScreen/index.scss +4 -0
- package/dist/eject-theme/components/Outline/index.scss +4 -0
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +3 -0
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +16 -0
- package/dist/eject-theme/components/Sidebar/SidebarItem.test.tsx +51 -0
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +10 -1
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +15 -0
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +6 -1
- package/dist/eject-theme/components/Sidebar/index.tsx +1 -0
- package/dist/index.js +1 -1
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +40 -12
- package/dist/node/auto-nav-sidebar/type.d.ts +7 -0
- package/dist/node/auto-nav-sidebar/utils.d.ts +1 -0
- package/dist/node/auto-nav-sidebar/utils.js +2 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.d.ts +2 -1
- package/dist/node/constants.js +50 -2
- package/dist/node/dev.d.ts +2 -1
- package/dist/node/dev.js +7 -2
- package/dist/node/eject.js +3 -3
- package/dist/node/initRsbuild.d.ts +6 -2
- package/dist/node/initRsbuild.js +37 -13
- package/dist/node/last-updated/index.js +113 -16
- package/dist/node/logger/hint.js +2 -2
- package/dist/node/mdx/options.js +3 -2
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
- package/dist/node/mdx/remarkPlugins/image.js +3 -3
- package/dist/node/mdx/remarkPlugins/link.d.ts +2 -1
- package/dist/node/mdx/remarkPlugins/link.js +8 -7
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.d.ts +0 -1
- package/dist/node/route/RoutePage.js +4 -6
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +3 -15
- package/dist/node/route/normalizeRoutePath.js +2 -3
- package/dist/node/runtimeModule/i18n.js +3 -3
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +1 -1
- package/dist/node/ssg/renderPage.js +3 -3
- package/dist/node/ssg/renderPageWorker.js +2 -2
- package/dist/node/ssg/renderPages.js +6 -6
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +8 -10
- package/dist/node/ssg-md/renderPage.js +3 -3
- package/dist/node/ssg-md/renderPages.js +4 -4
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +2 -2
- package/dist/node/utils/flattenMdxContent.js +2 -2
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +3 -3
- package/dist/runtime/App.js +7 -4
- package/dist/runtime/csrClientEntry.js +7 -2
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/reactDom.d.ts +19 -0
- package/dist/runtime/reactDom.js +5 -0
- package/dist/runtime/route.d.ts +10 -0
- package/dist/runtime/route.js +13 -2
- package/dist/runtime/ssrClientEntry.js +2 -0
- package/dist/theme/components/HoverGroup/index.css +15 -0
- package/dist/theme/components/HoverGroup/index.js +17 -1
- package/dist/theme/components/Llms/LlmsCopyButton.js +3 -4
- package/dist/theme/components/Llms/LlmsCopyRow.js +2 -3
- package/dist/theme/components/Llms/LlmsHint.d.ts +2 -0
- package/dist/theme/components/Llms/LlmsHint.js +44 -0
- package/dist/theme/components/Llms/getLlmsCopyContent.d.ts +1 -0
- package/dist/theme/components/Llms/getLlmsCopyContent.js +14 -0
- package/dist/theme/components/Llms/index.d.ts +1 -1
- package/dist/theme/components/Llms/index.js +1 -1
- package/dist/theme/components/Nav/NavMenu.css +15 -0
- package/dist/theme/components/Nav/NavMenu.js +8 -0
- package/dist/theme/components/Nav/hooks.js +1 -2
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +17 -2
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -22
- package/dist/theme/components/NavScreen/index.css +4 -0
- package/dist/theme/components/Outline/index.css +4 -0
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.js +4 -1
- package/dist/theme/components/Sidebar/SidebarItem.css +15 -0
- package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -1
- package/dist/theme/components/Sidebar/SidebarItem.js +7 -2
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +14 -0
- package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +2 -1
- package/dist/theme/components/Sidebar/SidebarSectionHeader.js +12 -6
- package/dist/theme/components/Sidebar/index.js +1 -0
- package/dist/theme/components/SwitchAppearance/global.css +3 -16
- package/dist/theme/index.d.ts +1 -2
- package/dist/theme/index.js +1 -2
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/theme/logic/utils.d.ts +4 -0
- package/dist/theme/logic/utils.js +23 -2
- package/dist/theme/styles/preflight.css +0 -2
- package/meta-json-schema.json +33 -3
- package/nav-json-schema.json +9 -0
- package/package.json +18 -23
- package/dist/5871.js +0 -7275
- package/dist/5871.js.LICENSE.txt +0 -41
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +0 -23
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +0 -15
- package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +0 -1
- package/dist/theme/components/Llms/LlmsHiddenHint.js +0 -18
- package/dist/theme/logic/useRedirect4FirstVisit.d.ts +0 -5
- package/dist/theme/logic/useRedirect4FirstVisit.js +0 -31
- /package/dist/{102.js → 102~0.js} +0 -0
- /package/dist/{7748.js → 7748~0.js} +0 -0
- /package/dist/{0~8016.js → 8016~0.js} +0 -0
- /package/dist/{9857.js → 9857~0.js} +0 -0
- /package/dist/{9940.js → 9940~0.js} +0 -0
- /package/dist/{0~rslib-runtime.js → rslib-runtime~0.js} +0 -0
- /package/dist/{0~tinypool.js → tinypool~0.js} +0 -0
package/dist/node/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../
|
|
1
|
+
import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../8472~0.js";
|
|
2
2
|
const constants_require = createRequire(import.meta.url);
|
|
3
3
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
4
4
|
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
|
@@ -18,6 +18,54 @@ const getInlineThemeScript = (darkMode)=>{
|
|
|
18
18
|
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
|
19
19
|
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
20
20
|
};
|
|
21
|
+
const serializeInlineScriptData = (value)=>JSON.stringify(value).replace(/</g, '\\u003c');
|
|
22
|
+
const getInlineLocaleRedirectScript = (config)=>{
|
|
23
|
+
const localeRedirect = config.route?.localeRedirect ?? config.themeConfig?.localeRedirect ?? 'auto';
|
|
24
|
+
const defaultLang = config.lang || '';
|
|
25
|
+
const locales = config.locales ?? config.themeConfig?.locales ?? [];
|
|
26
|
+
if ('never' === localeRedirect || !defaultLang || 0 === locales.length) return '';
|
|
27
|
+
const langs = locales.map((locale)=>locale.lang);
|
|
28
|
+
const versions = config.multiVersion?.versions ?? [];
|
|
29
|
+
const base = (config.base ?? '/').replace(/\/$/, '');
|
|
30
|
+
const routePathname = base ? 'cleanPathname' : 'pathname';
|
|
31
|
+
const pathDeclarations = base ? `base = ${serializeInlineScriptData(base)}, cleanPathname = pathname.startsWith(base) ? pathname.slice(base.length) || '/' : pathname, pathSegments = cleanPathname.split('/').filter(Boolean)` : "pathSegments = pathname.split('/').filter(Boolean)";
|
|
32
|
+
const langIndex = versions.length ? 'langIndex' : '0';
|
|
33
|
+
const versionDeclarations = versions.length ? `versions = ${serializeInlineScriptData(versions)}, langIndex = versions.includes(pathSegments[0]) ? 1 : 0` : '';
|
|
34
|
+
const routeDeclarations = [
|
|
35
|
+
pathDeclarations,
|
|
36
|
+
versionDeclarations,
|
|
37
|
+
`currentLang = langs.includes(pathSegments[${langIndex}]) ? pathSegments[${langIndex}] : defaultLang`
|
|
38
|
+
].filter(Boolean).join(', ');
|
|
39
|
+
const replaceLocationScript = `
|
|
40
|
+
var newPathname = '/' + newPathSegments.join('/'), trailingSlash = newPathname !== '/' && ${routePathname}.endsWith('/') ? '/' : ''
|
|
41
|
+
window.location['replace'](${base ? 'base + ' : ''}newPathname + trailingSlash + search)`;
|
|
42
|
+
const redirectScript = 'only-default-lang' === localeRedirect ? `if (currentLang === defaultLang && langs.includes(targetLang) && targetLang !== defaultLang) {
|
|
43
|
+
var newPathSegments = pathSegments.slice()
|
|
44
|
+
newPathSegments.splice(${langIndex}, 0, targetLang)
|
|
45
|
+
${replaceLocationScript}
|
|
46
|
+
}` : `if (langs.includes(targetLang) && targetLang !== currentLang) {
|
|
47
|
+
var newPathSegments = pathSegments.slice()
|
|
48
|
+
if (targetLang === defaultLang) {
|
|
49
|
+
newPathSegments.splice(${langIndex}, 1)
|
|
50
|
+
} else if (currentLang === defaultLang) {
|
|
51
|
+
newPathSegments.splice(${langIndex}, 0, targetLang)
|
|
52
|
+
} else {
|
|
53
|
+
newPathSegments[${langIndex}] = targetLang
|
|
54
|
+
}
|
|
55
|
+
${replaceLocationScript}
|
|
56
|
+
}`;
|
|
57
|
+
return `{
|
|
58
|
+
var defaultLang = ${serializeInlineScriptData(defaultLang)}, langs = ${serializeInlineScriptData(langs)}
|
|
59
|
+
if (!/bot|spider|crawl|lighthouse/i.test(window.navigator.userAgent)) {
|
|
60
|
+
var firstVisitKey = 'rspress-visited', visited = localStorage.getItem(firstVisitKey)
|
|
61
|
+
if (!visited) {
|
|
62
|
+
localStorage.setItem(firstVisitKey, '1')
|
|
63
|
+
var targetLang = window.navigator.language.split('-')[0], { pathname, search } = window.location, ${routeDeclarations}
|
|
64
|
+
${redirectScript}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
68
|
+
};
|
|
21
69
|
const PACKAGE_ROOT = node_path.dirname(constants_require.resolve('@rspress/core/package.json'));
|
|
22
70
|
const DEFAULT_THEME = node_path.join(PACKAGE_ROOT, 'dist/theme');
|
|
23
71
|
const EJECTED_THEME = node_path.join(PACKAGE_ROOT, 'dist/eject-theme');
|
|
@@ -36,4 +84,4 @@ const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
|
|
|
36
84
|
const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
|
|
37
85
|
const NODE_SSG_MD_BUNDLE_FOLDER = '__ssg_md__';
|
|
38
86
|
const NODE_SSG_MD_BUNDLE_NAME = 'rspress-ssg-md-entry.cjs';
|
|
39
|
-
export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, PUBLIC_DIR, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, getInlineThemeScript, importStatementRegex, isProduction };
|
|
87
|
+
export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, PUBLIC_DIR, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, getInlineLocaleRedirectScript, getInlineThemeScript, importStatementRegex, isProduction };
|
package/dist/node/dev.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RsbuildConfig } from '@rsbuild/core';
|
|
1
|
+
import type { RestartFn, RsbuildConfig } from '@rsbuild/core';
|
|
2
2
|
import type { UserConfig } from '@rspress/shared';
|
|
3
3
|
interface ServerInstance {
|
|
4
4
|
close: () => Promise<void>;
|
|
@@ -9,6 +9,7 @@ interface DevOptions {
|
|
|
9
9
|
config: UserConfig;
|
|
10
10
|
configFilePath: string;
|
|
11
11
|
extraBuilderConfig?: RsbuildConfig;
|
|
12
|
+
restart?: RestartFn;
|
|
12
13
|
}
|
|
13
14
|
export declare function dev(options: DevOptions): Promise<ServerInstance>;
|
|
14
15
|
export {};
|
package/dist/node/dev.js
CHANGED
|
@@ -3,7 +3,8 @@ import { RouteService } from "./route/RouteService.js";
|
|
|
3
3
|
import { initRsbuild } from "./initRsbuild.js";
|
|
4
4
|
import { checkLanguageParity } from "./utils/checkLanguageParity.js";
|
|
5
5
|
async function dev(options) {
|
|
6
|
-
const { docDirectory, config, extraBuilderConfig, configFilePath } = options;
|
|
6
|
+
const { docDirectory, config, extraBuilderConfig, configFilePath, restart } = options;
|
|
7
|
+
const configFileMeta = config._privateMeta;
|
|
7
8
|
const isProd = false;
|
|
8
9
|
const pluginDriver = await PluginDriver.create(config, configFilePath, isProd);
|
|
9
10
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
@@ -17,7 +18,11 @@ async function dev(options) {
|
|
|
17
18
|
await pluginDriver.routeGenerated(routeService.getRoutes());
|
|
18
19
|
await pluginDriver.routeServiceGenerated(routeService);
|
|
19
20
|
await pluginDriver.beforeBuild();
|
|
20
|
-
const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, false,
|
|
21
|
+
const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, false, {
|
|
22
|
+
configFileMeta,
|
|
23
|
+
extraRsbuildConfig: extraBuilderConfig,
|
|
24
|
+
restart
|
|
25
|
+
});
|
|
21
26
|
rsbuild.onAfterDevCompile(async ()=>{
|
|
22
27
|
await pluginDriver.afterBuild();
|
|
23
28
|
});
|
package/dist/node/eject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __webpack_require__ } from "../
|
|
2
|
-
import "../4538.js";
|
|
3
|
-
import { node_path, logger, promises } from "../
|
|
1
|
+
import { __webpack_require__ } from "../rslib-runtime~0.js";
|
|
2
|
+
import "../4538~0.js";
|
|
3
|
+
import { node_path, logger, promises } from "../2711~0.js";
|
|
4
4
|
import { EJECTED_THEME } from "./constants.js";
|
|
5
5
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
|
|
1
|
+
import type { RestartFn, RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import { type UserConfig } from '@rspress/shared';
|
|
3
3
|
import type { PluginDriver } from './PluginDriver.js';
|
|
4
4
|
import type { RouteService } from './route/RouteService.js';
|
|
5
|
-
export declare function initRsbuild(rootDir: string, config: UserConfig, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean,
|
|
5
|
+
export declare function initRsbuild(rootDir: string, config: UserConfig, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean, options?: {
|
|
6
|
+
configFileMeta?: RsbuildConfig['_privateMeta'];
|
|
7
|
+
extraRsbuildConfig?: RsbuildConfig;
|
|
8
|
+
restart?: RestartFn;
|
|
9
|
+
}): Promise<RsbuildInstance>;
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../
|
|
1
|
+
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../2711~0.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
|
-
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
3
|
+
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
4
4
|
import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
|
|
5
5
|
import { RouteChunkAssetsPlugin } from "./route/routeChunkAssets.js";
|
|
6
6
|
import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
|
|
@@ -16,7 +16,7 @@ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
|
|
|
16
16
|
import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
|
|
17
17
|
import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
|
|
18
18
|
import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
|
|
19
|
-
import { package_namespaceObject } from "../
|
|
19
|
+
import { package_namespaceObject } from "../8472~0.js";
|
|
20
20
|
function isPluginIncluded(config, pluginName) {
|
|
21
21
|
return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
|
|
22
22
|
}
|
|
@@ -37,12 +37,13 @@ async function getVirtualModulesFromPlugins(pluginDriver) {
|
|
|
37
37
|
});
|
|
38
38
|
return runtimeModule;
|
|
39
39
|
}
|
|
40
|
-
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
|
|
40
|
+
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, restart) {
|
|
41
41
|
const CUSTOM_THEME_DIR = node_path.isAbsolute(config.themeDir) ? config.themeDir : node_path.join(external_node_process_cwd(), config.themeDir);
|
|
42
42
|
const outDir = config?.outDir ?? OUTPUT_DIR;
|
|
43
43
|
const base = config?.base ?? '/';
|
|
44
44
|
const enableLlmsUI = isLlmsUIEnabled(config);
|
|
45
45
|
const enableLlmsHint = isLlmsHintEnabled(config, enableSSG);
|
|
46
|
+
const localeRedirectScript = getInlineLocaleRedirectScript(config);
|
|
46
47
|
const assetPrefix = isProduction() ? addTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '/';
|
|
47
48
|
const routeChunkAssets = new RouteChunkAssetsPlugin(routeService);
|
|
48
49
|
const normalizeIcon = (icon)=>{
|
|
@@ -114,15 +115,36 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
114
115
|
},
|
|
115
116
|
dev: {
|
|
116
117
|
lazyCompilation: 'false' !== process.env.RSPRESS_LAZY_COMPILATION,
|
|
117
|
-
cliShortcuts:
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
cliShortcuts: true,
|
|
119
|
+
...restart ? {
|
|
120
|
+
watchFiles: {
|
|
121
|
+
paths: userDocRoot,
|
|
122
|
+
type: 'restart',
|
|
123
|
+
events: [
|
|
124
|
+
'add',
|
|
125
|
+
'unlink'
|
|
126
|
+
],
|
|
127
|
+
options: {
|
|
128
|
+
ignored: [
|
|
129
|
+
'**/node_modules/**',
|
|
130
|
+
'**/.git/**',
|
|
131
|
+
'**/.DS_Store/**',
|
|
132
|
+
node_path.join(userDocRoot, "public")
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} : {}
|
|
120
137
|
},
|
|
121
138
|
html: {
|
|
122
139
|
title: config?.title ?? DEFAULT_TITLE,
|
|
123
140
|
favicon: normalizeIcon(config?.icon),
|
|
124
141
|
template: TEMPLATE_PATH,
|
|
125
142
|
tags: [
|
|
143
|
+
localeRedirectScript ? {
|
|
144
|
+
tag: "script",
|
|
145
|
+
children: localeRedirectScript,
|
|
146
|
+
append: false
|
|
147
|
+
} : null,
|
|
126
148
|
'force-light' !== normalizeDarkMode(config.themeConfig?.darkMode) ? {
|
|
127
149
|
tag: "script",
|
|
128
150
|
children: getInlineThemeScript(config.themeConfig?.darkMode),
|
|
@@ -164,7 +186,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
164
186
|
PACKAGE_ROOT
|
|
165
187
|
],
|
|
166
188
|
define: {
|
|
167
|
-
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
168
189
|
'import.meta.env.ENABLE_LLMS_UI': JSON.stringify(enableLlmsUI),
|
|
169
190
|
'import.meta.env.ENABLE_LLMS_HINT': JSON.stringify(enableLlmsHint)
|
|
170
191
|
}
|
|
@@ -176,7 +197,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
176
197
|
...'false' !== process.env.RSPRESS_PERSISTENT_CACHE ? {
|
|
177
198
|
buildCache: {
|
|
178
199
|
buildDependencies: [
|
|
179
|
-
|
|
200
|
+
fileURLToPath(import.meta.url),
|
|
180
201
|
pluginDriver.getConfigFilePath()
|
|
181
202
|
],
|
|
182
203
|
cacheDigest: [
|
|
@@ -220,7 +241,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
220
241
|
chain.module.rule('mdx').test(MDX_OR_MD_REGEXP).resolve.merge({
|
|
221
242
|
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
222
243
|
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
223
|
-
}).end().oneOf('mdx-raw').type('asset/source').resourceQuery(RAW_QUERY_REGEXP).end().oneOf('mdx').type("javascript/auto").use('builtin:swc-loader').loader('builtin:swc-loader').options(swcLoaderOptions).end().use('mdx-loader').loader(fileURLToPath(
|
|
244
|
+
}).end().oneOf('mdx-raw').type('asset/source').resourceQuery(RAW_QUERY_REGEXP).end().oneOf('mdx').type("javascript/auto").use('builtin:swc-loader').loader('builtin:swc-loader').options(swcLoaderOptions).end().use('mdx-loader').loader(node_path.join(node_path.dirname(fileURLToPath(import.meta.url)), 'mdx/loader.js')).options({
|
|
224
245
|
config,
|
|
225
246
|
docDirectory: userDocRoot,
|
|
226
247
|
routeService,
|
|
@@ -355,14 +376,17 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
355
376
|
}
|
|
356
377
|
};
|
|
357
378
|
}
|
|
358
|
-
async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG,
|
|
379
|
+
async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG, options = {}) {
|
|
359
380
|
const userDocRoot = node_path.resolve(rootDir || config.root);
|
|
360
381
|
hintBuilderPluginsBreakingChange(config);
|
|
361
382
|
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
362
|
-
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver);
|
|
383
|
+
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, options.restart);
|
|
384
|
+
const rsbuildConfig = mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config.builderConfig || {}, options.extraRsbuildConfig || {});
|
|
385
|
+
if (options.configFileMeta) rsbuildConfig._privateMeta = options.configFileMeta;
|
|
363
386
|
const rsbuild = await createRsbuild({
|
|
364
387
|
callerName: 'rspress',
|
|
365
|
-
|
|
388
|
+
restart: options.restart,
|
|
389
|
+
rsbuildConfig
|
|
366
390
|
});
|
|
367
391
|
return rsbuild;
|
|
368
392
|
}
|
|
@@ -1,33 +1,130 @@
|
|
|
1
|
-
import { execa } from "../../0
|
|
1
|
+
import { node_path, execa } from "../../864~0.js";
|
|
2
|
+
import { slash } from "../utils/normalizePath.js";
|
|
2
3
|
function transform(timestamp, lang) {
|
|
3
4
|
return new Date(timestamp).toLocaleString(lang || 'zh');
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
const COMMIT_FORMAT = '--pretty=format:%x00%at%x00%an%x00%ae';
|
|
7
|
+
const ESCAPES = {
|
|
8
|
+
a: '\x07',
|
|
9
|
+
b: '\b',
|
|
10
|
+
t: '\t',
|
|
11
|
+
n: '\n',
|
|
12
|
+
v: '\v',
|
|
13
|
+
f: '\f',
|
|
14
|
+
r: '\r',
|
|
15
|
+
'"': '"',
|
|
16
|
+
'\\': '\\'
|
|
17
|
+
};
|
|
18
|
+
function unquotePath(filePath) {
|
|
19
|
+
if (!filePath.startsWith('"')) return filePath;
|
|
20
|
+
return filePath.slice(1, -1).replace(/\\([0-7]{3}|.)/g, (_, escaped)=>3 === escaped.length ? String.fromCharCode(Number.parseInt(escaped, 8)) : ESCAPES[escaped] ?? escaped);
|
|
21
|
+
}
|
|
22
|
+
function getCommonDir(filePaths) {
|
|
23
|
+
let common = node_path.dirname(filePaths[0]).split(node_path.sep);
|
|
24
|
+
for (const filePath of filePaths.slice(1)){
|
|
25
|
+
const segments = node_path.dirname(filePath).split(node_path.sep);
|
|
26
|
+
let i = 0;
|
|
27
|
+
while(i < common.length && i < segments.length && common[i] === segments[i])i++;
|
|
28
|
+
common = common.slice(0, i);
|
|
29
|
+
}
|
|
30
|
+
return common.length > 1 ? common.join(node_path.sep) : node_path.parse(filePaths[0]).root;
|
|
31
|
+
}
|
|
32
|
+
function getMostCommonParent(filePaths) {
|
|
33
|
+
const counts = new Map();
|
|
34
|
+
let best = '';
|
|
35
|
+
let bestCount = 0;
|
|
36
|
+
for (const filePath of filePaths){
|
|
37
|
+
const dir = node_path.dirname(filePath);
|
|
38
|
+
const count = (counts.get(dir) ?? 0) + 1;
|
|
39
|
+
counts.set(dir, count);
|
|
40
|
+
if (count > bestCount) {
|
|
41
|
+
best = dir;
|
|
42
|
+
bestCount = count;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return best;
|
|
46
|
+
}
|
|
47
|
+
async function getRepoPrefix(dir) {
|
|
6
48
|
try {
|
|
7
49
|
const { stdout } = await execa('git', [
|
|
50
|
+
'rev-parse',
|
|
51
|
+
'--show-prefix'
|
|
52
|
+
], {
|
|
53
|
+
cwd: dir
|
|
54
|
+
});
|
|
55
|
+
return stdout.trim();
|
|
56
|
+
} catch {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function stripPrefix(dir, prefix) {
|
|
61
|
+
let root = dir;
|
|
62
|
+
for(let i = prefix.split('/').filter(Boolean).length; i > 0; i--)root = node_path.dirname(root);
|
|
63
|
+
return root;
|
|
64
|
+
}
|
|
65
|
+
async function collectGitInfo(dir) {
|
|
66
|
+
const infoByPath = new Map();
|
|
67
|
+
let stdout;
|
|
68
|
+
try {
|
|
69
|
+
({ stdout } = await execa('git', [
|
|
70
|
+
'-c',
|
|
71
|
+
'core.quotePath=false',
|
|
8
72
|
'log',
|
|
9
|
-
|
|
10
|
-
'--
|
|
73
|
+
COMMIT_FORMAT,
|
|
74
|
+
'--name-only',
|
|
75
|
+
'--cc',
|
|
76
|
+
'--no-renames',
|
|
11
77
|
'--',
|
|
12
|
-
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
78
|
+
'.'
|
|
79
|
+
], {
|
|
80
|
+
cwd: dir
|
|
81
|
+
}));
|
|
82
|
+
} catch {
|
|
83
|
+
return infoByPath;
|
|
84
|
+
}
|
|
85
|
+
let commit;
|
|
86
|
+
for (const line of stdout.split('\n')){
|
|
87
|
+
if (line.startsWith('\0')) {
|
|
88
|
+
const [, at, an = '', ae = ''] = line.split('\0');
|
|
89
|
+
commit = {
|
|
90
|
+
timestamp: 1000 * Number(at),
|
|
91
|
+
authorName: an,
|
|
92
|
+
authorEmail: ae
|
|
93
|
+
};
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (!line || !commit) continue;
|
|
97
|
+
const filePath = unquotePath(line);
|
|
98
|
+
if (!infoByPath.has(filePath)) infoByPath.set(filePath, commit);
|
|
99
|
+
}
|
|
100
|
+
return infoByPath;
|
|
101
|
+
}
|
|
102
|
+
async function createLookup(filePaths) {
|
|
103
|
+
if (!filePaths.length) return ()=>void 0;
|
|
104
|
+
let dir = getCommonDir(filePaths);
|
|
105
|
+
let prefix = await getRepoPrefix(dir);
|
|
106
|
+
if (void 0 === prefix) {
|
|
107
|
+
const candidate = getMostCommonParent(filePaths);
|
|
108
|
+
const candidatePrefix = await getRepoPrefix(candidate);
|
|
109
|
+
if (void 0 === candidatePrefix) return ()=>void 0;
|
|
110
|
+
dir = stripPrefix(candidate, candidatePrefix);
|
|
111
|
+
prefix = '';
|
|
23
112
|
}
|
|
113
|
+
const repoPrefix = prefix;
|
|
114
|
+
const scope = dir;
|
|
115
|
+
const infoByPath = await collectGitInfo(dir);
|
|
116
|
+
return (filePath)=>infoByPath.get(repoPrefix + slash(node_path.relative(scope, filePath)));
|
|
24
117
|
}
|
|
25
118
|
function pluginLastUpdated(authorOption = false) {
|
|
119
|
+
let lookup;
|
|
26
120
|
return {
|
|
27
121
|
name: '@rspress/plugin-last-updated',
|
|
122
|
+
routeGenerated (routes) {
|
|
123
|
+
lookup = createLookup(routes.map((route)=>route.absolutePath));
|
|
124
|
+
},
|
|
28
125
|
async extendPageData (pageData) {
|
|
29
126
|
const { _filepath, lang } = pageData;
|
|
30
|
-
const info = await
|
|
127
|
+
const info = (await lookup)?.(_filepath);
|
|
31
128
|
if (!info) return;
|
|
32
129
|
pageData.lastUpdatedTime = transform(info.timestamp, lang);
|
|
33
130
|
if (false === authorOption) return;
|
package/dist/node/logger/hint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __webpack_require__ } from "../../
|
|
2
|
-
import { relative, logger, join, readFile } from "../../4538.js";
|
|
1
|
+
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
2
|
+
import { relative, logger, join, readFile } from "../../4538~0.js";
|
|
3
3
|
import { pathExists } from "../utils/fs.js";
|
|
4
4
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
5
5
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
package/dist/node/mdx/options.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../9940.js";
|
|
1
|
+
import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../9940~0.js";
|
|
2
2
|
import { remarkToc } from "./remarkPlugins/toc.js";
|
|
3
3
|
import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
|
|
4
4
|
import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
|
|
@@ -55,7 +55,8 @@ async function createMDXOptions(options) {
|
|
|
55
55
|
checkAnchors: false,
|
|
56
56
|
autoPrefix: true
|
|
57
57
|
},
|
|
58
|
-
__base: config?.base
|
|
58
|
+
__base: config?.base,
|
|
59
|
+
__siteOrigin: config?.siteOrigin
|
|
59
60
|
} : {
|
|
60
61
|
cleanUrls: false,
|
|
61
62
|
root: docDirectory,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../9940.js";
|
|
1
|
+
import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../9940~0.js";
|
|
2
2
|
import { createMDXOptions } from "./options.js";
|
|
3
3
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
4
4
|
import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../../9940.js";
|
|
1
|
+
import { visit } from "../../../9940~0.js";
|
|
2
2
|
const rehypeCodeMeta = ()=>(tree)=>{
|
|
3
3
|
visit(tree, 'element', (node)=>{
|
|
4
4
|
if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../9940.js";
|
|
1
|
+
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../9940~0.js";
|
|
2
2
|
const rehypeHeaderAnchor = ()=>{
|
|
3
3
|
const slugger = new github_slugger();
|
|
4
4
|
return (tree)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../9940.js";
|
|
1
|
+
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../9940~0.js";
|
|
2
2
|
const cssVariablesTheme = createCssVariablesTheme({
|
|
3
3
|
name: 'css-variables',
|
|
4
4
|
variablePrefix: '--shiki-',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path } from "../../../9940.js";
|
|
1
|
+
import { node_path } from "../../../9940~0.js";
|
|
2
2
|
import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
|
|
3
3
|
const remarkBuiltin = ({ globalComponents })=>(tree)=>{
|
|
4
4
|
const demos = globalComponents.map((componentPath)=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __webpack_require__ } from "../../../
|
|
2
|
-
import "../../../4538.js";
|
|
3
|
-
import { visit, node_path, logger, cwd, readFile } from "../../../5357.js";
|
|
1
|
+
import { __webpack_require__ } from "../../../rslib-runtime~0.js";
|
|
2
|
+
import "../../../4538~0.js";
|
|
3
|
+
import { visit, node_path, logger, cwd, readFile } from "../../../5357~0.js";
|
|
4
4
|
import { createError } from "../../utils/error.js";
|
|
5
5
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __webpack_require__ } from "../../../
|
|
2
|
-
import "../../../4538.js";
|
|
3
|
-
import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../5357.js";
|
|
1
|
+
import { __webpack_require__ } from "../../../rslib-runtime~0.js";
|
|
2
|
+
import "../../../4538~0.js";
|
|
3
|
+
import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../5357~0.js";
|
|
4
4
|
import { createError } from "../../utils/error.js";
|
|
5
5
|
import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
|
|
6
6
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -7,10 +7,11 @@ import type { RouteService } from '../../route/RouteService.js';
|
|
|
7
7
|
* 1. add version and lang prefix to the link
|
|
8
8
|
* 2. checkDeadLinks
|
|
9
9
|
*/
|
|
10
|
-
export declare const remarkLink: ({ cleanUrls, routeService, remarkLinkOptions, lint, __base, }: {
|
|
10
|
+
export declare const remarkLink: ({ cleanUrls, routeService, remarkLinkOptions, lint, __base, __siteOrigin, }: {
|
|
11
11
|
cleanUrls: boolean | string;
|
|
12
12
|
routeService: RouteService | null;
|
|
13
13
|
remarkLinkOptions?: MarkdownOptions['link'];
|
|
14
14
|
lint?: boolean;
|
|
15
15
|
__base?: string;
|
|
16
|
+
__siteOrigin?: string;
|
|
16
17
|
}) => (tree: Root, file: VFile) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __webpack_require__ } from "../../../
|
|
2
|
-
import "../../../4538.js";
|
|
3
|
-
import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, MDX_OR_MD_REGEXP, withBase } from "../../../5357.js";
|
|
1
|
+
import { __webpack_require__ } from "../../../rslib-runtime~0.js";
|
|
2
|
+
import "../../../4538~0.js";
|
|
3
|
+
import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withSiteOrigin, MDX_OR_MD_REGEXP, withBase } from "../../../5357~0.js";
|
|
4
4
|
import { hintRelativeMarkdownLink } from "../../logger/hint.js";
|
|
5
5
|
import { createError } from "../../utils/error.js";
|
|
6
6
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -99,7 +99,7 @@ function looseMarkdownLink(url, routeService, filePath) {
|
|
|
99
99
|
}
|
|
100
100
|
return url;
|
|
101
101
|
}
|
|
102
|
-
function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, deadLinks, __base) {
|
|
102
|
+
function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, deadLinks, __base, __siteOrigin) {
|
|
103
103
|
if (!nodeUrl) return {
|
|
104
104
|
url: ''
|
|
105
105
|
};
|
|
@@ -148,25 +148,26 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, d
|
|
|
148
148
|
if (search) url += `?${search}`;
|
|
149
149
|
if (hash) url += `#${hash}`;
|
|
150
150
|
if (__base) url = withBase(url, __base);
|
|
151
|
+
if (__siteOrigin) url = withSiteOrigin(url, __siteOrigin);
|
|
151
152
|
return {
|
|
152
153
|
url,
|
|
153
154
|
routePath,
|
|
154
155
|
hash
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
|
-
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base })=>(tree, file)=>{
|
|
158
|
+
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base, __siteOrigin })=>(tree, file)=>{
|
|
158
159
|
const { checkAnchors: shouldCheckAnchors = false, checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
|
|
159
160
|
const deadLinks = new Map();
|
|
160
161
|
const anchorLinks = new Map();
|
|
161
162
|
visit(tree, 'link', (node)=>{
|
|
162
163
|
const { url: nodeUrl } = node;
|
|
163
|
-
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
|
|
164
|
+
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base, __siteOrigin);
|
|
164
165
|
if (link.hash) anchorLinks.set(nodeUrl, link);
|
|
165
166
|
node.url = link.url;
|
|
166
167
|
});
|
|
167
168
|
visit(tree, 'definition', (node)=>{
|
|
168
169
|
const { url: nodeUrl } = node;
|
|
169
|
-
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
|
|
170
|
+
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base, __siteOrigin);
|
|
170
171
|
if (link.hash) anchorLinks.set(nodeUrl, link);
|
|
171
172
|
node.url = link.url;
|
|
172
173
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visitChildren, extractTextAndId, github_slugger, slug } from "../../../7748.js";
|
|
1
|
+
import { visitChildren, extractTextAndId, github_slugger, slug } from "../../../7748~0.js";
|
|
2
2
|
const extractChildText = (child, preserveInlineMarkdown = true)=>{
|
|
3
3
|
if ('link' === child.type) return child.children?.map((child)=>extractChildText(child, preserveInlineMarkdown)).join('') ?? '';
|
|
4
4
|
if ('strong' === child.type) {
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { node_path } from "../../
|
|
1
|
+
import { node_path } from "../../2711~0.js";
|
|
2
2
|
import { RouteService } from "./RouteService.js";
|
|
3
3
|
import { normalizePath, slash } from "../utils/normalizePath.js";
|
|
4
4
|
import { getPageKey } from "../utils/getPageKey.js";
|
|
5
5
|
class RoutePage {
|
|
6
6
|
routeMeta;
|
|
7
|
-
#docDir;
|
|
8
7
|
pageIndexInfo;
|
|
9
8
|
setPageIndexInfo(info) {
|
|
10
9
|
this.pageIndexInfo = info;
|
|
11
10
|
}
|
|
12
11
|
static create(absolutePath, docsDir) {
|
|
13
12
|
const routeMeta = absolutePathToRouteMeta(absolutePath, docsDir, RouteService.getInstance());
|
|
14
|
-
return new RoutePage(routeMeta
|
|
13
|
+
return new RoutePage(routeMeta);
|
|
15
14
|
}
|
|
16
15
|
static createFromExternal(routePath, filepath, docDir) {
|
|
17
16
|
const routeMeta = RoutePage.generateRouteMeta(routePath, filepath, docDir);
|
|
18
|
-
return new RoutePage(routeMeta
|
|
17
|
+
return new RoutePage(routeMeta);
|
|
19
18
|
}
|
|
20
|
-
constructor(routeMeta
|
|
19
|
+
constructor(routeMeta){
|
|
21
20
|
this.routeMeta = routeMeta;
|
|
22
|
-
this.#docDir = docDir;
|
|
23
21
|
}
|
|
24
22
|
static generateRouteMeta(routePath, filepath, docDir) {
|
|
25
23
|
const routeService = RouteService.getInstance();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../
|
|
1
|
+
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../2711~0.js";
|
|
2
2
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
3
3
|
import { createError } from "../utils/error.js";
|
|
4
4
|
import { getRouteChunkName } from "./routeChunkAssets.js";
|