@rspress/core 2.0.19 → 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/{6305~0.js → 2711~0.js} +1 -1
- package/dist/5357~0.js +1 -1
- package/dist/8472~0.js +2 -2
- package/dist/864~0.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/loadConfigFile.js +2 -3
- package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +1 -1
- package/dist/eject-theme/components/Llms/LlmsHint.tsx +10 -6
- package/dist/eject-theme/components/Nav/hooks.tsx +1 -2
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +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 +2 -3
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +3 -3
- package/dist/node/last-updated/index.js +2 -2
- package/dist/node/mdx/options.js +2 -1
- package/dist/node/mdx/remarkPlugins/link.d.ts +2 -1
- package/dist/node/mdx/remarkPlugins/link.js +6 -5
- 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 +1 -1
- package/dist/node/route/normalizeRoutePath.js +2 -3
- package/dist/node/runtimeModule/i18n.js +1 -1
- 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/renderPages.js +2 -2
- 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/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- 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/flattenMdxContent.js +2 -2
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/csrClientEntry.js +7 -2
- 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/Llms/LlmsHint.js +6 -2
- package/dist/theme/components/Nav/hooks.js +1 -2
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/SwitchAppearance/global.css +3 -16
- 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/package.json +13 -13
|
@@ -2809,7 +2809,7 @@ function isDynamicPattern(pattern, options) {
|
|
|
2809
2809
|
return scan.isGlob || scan.negated;
|
|
2810
2810
|
}
|
|
2811
2811
|
function log(...tasks) {
|
|
2812
|
-
console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
2812
|
+
console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
|
|
2813
2813
|
}
|
|
2814
2814
|
function ensureStringArray(value) {
|
|
2815
2815
|
return "string" == typeof value ? [
|
package/dist/5357~0.js
CHANGED
|
@@ -4,5 +4,5 @@ export { cwd } from "node:process";
|
|
|
4
4
|
export { logger } from "@rspress/shared/logger";
|
|
5
5
|
export { visit } from "unist-util-visit";
|
|
6
6
|
export { existsSync } from "node:fs";
|
|
7
|
-
export { MDX_OR_MD_REGEXP, addLeadingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase } from "@rspress/shared";
|
|
7
|
+
export { MDX_OR_MD_REGEXP, addLeadingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase, withSiteOrigin } from "@rspress/shared";
|
|
8
8
|
export { getNodeAttribute } from "@rspress/shared/node-utils";
|
package/dist/8472~0.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var package_namespaceObject = {
|
|
2
|
-
rE: "2.0.
|
|
2
|
+
rE: "2.0.20"
|
|
3
3
|
};
|
|
4
4
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
5
5
|
return new Promise((resolve_, reject_)=>{
|
|
6
6
|
if (void 0 === iterable[Symbol.iterator] && void 0 === iterable[Symbol.asyncIterator]) throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
7
7
|
if ('function' != typeof mapper) throw new TypeError('Mapper function is required');
|
|
8
|
-
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 ||
|
|
8
|
+
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || 1 / 0 === concurrency)) throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
9
9
|
const result = [];
|
|
10
10
|
const errors = [];
|
|
11
11
|
const skippedIndexesMap = new Map();
|
package/dist/864~0.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
|
8
8
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
9
9
|
import { debuglog } from "node:util";
|
|
10
10
|
import { __webpack_require__ } from "./rslib-runtime~0.js";
|
|
11
|
-
import "./
|
|
11
|
+
import "./2711~0.js";
|
|
12
12
|
__webpack_require__.add({
|
|
13
13
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
14
14
|
const cp = __webpack_require__("child_process");
|
package/dist/cli/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../
|
|
1
|
+
import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../2711~0.js";
|
|
2
2
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
3
3
|
async function loadConfigFile(customConfigFile) {
|
|
4
4
|
const baseDir = process.cwd();
|
|
5
|
-
|
|
6
|
-
configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
|
|
5
|
+
const configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
|
|
7
6
|
if (!configFilePath) {
|
|
8
7
|
logger.info(`No config file found in ${baseDir}`);
|
|
9
8
|
return {
|
|
@@ -64,7 +64,7 @@ describe('LlmsHint', () => {
|
|
|
64
64
|
setSsgMd(true);
|
|
65
65
|
|
|
66
66
|
expect(await renderToMarkdownString(<LlmsHint />)).toBe(
|
|
67
|
-
'> For AI agents: the complete documentation index is available at https://example.com/docs/llms.txt, the full documentation bundle is available at https://example.com/docs/llms-full.txt
|
|
67
|
+
'> For AI agents: the complete documentation index is available at https://example.com/docs/llms.txt, the full documentation bundle is available at https://example.com/docs/llms-full.txt.\n\n',
|
|
68
68
|
);
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -27,9 +27,12 @@ function createLlmsHintText({
|
|
|
27
27
|
}: {
|
|
28
28
|
llmsTxtUrl: string;
|
|
29
29
|
llmsFullTxtUrl: string;
|
|
30
|
-
pageMdUrl
|
|
30
|
+
pageMdUrl?: string;
|
|
31
31
|
}) {
|
|
32
|
-
|
|
32
|
+
const text = `For AI agents: the complete documentation index is available at ${llmsTxtUrl}, the full documentation bundle is available at ${llmsFullTxtUrl}`;
|
|
33
|
+
return pageMdUrl
|
|
34
|
+
? `${text}, and this page is available as Markdown at ${pageMdUrl}.`
|
|
35
|
+
: `${text}.`;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
export function LlmsHint() {
|
|
@@ -51,6 +54,11 @@ export function LlmsHint() {
|
|
|
51
54
|
const llmsFullTxtUrl = withSiteOrigin(
|
|
52
55
|
withBase(`/${versionPrefix}${langPrefix}llms-full.txt`),
|
|
53
56
|
);
|
|
57
|
+
|
|
58
|
+
if (import.meta.env.SSG_MD) {
|
|
59
|
+
return `> ${createLlmsHintText({ llmsTxtUrl, llmsFullTxtUrl })}\n\n`;
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
const pageMdUrl = withSiteOrigin(routePathToMdPath(page.routePath));
|
|
55
63
|
const hintText = createLlmsHintText({
|
|
56
64
|
llmsTxtUrl,
|
|
@@ -58,10 +66,6 @@ export function LlmsHint() {
|
|
|
58
66
|
pageMdUrl,
|
|
59
67
|
});
|
|
60
68
|
|
|
61
|
-
if (import.meta.env.SSG_MD) {
|
|
62
|
-
return `> ${hintText}\n\n`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
69
|
return (
|
|
66
70
|
<div className="rp-llms-hint" style={visuallyHiddenStyle}>
|
|
67
71
|
{hintText}
|
|
@@ -32,7 +32,6 @@ function replaceLang(
|
|
|
32
32
|
|
|
33
33
|
let versionPart = '';
|
|
34
34
|
let langPart = '';
|
|
35
|
-
let purePathPart = '';
|
|
36
35
|
|
|
37
36
|
const parts = url.split('/').filter(Boolean);
|
|
38
37
|
|
|
@@ -51,7 +50,7 @@ function replaceLang(
|
|
|
51
50
|
parts.shift();
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
purePathPart = parts.join('/') || '';
|
|
53
|
+
let purePathPart = parts.join('/') || '';
|
|
55
54
|
|
|
56
55
|
if ((versionPart || langPart) && !purePathPart) {
|
|
57
56
|
purePathPart = cleanUrls ? 'index' : 'index.html';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, node_path, addLeadingSlash } from "../
|
|
1
|
+
import { addTrailingSlash, node_path, addLeadingSlash } from "../2711~0.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
|
|
4
4
|
class PluginDriver {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../
|
|
1
|
+
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2711~0.js";
|
|
2
2
|
import { processLocales, combineWalkResult } from "./locales.js";
|
|
3
3
|
import { walk } from "./walk.js";
|
|
4
4
|
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../4538~0.js";
|
|
3
|
-
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../
|
|
3
|
+
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2711~0.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
5
5
|
import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
|
|
6
6
|
import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
|
|
@@ -75,8 +75,7 @@ async function detectFilePath(absolutePath, extensions) {
|
|
|
75
75
|
throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}The file extension "${ext}" is not supported, please use one of the following extensions: ${extensions.join(', ')}`);
|
|
76
76
|
}
|
|
77
77
|
async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensions, mdFileSet) {
|
|
78
|
-
|
|
79
|
-
metaItem = 'string' == typeof metaItemRaw ? {
|
|
78
|
+
const metaItem = 'string' == typeof metaItemRaw ? {
|
|
80
79
|
name: metaItemRaw,
|
|
81
80
|
type: 'file'
|
|
82
81
|
} : metaItemRaw;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../
|
|
1
|
+
import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2711~0.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
3
|
async function pathExists(path) {
|
|
4
4
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, node_path, promises } from "../../
|
|
1
|
+
import { isExternalUrl, node_path, promises } from "../../2711~0.js";
|
|
2
2
|
import { pathExists } from "../utils/fs.js";
|
|
3
3
|
import { readJson } from "./utils.js";
|
|
4
4
|
import { addRoutePrefix } from "../route/RoutePage.js";
|
package/dist/node/constants.js
CHANGED
|
@@ -38,7 +38,7 @@ const getInlineLocaleRedirectScript = (config)=>{
|
|
|
38
38
|
].filter(Boolean).join(', ');
|
|
39
39
|
const replaceLocationScript = `
|
|
40
40
|
var newPathname = '/' + newPathSegments.join('/'), trailingSlash = newPathname !== '/' && ${routePathname}.endsWith('/') ? '/' : ''
|
|
41
|
-
window.location
|
|
41
|
+
window.location['replace'](${base ? 'base + ' : ''}newPathname + trailingSlash + search)`;
|
|
42
42
|
const redirectScript = 'only-default-lang' === localeRedirect ? `if (currentLang === defaultLang && langs.includes(targetLang) && targetLang !== defaultLang) {
|
|
43
43
|
var newPathSegments = pathSegments.slice()
|
|
44
44
|
newPathSegments.splice(${langIndex}, 0, targetLang)
|
package/dist/node/eject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../rslib-runtime~0.js";
|
|
2
2
|
import "../4538~0.js";
|
|
3
|
-
import { node_path, logger, promises } from "../
|
|
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);
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
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";
|
|
@@ -197,7 +197,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
197
197
|
...'false' !== process.env.RSPRESS_PERSISTENT_CACHE ? {
|
|
198
198
|
buildCache: {
|
|
199
199
|
buildDependencies: [
|
|
200
|
-
|
|
200
|
+
fileURLToPath(import.meta.url),
|
|
201
201
|
pluginDriver.getConfigFilePath()
|
|
202
202
|
],
|
|
203
203
|
cacheDigest: [
|
|
@@ -241,7 +241,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
241
241
|
chain.module.rule('mdx').test(MDX_OR_MD_REGEXP).resolve.merge({
|
|
242
242
|
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
243
243
|
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
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(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({
|
|
245
245
|
config,
|
|
246
246
|
docDirectory: userDocRoot,
|
|
247
247
|
routeService,
|
|
@@ -53,7 +53,7 @@ async function getRepoPrefix(dir) {
|
|
|
53
53
|
cwd: dir
|
|
54
54
|
});
|
|
55
55
|
return stdout.trim();
|
|
56
|
-
} catch
|
|
56
|
+
} catch {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -79,7 +79,7 @@ async function collectGitInfo(dir) {
|
|
|
79
79
|
], {
|
|
80
80
|
cwd: dir
|
|
81
81
|
}));
|
|
82
|
-
} catch
|
|
82
|
+
} catch {
|
|
83
83
|
return infoByPath;
|
|
84
84
|
}
|
|
85
85
|
let commit;
|
package/dist/node/mdx/options.js
CHANGED
|
@@ -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
1
|
import { __webpack_require__ } from "../../../rslib-runtime~0.js";
|
|
2
2
|
import "../../../4538~0.js";
|
|
3
|
-
import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, MDX_OR_MD_REGEXP, withBase } from "../../../5357~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,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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path, promises, loadFrontMatter, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../2711~0.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../2711~0.js";
|
|
2
2
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
3
3
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
4
4
|
return [
|
|
@@ -11,7 +11,6 @@ const splitRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
|
11
11
|
const hasTrailSlash = relativePath.endsWith('/');
|
|
12
12
|
let versionPart = '';
|
|
13
13
|
let langPart = '';
|
|
14
|
-
let purePathPart = '';
|
|
15
14
|
const parts = relativePath.split('/').filter(Boolean);
|
|
16
15
|
if (version) {
|
|
17
16
|
const versionToMatch = parts[0];
|
|
@@ -21,7 +20,7 @@ const splitRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
|
21
20
|
const langToMatch = parts[0];
|
|
22
21
|
if (langs.includes(langToMatch)) langPart = parts.shift() ?? '';
|
|
23
22
|
}
|
|
24
|
-
purePathPart = parts.join('/');
|
|
23
|
+
const purePathPart = parts.join('/');
|
|
25
24
|
return [
|
|
26
25
|
versionPart,
|
|
27
26
|
langPart,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../4538~0.js";
|
|
3
|
-
import { createRequire, join, logger } from "../../
|
|
3
|
+
import { createRequire, join, logger } from "../../2711~0.js";
|
|
4
4
|
import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
|
|
5
5
|
import { createError } from "../utils/error.js";
|
|
6
6
|
import { pathExists } from "../utils/fs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../2711~0.js";
|
|
2
2
|
import { extractPageData } from "../../route/extractPageData.js";
|
|
3
3
|
import { createHash } from "../../utils/createHash.js";
|
|
4
4
|
function deletePrivateField(obj) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, pluginVirtualModule } from "../../../
|
|
1
|
+
import { logger, pluginVirtualModule } from "../../../2711~0.js";
|
|
2
2
|
import { createPageData } from "./createPageData.js";
|
|
3
3
|
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
4
4
|
const ref = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../2711~0.js";
|
|
2
2
|
import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
|
|
3
3
|
async function createSiteData(userConfig) {
|
|
4
4
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../
|
|
1
|
+
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../2711~0.js";
|
|
2
2
|
import { getI18nData } from "../i18n.js";
|
|
3
3
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
4
|
async function normalizeThemeConfig(docConfig) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProduction, logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../2711~0.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|
package/dist/node/serve.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../
|
|
1
|
+
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../2711~0.js";
|
|
2
2
|
function createAlternateLinksByRoute(routes, config) {
|
|
3
3
|
const routeGroups = new Map();
|
|
4
4
|
for (const route of routes){
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! LICENSE: renderPages.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
3
3
|
import "../../4538~0.js";
|
|
4
|
-
import {
|
|
4
|
+
import { node_path, fileURLToPath, logger, chunk } from "../../2711~0.js";
|
|
5
5
|
import { createAlternateLinksByRoute } from "./alternateLinks.js";
|
|
6
6
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
7
7
|
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
@@ -48,7 +48,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
48
48
|
logger.info(`Rendering pages with experimental SSG worker (${picocolors_default().yellow(numberOfThreads)} threads)...`);
|
|
49
49
|
const Tinypool = await import("../../tinypool~0.js").then((m)=>m.default);
|
|
50
50
|
const pool = new Tinypool({
|
|
51
|
-
filename:
|
|
51
|
+
filename: node_path.join(node_path.dirname(fileURLToPath(import.meta.url)), 'renderPageWorker.js'),
|
|
52
52
|
concurrentTasksPerWorker: 1,
|
|
53
53
|
minThreads: numberOfThreads,
|
|
54
54
|
maxThreads: numberOfThreads,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../2711~0.js";
|
|
2
2
|
import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
const rsbuildPluginSSG = ({ routeService, config, routeChunkAssets })=>({
|
package/dist/node/ssg/ssgEnv.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! LICENSE: ssgEnv.js.LICENSE.txt */
|
|
2
|
-
import { node_os } from "../../
|
|
2
|
+
import { node_os } from "../../2711~0.js";
|
|
3
3
|
/**
|
|
4
4
|
* these codes are copied from
|
|
5
5
|
* @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { matchPath, getSidebarDataGroup } from "../../../
|
|
1
|
+
import { matchPath, getSidebarDataGroup } from "../../../2711~0.js";
|
|
2
2
|
import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
|
|
3
3
|
async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
4
4
|
const base = config.base ?? '/';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../
|
|
1
|
+
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../2711~0.js";
|
|
2
2
|
import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
|
|
3
3
|
function routePathToMdPath(routePath, base, siteOrigin) {
|
|
4
4
|
let url = routePath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../4538~0.js";
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../2711~0.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.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
1
|
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../4538~0.js";
|
|
3
|
-
import { logger } from "../../
|
|
3
|
+
import { logger } from "../../2711~0.js";
|
|
4
4
|
import { pMap } from "../../8472~0.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { writeFile, mkdir, rm, join, isDebugMode } from "../../2711~0.js";
|
|
2
2
|
import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash as external_node_crypto_createHash } from "../../
|
|
1
|
+
import { createHash as external_node_crypto_createHash } from "../../2711~0.js";
|
|
2
2
|
function createHash(str, length = 8) {
|
|
3
3
|
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../
|
|
1
|
+
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../2711~0.js";
|
|
2
2
|
import { createError } from "./error.js";
|
|
3
3
|
import { importStatementRegex } from "../constants.js";
|
|
4
4
|
const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
|
|
@@ -53,7 +53,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
53
53
|
let absoluteImportPath;
|
|
54
54
|
try {
|
|
55
55
|
absoluteImportPath = await resolveDepPath(importPath, node_path.dirname(basePath), alias);
|
|
56
|
-
} catch
|
|
56
|
+
} catch {
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
if (MDX_OR_MD_REGEXP.test(absoluteImportPath)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../4538~0.js";
|
|
3
|
-
import { node_path, core_rspack, logger } from "../../
|
|
3
|
+
import { node_path, core_rspack, logger } from "../../2711~0.js";
|
|
4
4
|
import { pathExists, readJson } from "./fs.js";
|
|
5
5
|
import { PACKAGE_ROOT } from "../constants.js";
|
|
6
6
|
import { hintReactVersion } from "../logger/hint.js";
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
3
|
import { ClientApp } from "./ClientApp.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { redirectToCleanUrl } from "./route.js";
|
|
5
|
+
function renderInBrowser() {
|
|
6
|
+
redirectToCleanUrl(window.location, window.history);
|
|
7
|
+
const container = document.getElementById('__rspress_root');
|
|
8
|
+
createRoot(container).render(/*#__PURE__*/ jsx(ClientApp, {}));
|
|
9
|
+
}
|
|
10
|
+
renderInBrowser();
|
package/dist/runtime/route.d.ts
CHANGED
|
@@ -20,6 +20,16 @@ export declare function matchPath(pattern: string, pathname: string): {
|
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
22
|
export declare function pathnameToRouteService(pathname: string): Route | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Redirects a pathname to the matching route's canonical URL with the History
|
|
25
|
+
* API.
|
|
26
|
+
*
|
|
27
|
+
* The URL format follows the `cleanUrls` setting. Query strings, hashes, and
|
|
28
|
+
* history state are preserved.
|
|
29
|
+
*
|
|
30
|
+
* @returns Whether the URL was updated.
|
|
31
|
+
*/
|
|
32
|
+
export declare function redirectToCleanUrl(location: Pick<Location, 'hash' | 'pathname' | 'search'>, history: Pick<History, 'replaceState' | 'state'>): boolean;
|
|
23
33
|
/**
|
|
24
34
|
* link: /api/config
|
|
25
35
|
* currentPathname:
|
package/dist/runtime/route.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { cleanUrl } from "@rspress/shared";
|
|
1
|
+
import { cleanUrl, normalizeHref } from "@rspress/shared";
|
|
2
2
|
import { routes } from "virtual-routes";
|
|
3
3
|
import virtual_site_data from "virtual-site-data";
|
|
4
|
+
import { removeBase, removeTrailingSlash } from "./utils.js";
|
|
4
5
|
function normalizeRoutePath(routePath) {
|
|
5
6
|
return cleanUrl(decodeURIComponent(routePath)).replace(/\.html$/, '').replace(/\/index$/, '/').toLowerCase();
|
|
6
7
|
}
|
|
@@ -43,6 +44,16 @@ function pathnameToRouteService(pathname) {
|
|
|
43
44
|
if (route) cache.set(normalizedPathname, route);
|
|
44
45
|
return route;
|
|
45
46
|
}
|
|
47
|
+
function redirectToCleanUrl(location, history) {
|
|
48
|
+
if (virtual_site_data.route?.cleanUrlsRedirect === false) return false;
|
|
49
|
+
const matchedRoute = pathnameToRouteService(removeBase(location.pathname));
|
|
50
|
+
if (!matchedRoute) return false;
|
|
51
|
+
const canonicalRoutePath = normalizeHref(matchedRoute.path, Boolean(virtual_site_data.route?.cleanUrls));
|
|
52
|
+
const canonicalPathname = `${removeTrailingSlash(virtual_site_data.base)}${canonicalRoutePath}`;
|
|
53
|
+
if (location.pathname === canonicalPathname) return false;
|
|
54
|
+
history.replaceState(history.state, '', `${canonicalPathname}${location.search}${location.hash}`);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
46
57
|
function isActive(itemLink, currentPathname) {
|
|
47
58
|
const linkMatched = matchPath(itemLink, currentPathname);
|
|
48
59
|
return null !== linkMatched;
|
|
@@ -52,4 +63,4 @@ const preloadLink = (link)=>{
|
|
|
52
63
|
const route = pathnameToRouteService(link);
|
|
53
64
|
if (route) route.preload();
|
|
54
65
|
};
|
|
55
|
-
export { isActive, matchPath, pathnameToRouteService, preloadLink };
|
|
66
|
+
export { isActive, matchPath, pathnameToRouteService, preloadLink, redirectToCleanUrl };
|
|
@@ -4,7 +4,9 @@ import { startTransition } from "react";
|
|
|
4
4
|
import { hydrateRoot } from "react-dom/client";
|
|
5
5
|
import { ClientApp } from "./ClientApp.js";
|
|
6
6
|
import { initPageData, setCurrentPageData } from "./initPageData.js";
|
|
7
|
+
import { redirectToCleanUrl } from "./route.js";
|
|
7
8
|
async function renderInBrowser() {
|
|
9
|
+
redirectToCleanUrl(window.location, window.history);
|
|
8
10
|
const container = document.getElementById('__rspress_root');
|
|
9
11
|
const pathname = removeBase(window.location.pathname);
|
|
10
12
|
const initialPageData = await initPageData(pathname);
|
|
@@ -13,7 +13,8 @@ const visuallyHiddenStyle = {
|
|
|
13
13
|
border: 0
|
|
14
14
|
};
|
|
15
15
|
function createLlmsHintText({ llmsTxtUrl, llmsFullTxtUrl, pageMdUrl }) {
|
|
16
|
-
|
|
16
|
+
const text = `For AI agents: the complete documentation index is available at ${llmsTxtUrl}, the full documentation bundle is available at ${llmsFullTxtUrl}`;
|
|
17
|
+
return pageMdUrl ? `${text}, and this page is available as Markdown at ${pageMdUrl}.` : `${text}.`;
|
|
17
18
|
}
|
|
18
19
|
function LlmsHint() {
|
|
19
20
|
const { page } = usePage();
|
|
@@ -24,13 +25,16 @@ function LlmsHint() {
|
|
|
24
25
|
const langPrefix = page.lang === site.lang ? '' : `${page.lang}/`;
|
|
25
26
|
const llmsTxtUrl = withSiteOrigin(withBase(`/${versionPrefix}${langPrefix}llms.txt`));
|
|
26
27
|
const llmsFullTxtUrl = withSiteOrigin(withBase(`/${versionPrefix}${langPrefix}llms-full.txt`));
|
|
28
|
+
if (import.meta.env.SSG_MD) return `> ${createLlmsHintText({
|
|
29
|
+
llmsTxtUrl,
|
|
30
|
+
llmsFullTxtUrl
|
|
31
|
+
})}\n\n`;
|
|
27
32
|
const pageMdUrl = withSiteOrigin(routePathToMdPath(page.routePath));
|
|
28
33
|
const hintText = createLlmsHintText({
|
|
29
34
|
llmsTxtUrl,
|
|
30
35
|
llmsFullTxtUrl,
|
|
31
36
|
pageMdUrl
|
|
32
37
|
});
|
|
33
|
-
if (import.meta.env.SSG_MD) return `> ${hintText}\n\n`;
|
|
34
38
|
return /*#__PURE__*/ jsx("div", {
|
|
35
39
|
className: "rp-llms-hint",
|
|
36
40
|
style: visuallyHiddenStyle,
|
|
@@ -5,14 +5,13 @@ function replaceLang(rawUrl, lang, version, cleanUrls, isPageNotFound) {
|
|
|
5
5
|
url = normalizeHrefInRuntime(url);
|
|
6
6
|
let versionPart = '';
|
|
7
7
|
let langPart = '';
|
|
8
|
-
let purePathPart = '';
|
|
9
8
|
const parts = url.split('/').filter(Boolean);
|
|
10
9
|
if (version.current && version.current !== version.default) versionPart = parts.shift() || '';
|
|
11
10
|
if (lang.target !== lang.default) {
|
|
12
11
|
langPart = lang.target;
|
|
13
12
|
if (lang.current !== lang.default) parts.shift();
|
|
14
13
|
} else parts.shift();
|
|
15
|
-
purePathPart = parts.join('/') || '';
|
|
14
|
+
let purePathPart = parts.join('/') || '';
|
|
16
15
|
if ((versionPart || langPart) && !purePathPart) purePathPart = cleanUrls ? 'index' : 'index.html';
|
|
17
16
|
return addLeadingSlash([
|
|
18
17
|
versionPart,
|
|
@@ -7,7 +7,7 @@ const cjkRegex = /[\u3131-\u314e|\u314f-\u3163|\uac00-\ud7a3]|[\u4E00-\u9FCC\u34
|
|
|
7
7
|
const cyrillicRegex = /[\u0400-\u04FF]/g;
|
|
8
8
|
function tokenize(str, regex) {
|
|
9
9
|
const words = [];
|
|
10
|
-
let m
|
|
10
|
+
let m;
|
|
11
11
|
do {
|
|
12
12
|
m = regex.exec(str);
|
|
13
13
|
if (m) words.push(m[0]);
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
::view-transition-old(root) {
|
|
1
|
+
::view-transition-old(root), ::view-transition-new(root) {
|
|
2
2
|
mix-blend-mode: normal;
|
|
3
3
|
animation: none;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
::view-transition-new(root) {
|
|
7
|
-
mix-blend-mode: normal;
|
|
8
|
-
animation: none;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
::view-transition-old(root) {
|
|
12
|
-
z-index: 1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.dark::view-transition-new(root) {
|
|
6
|
+
::view-transition-old(root), .dark::view-transition-new(root) {
|
|
16
7
|
z-index: 1;
|
|
17
8
|
}
|
|
18
9
|
|
|
19
|
-
::view-transition-new(root) {
|
|
20
|
-
z-index: 9999;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.dark::view-transition-old(root) {
|
|
10
|
+
::view-transition-new(root), .dark::view-transition-old(root) {
|
|
24
11
|
z-index: 9999;
|
|
25
12
|
}
|
|
26
13
|
|
|
@@ -23,6 +23,10 @@ export declare function renderInlineMarkdown(text: string): {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
+
* Parse a header text to plain text, which can be used in attributes like `title`. Both the inline markdown syntax and
|
|
27
|
+
* the HTML are stripped, because a header is markdown when it comes from the remark toc plugin, and HTML when it is
|
|
28
|
+
* collected from the DOM by `useDynamicToc`, carrying the markup of the components rendered in the heading.
|
|
29
|
+
* @param mdx The header text to parse, either markdown or HTML.
|
|
26
30
|
* @internal
|
|
27
31
|
* @private
|
|
28
32
|
*/
|
|
@@ -20,11 +20,32 @@ const CODE_TEXT_PATTERN = /`(.*?)`/g;
|
|
|
20
20
|
const STRONG_TEXT_PATTERN = /\*{2}(?!\*)(.*?)\*{2}(?!\*)/g;
|
|
21
21
|
const EMPHASIS_TEXT_PATTERN = /\*(?!\*)(.*?)\*(?!\*)/g;
|
|
22
22
|
const DELETE_TEXT_PATTERN = /~{2}(.*?)~{2}/g;
|
|
23
|
+
const INLINE_CODE_PATTERN = /`[^`]+`/g;
|
|
24
|
+
const HTML_TAG_PATTERN = /<\/?[a-z][^>]*>/gi;
|
|
25
|
+
const HTML_ENTITY_PATTERN = /&(#\d+|#x[0-9a-f]+|[a-z][0-9a-z]*);/gi;
|
|
26
|
+
const NAMED_HTML_ENTITIES = {
|
|
27
|
+
amp: '&',
|
|
28
|
+
apos: "'",
|
|
29
|
+
gt: '>',
|
|
30
|
+
lt: '<',
|
|
31
|
+
nbsp: '\u00A0',
|
|
32
|
+
quot: '"'
|
|
33
|
+
};
|
|
34
|
+
function decodeHtmlEntities(text) {
|
|
35
|
+
return text.replace(HTML_ENTITY_PATTERN, (match, entity)=>{
|
|
36
|
+
if (!entity.startsWith('#')) return NAMED_HTML_ENTITIES[entity.toLowerCase()] ?? match;
|
|
37
|
+
const isHex = 'x' === entity[1] || 'X' === entity[1];
|
|
38
|
+
const codePoint = Number.parseInt(isHex ? entity.slice(2) : entity.slice(1), isHex ? 16 : 10);
|
|
39
|
+
const isScalarValue = codePoint <= 0x10ffff && !(codePoint >= 0xd800 && codePoint <= 0xdfff);
|
|
40
|
+
return isScalarValue ? String.fromCodePoint(codePoint) : match;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
23
43
|
function renderInlineMarkdown(text) {
|
|
24
|
-
const htmlText = text.replace(
|
|
44
|
+
const htmlText = text.replace(INLINE_CODE_PATTERN, (match)=>match.replace(/</g, '<')).replace(STRONG_TEXT_PATTERN, '<strong>$1</strong>').replace(EMPHASIS_TEXT_PATTERN, '<em>$1</em>').replace(DELETE_TEXT_PATTERN, '<del>$1</del>').replace(CODE_TEXT_PATTERN, '<code>$1</code>');
|
|
25
45
|
return renderHtmlOrText(htmlText);
|
|
26
46
|
}
|
|
27
47
|
function parseInlineMarkdownText(mdx) {
|
|
28
|
-
|
|
48
|
+
const plainText = mdx.replace(INLINE_CODE_PATTERN, (match)=>match.replace(/</g, '<')).replace(STRONG_TEXT_PATTERN, '$1').replace(EMPHASIS_TEXT_PATTERN, '$1').replace(DELETE_TEXT_PATTERN, '$1').replace(CODE_TEXT_PATTERN, '$1').replace(HTML_TAG_PATTERN, '');
|
|
49
|
+
return decodeHtmlEntities(plainText).trim();
|
|
29
50
|
}
|
|
30
51
|
export { parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown };
|
|
@@ -27,7 +27,6 @@ hr {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
abbr:where([title]) {
|
|
30
|
-
-webkit-text-decoration: underline dotted;
|
|
31
30
|
text-decoration: underline dotted;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -38,7 +37,6 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
38
37
|
|
|
39
38
|
a {
|
|
40
39
|
color: inherit;
|
|
41
|
-
-webkit-text-decoration: inherit;
|
|
42
40
|
text-decoration: inherit;
|
|
43
41
|
}
|
|
44
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.20",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@mdx-js/mdx": "^3.1.1",
|
|
62
62
|
"@mdx-js/react": "^3.1.1",
|
|
63
|
-
"@rsbuild/core": "^2.1.
|
|
63
|
+
"@rsbuild/core": "^2.1.13",
|
|
64
64
|
"@rsbuild/plugin-react": "~2.1.0",
|
|
65
65
|
"@shikijs/rehype": "^4.2.0",
|
|
66
66
|
"@types/mdast": "^4.0.4",
|
|
67
|
-
"@types/react": "^19.2.
|
|
68
|
-
"@unhead/react": "^2.1.
|
|
67
|
+
"@types/react": "^19.2.18",
|
|
68
|
+
"@unhead/react": "^2.1.17",
|
|
69
69
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
70
70
|
"clsx": "2.1.1",
|
|
71
71
|
"copy-to-clipboard": "^3.3.3",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react-dom": "^19.2.8",
|
|
81
81
|
"react-lazy-with-preload": "^2.2.1",
|
|
82
82
|
"react-render-to-markdown": "19.1.0",
|
|
83
|
-
"react-router-dom": "^7.18.
|
|
83
|
+
"react-router-dom": "^7.18.2",
|
|
84
84
|
"rehype-external-links": "^3.0.0",
|
|
85
85
|
"rehype-raw": "^7.0.0",
|
|
86
86
|
"remark-cjk-friendly": "^2.3.1",
|
|
@@ -95,27 +95,27 @@
|
|
|
95
95
|
"unist-util-visit": "^5.1.0",
|
|
96
96
|
"unist-util-visit-children": "^3.0.0",
|
|
97
97
|
"vfile": "^6.0.3",
|
|
98
|
-
"@rspress/shared": "2.0.
|
|
98
|
+
"@rspress/shared": "2.0.20"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@microsoft/api-extractor": "^7.
|
|
102
|
-
"@rsbuild/plugin-sass": "~
|
|
101
|
+
"@microsoft/api-extractor": "^7.59.0",
|
|
102
|
+
"@rsbuild/plugin-sass": "~2.0.1",
|
|
103
103
|
"@rsbuild/plugin-svgr": "^2.0.5",
|
|
104
|
-
"@rslib/core": "1.0.0-
|
|
104
|
+
"@rslib/core": "1.0.0-rc.0",
|
|
105
105
|
"@types/body-scroll-lock": "^3.1.2",
|
|
106
106
|
"@types/hast": "^3.0.5",
|
|
107
107
|
"@types/node": "^22.8.1",
|
|
108
108
|
"@types/nprogress": "^0.2.3",
|
|
109
|
-
"@types/react-dom": "^19.2.
|
|
110
|
-
"@types/web": "^0.0.
|
|
109
|
+
"@types/react-dom": "^19.2.4",
|
|
110
|
+
"@types/web": "^0.0.354",
|
|
111
111
|
"cac": "^7.0.0",
|
|
112
112
|
"execa": "8.0.1",
|
|
113
113
|
"mdast-util-directive": "^3.1.0",
|
|
114
114
|
"mdast-util-mdx-expression": "^2.0.1",
|
|
115
|
-
"memfs": "^4.
|
|
115
|
+
"memfs": "^4.68.1",
|
|
116
116
|
"p-map": "^7.0.6",
|
|
117
117
|
"picocolors": "^1.1.1",
|
|
118
|
-
"postcss": "8.5.
|
|
118
|
+
"postcss": "8.5.26",
|
|
119
119
|
"remark-directive": "^4.0.0",
|
|
120
120
|
"rsbuild-plugin-publint": "^1.0.0",
|
|
121
121
|
"rsbuild-plugin-virtual-module": "0.4.5",
|