@rspress/core 1.40.3-cannary-20250126 → 1.41.1
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.js +122 -60
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +9 -8
- package/dist/loader.js.map +1 -1
- package/package.json +14 -16
- package/loader.cjs +0 -8
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var require_package = __commonJS({
|
|
|
66
66
|
"package.json"(exports, module) {
|
|
67
67
|
module.exports = {
|
|
68
68
|
name: "@rspress/core",
|
|
69
|
-
version: "1.
|
|
69
|
+
version: "1.41.1",
|
|
70
70
|
description: "The Rspress Documentation Framework",
|
|
71
71
|
bugs: "https://github.com/web-infra-dev/rspress/issues",
|
|
72
72
|
repository: {
|
|
@@ -110,9 +110,7 @@ var require_package = __commonJS({
|
|
|
110
110
|
"src/shared",
|
|
111
111
|
"index.html",
|
|
112
112
|
"runtime.ts",
|
|
113
|
-
"theme.ts"
|
|
114
|
-
"loader.cjs",
|
|
115
|
-
"compiled"
|
|
113
|
+
"theme.ts"
|
|
116
114
|
],
|
|
117
115
|
scripts: {
|
|
118
116
|
build: "modern build",
|
|
@@ -124,7 +122,7 @@ var require_package = __commonJS({
|
|
|
124
122
|
"@mdx-js/loader": "2.3.0",
|
|
125
123
|
"@mdx-js/mdx": "2.3.0",
|
|
126
124
|
"@mdx-js/react": "2.3.0",
|
|
127
|
-
"@rsbuild/core": "1.2.
|
|
125
|
+
"@rsbuild/core": "1.2.3",
|
|
128
126
|
"@rsbuild/plugin-less": "~1.1.0",
|
|
129
127
|
"@rsbuild/plugin-react": "~1.1.0",
|
|
130
128
|
"@rsbuild/plugin-sass": "~1.2.0",
|
|
@@ -160,8 +158,8 @@ var require_package = __commonJS({
|
|
|
160
158
|
"unist-util-visit-children": "^3.0.0"
|
|
161
159
|
},
|
|
162
160
|
devDependencies: {
|
|
163
|
-
"@modern-js/plugin-tailwindcss": "2.
|
|
164
|
-
"@modern-js/tsconfig": "2.
|
|
161
|
+
"@modern-js/plugin-tailwindcss": "2.64.0",
|
|
162
|
+
"@modern-js/tsconfig": "2.64.0",
|
|
165
163
|
"@types/hast": "3.0.4",
|
|
166
164
|
"@types/html-to-text": "^9.0.4",
|
|
167
165
|
"@types/jest": "~29.5.14",
|
|
@@ -170,14 +168,14 @@ var require_package = __commonJS({
|
|
|
170
168
|
"@types/node": "^18.11.17",
|
|
171
169
|
"@types/react": "^18.3.18",
|
|
172
170
|
"@types/react-dom": "^18.3.5",
|
|
173
|
-
postcss: "8.
|
|
171
|
+
postcss: "8.5.1",
|
|
174
172
|
"rehype-stringify": "^9.0.4",
|
|
175
173
|
"remark-parse": "^10.0.2",
|
|
176
174
|
"remark-rehype": "^10.1.0",
|
|
177
175
|
rimraf: "^3.0.2",
|
|
178
176
|
tailwindcss: "^3.4.17",
|
|
179
177
|
typescript: "^5.5.3",
|
|
180
|
-
vitest: "2.1.
|
|
178
|
+
vitest: "2.1.9"
|
|
181
179
|
},
|
|
182
180
|
engines: {
|
|
183
181
|
node: ">=14.17.6"
|
|
@@ -227,10 +225,7 @@ var PluginDriver = class {
|
|
|
227
225
|
}
|
|
228
226
|
this.addPlugin(pluginContainerSyntax());
|
|
229
227
|
if (isDevDebugMode()) {
|
|
230
|
-
const SourceBuildPlugin = await import(
|
|
231
|
-
// @ts-expect-error need moduleResolution: Node16, NodeNext or Bundler to get type declarations work
|
|
232
|
-
"@rspress/theme-default/node/source-build-plugin.js"
|
|
233
|
-
).then(
|
|
228
|
+
const SourceBuildPlugin = await import("@rspress/theme-default/node/source-build-plugin.js").then(
|
|
234
229
|
(r) => r.SourceBuildPlugin,
|
|
235
230
|
() => null
|
|
236
231
|
);
|
|
@@ -382,6 +377,7 @@ _plugins = new WeakMap();
|
|
|
382
377
|
_isProd = new WeakMap();
|
|
383
378
|
|
|
384
379
|
// src/node/initRsbuild.ts
|
|
380
|
+
import fs9 from "fs/promises";
|
|
385
381
|
import path11 from "path";
|
|
386
382
|
import { PLUGIN_LESS_NAME, pluginLess } from "@rsbuild/plugin-less";
|
|
387
383
|
import { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
|
|
@@ -393,7 +389,6 @@ import {
|
|
|
393
389
|
removeLeadingSlash as removeLeadingSlash2,
|
|
394
390
|
removeTrailingSlash
|
|
395
391
|
} from "@rspress/shared";
|
|
396
|
-
import fs8 from "@rspress/shared/fs-extra";
|
|
397
392
|
|
|
398
393
|
// src/node/constants.ts
|
|
399
394
|
import path from "path";
|
|
@@ -437,13 +432,13 @@ var TEMP_DIR = path.join(
|
|
|
437
432
|
);
|
|
438
433
|
|
|
439
434
|
// src/node/route/RouteService.ts
|
|
435
|
+
import fs4 from "fs/promises";
|
|
440
436
|
import path5 from "path";
|
|
441
437
|
import {
|
|
442
438
|
addLeadingSlash,
|
|
443
439
|
addTrailingSlash,
|
|
444
440
|
withBase
|
|
445
441
|
} from "@rspress/shared";
|
|
446
|
-
import fs3 from "@rspress/shared/fs-extra";
|
|
447
442
|
import { glob } from "tinyglobby";
|
|
448
443
|
|
|
449
444
|
// src/node/utils/normalizePath.ts
|
|
@@ -471,18 +466,37 @@ function createHash(str) {
|
|
|
471
466
|
}
|
|
472
467
|
|
|
473
468
|
// src/node/utils/detectReactVersion.ts
|
|
469
|
+
import fs2 from "fs";
|
|
474
470
|
import path3 from "path";
|
|
475
|
-
import fs from "@rspress/shared/fs-extra";
|
|
476
471
|
import { logger } from "@rspress/shared/logger";
|
|
477
472
|
import enhancedResolve from "enhanced-resolve";
|
|
473
|
+
|
|
474
|
+
// src/node/utils/fs.ts
|
|
475
|
+
import fs from "fs/promises";
|
|
476
|
+
async function pathExists(path13) {
|
|
477
|
+
try {
|
|
478
|
+
await fs.access(path13);
|
|
479
|
+
return true;
|
|
480
|
+
} catch {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
async function readJson(path13) {
|
|
485
|
+
const raw = await fs.readFile(path13, "utf8");
|
|
486
|
+
return JSON.parse(raw);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/node/utils/detectReactVersion.ts
|
|
478
490
|
var { CachedInputFileSystem, ResolverFactory } = enhancedResolve;
|
|
479
491
|
var DEFAULT_REACT_VERSION = 18;
|
|
480
492
|
async function detectReactVersion() {
|
|
481
493
|
const cwd = process.cwd();
|
|
482
494
|
const reactPath = path3.join(cwd, "node_modules", "react");
|
|
483
|
-
if (await
|
|
484
|
-
const reactPkg = await
|
|
485
|
-
|
|
495
|
+
if (await pathExists(reactPath)) {
|
|
496
|
+
const reactPkg = await readJson(
|
|
497
|
+
path3.join(reactPath, "package.json")
|
|
498
|
+
);
|
|
499
|
+
const version = Number(reactPkg.version?.split(".")[0]);
|
|
486
500
|
return version;
|
|
487
501
|
}
|
|
488
502
|
return DEFAULT_REACT_VERSION;
|
|
@@ -501,7 +515,7 @@ async function resolveReactAlias(reactVersion, isSSR) {
|
|
|
501
515
|
}
|
|
502
516
|
const alias = {};
|
|
503
517
|
const resolver2 = ResolverFactory.createResolver({
|
|
504
|
-
fileSystem: new CachedInputFileSystem(
|
|
518
|
+
fileSystem: new CachedInputFileSystem(fs2, 0),
|
|
505
519
|
extensions: [".js"],
|
|
506
520
|
alias,
|
|
507
521
|
conditionNames: isSSR ? ["..."] : ["browser", "..."]
|
|
@@ -533,10 +547,10 @@ async function resolveReactAlias(reactVersion, isSSR) {
|
|
|
533
547
|
}
|
|
534
548
|
|
|
535
549
|
// src/node/utils/flattenMdxContent.ts
|
|
550
|
+
import fs3 from "fs";
|
|
536
551
|
import path4 from "path";
|
|
537
552
|
import { createProcessor } from "@mdx-js/mdx";
|
|
538
553
|
import { MDX_REGEXP } from "@rspress/shared";
|
|
539
|
-
import fs2 from "@rspress/shared/fs-extra";
|
|
540
554
|
import enhancedResolve2 from "enhanced-resolve";
|
|
541
555
|
var resolver;
|
|
542
556
|
var startFlatten = false;
|
|
@@ -545,7 +559,7 @@ var { CachedInputFileSystem: CachedInputFileSystem2, ResolverFactory: ResolverFa
|
|
|
545
559
|
async function resolveDepPath(importPath, importer, alias) {
|
|
546
560
|
if (!resolver) {
|
|
547
561
|
resolver = ResolverFactory2.createResolver({
|
|
548
|
-
fileSystem: new CachedInputFileSystem2(
|
|
562
|
+
fileSystem: new CachedInputFileSystem2(fs3, 0),
|
|
549
563
|
extensions: [".mdx", ".md"],
|
|
550
564
|
alias
|
|
551
565
|
});
|
|
@@ -583,7 +597,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
583
597
|
}
|
|
584
598
|
if (!startFlatten) {
|
|
585
599
|
resolver = ResolverFactory2.createResolver({
|
|
586
|
-
fileSystem: new CachedInputFileSystem2(
|
|
600
|
+
fileSystem: new CachedInputFileSystem2(fs3, 0),
|
|
587
601
|
extensions: [".mdx", ".md", ".js"],
|
|
588
602
|
alias
|
|
589
603
|
});
|
|
@@ -611,7 +625,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
611
625
|
continue;
|
|
612
626
|
}
|
|
613
627
|
if (MDX_REGEXP.test(absoluteImportPath)) {
|
|
614
|
-
const importedContent =
|
|
628
|
+
const importedContent = fs3.readFileSync(absoluteImportPath, "utf-8");
|
|
615
629
|
const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
|
|
616
630
|
result = result.replace(
|
|
617
631
|
new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`),
|
|
@@ -711,7 +725,7 @@ var RouteService = class {
|
|
|
711
725
|
...__privateGet(this, _exclude),
|
|
712
726
|
"**/node_modules/**",
|
|
713
727
|
"**/.eslintrc.js",
|
|
714
|
-
"**/.nx
|
|
728
|
+
"**/.nx/**",
|
|
715
729
|
`./${PUBLIC_DIR}/**`
|
|
716
730
|
]
|
|
717
731
|
})).sort();
|
|
@@ -828,7 +842,7 @@ _pluginDriver = new WeakMap();
|
|
|
828
842
|
_writeTempFile = new WeakSet();
|
|
829
843
|
writeTempFile_fn = async function(index, content) {
|
|
830
844
|
const tempFilePath = path5.join(__privateGet(this, _tempDir), `temp-${index}.mdx`);
|
|
831
|
-
await
|
|
845
|
+
await fs4.writeFile(tempFilePath, content);
|
|
832
846
|
return tempFilePath;
|
|
833
847
|
};
|
|
834
848
|
_generateRouteInfo = new WeakSet();
|
|
@@ -866,15 +880,15 @@ async function initRouteService(options) {
|
|
|
866
880
|
import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
|
|
867
881
|
|
|
868
882
|
// src/node/runtimeModule/globalStyles.ts
|
|
869
|
-
import
|
|
883
|
+
import fs5 from "fs/promises";
|
|
870
884
|
async function globalStylesVMPlugin(context) {
|
|
871
885
|
const { config, pluginDriver } = context;
|
|
872
886
|
const globalStylesByPlugins = pluginDriver.globalStyles();
|
|
873
887
|
if (config.globalStyles) {
|
|
874
888
|
const source = config.globalStyles;
|
|
875
|
-
const styleContent = await
|
|
889
|
+
const styleContent = await fs5.readFile(source, "utf-8");
|
|
876
890
|
const patchedStyleContent = styleContent.replace(/--modern-/g, "--rp-").replace(/\.modern-doc/g, ".rspress").replace(/\.modern-/g, ".rspress-");
|
|
877
|
-
await
|
|
891
|
+
await fs5.writeFile(source, patchedStyleContent, "utf-8");
|
|
878
892
|
}
|
|
879
893
|
const moduleContent = (await Promise.all(
|
|
880
894
|
[config?.globalStyles || "", ...globalStylesByPlugins].filter((source) => source.length > 0).map(async (source) => {
|
|
@@ -969,18 +983,18 @@ async function searchHookVMPlugin(context) {
|
|
|
969
983
|
}
|
|
970
984
|
|
|
971
985
|
// src/node/runtimeModule/siteData/index.ts
|
|
986
|
+
import fs7 from "fs/promises";
|
|
972
987
|
import path8 from "path";
|
|
973
988
|
import { SEARCH_INDEX_NAME } from "@rspress/shared";
|
|
974
|
-
import fs6 from "@rspress/shared/fs-extra";
|
|
975
989
|
import { groupBy } from "lodash-es";
|
|
976
990
|
|
|
977
991
|
// src/node/runtimeModule/siteData/extractPageData.ts
|
|
992
|
+
import fs6 from "fs/promises";
|
|
978
993
|
import path7 from "path";
|
|
979
994
|
import { compile } from "@rspress/mdx-rs";
|
|
980
995
|
import {
|
|
981
996
|
MDX_REGEXP as MDX_REGEXP2
|
|
982
997
|
} from "@rspress/shared";
|
|
983
|
-
import fs5 from "@rspress/shared/fs-extra";
|
|
984
998
|
import { loadFrontMatter } from "@rspress/shared/node-utils";
|
|
985
999
|
import { htmlToText } from "html-to-text";
|
|
986
1000
|
function applyReplaceRulesToNestedObject(obj, replaceRules) {
|
|
@@ -993,7 +1007,7 @@ function applyReplaceRulesToNestedObject(obj, replaceRules) {
|
|
|
993
1007
|
}
|
|
994
1008
|
return obj;
|
|
995
1009
|
}
|
|
996
|
-
async function extractPageData(replaceRules, alias, domain, root, routeService2, highlighterLangs) {
|
|
1010
|
+
async function extractPageData(replaceRules, alias, domain, root, routeService2, highlighterLangs, searchCodeBlocks) {
|
|
997
1011
|
const pageData = await Promise.all(
|
|
998
1012
|
routeService2.getRoutes().map(async (route, index) => {
|
|
999
1013
|
const defaultIndexInfo = {
|
|
@@ -1013,7 +1027,7 @@ async function extractPageData(replaceRules, alias, domain, root, routeService2,
|
|
|
1013
1027
|
if (!MDX_REGEXP2.test(route.absolutePath)) {
|
|
1014
1028
|
return defaultIndexInfo;
|
|
1015
1029
|
}
|
|
1016
|
-
let content = await
|
|
1030
|
+
let content = await fs6.readFile(route.absolutePath, "utf8");
|
|
1017
1031
|
const { frontmatter, content: strippedFrontMatter } = loadFrontMatter(
|
|
1018
1032
|
content,
|
|
1019
1033
|
route.absolutePath,
|
|
@@ -1056,7 +1070,7 @@ async function extractPageData(replaceRules, alias, domain, root, routeService2,
|
|
|
1056
1070
|
{
|
|
1057
1071
|
// Skip code blocks
|
|
1058
1072
|
selector: "pre > code",
|
|
1059
|
-
format: "skip"
|
|
1073
|
+
format: searchCodeBlocks ? "block" : "skip"
|
|
1060
1074
|
},
|
|
1061
1075
|
...["h1", "h2", "h3", "h4", "h5", "h6"].map((tag) => ({
|
|
1062
1076
|
selector: tag,
|
|
@@ -1345,14 +1359,17 @@ async function siteDataVMPlugin(context) {
|
|
|
1345
1359
|
}
|
|
1346
1360
|
const highlightLanguages = /* @__PURE__ */ new Set();
|
|
1347
1361
|
const replaceRules = userConfig?.replaceRules || [];
|
|
1348
|
-
const
|
|
1362
|
+
const searchConfig = userConfig?.search || {};
|
|
1363
|
+
const domain = searchConfig?.mode === "remote" ? searchConfig.domain ?? "" : "";
|
|
1364
|
+
const searchCodeBlocks = "codeBlocks" in searchConfig ? searchConfig.codeBlocks : false;
|
|
1349
1365
|
const pages = await extractPageData(
|
|
1350
1366
|
replaceRules,
|
|
1351
1367
|
alias,
|
|
1352
1368
|
domain,
|
|
1353
1369
|
userDocRoot,
|
|
1354
1370
|
routeService2,
|
|
1355
|
-
highlightLanguages
|
|
1371
|
+
highlightLanguages,
|
|
1372
|
+
searchCodeBlocks
|
|
1356
1373
|
);
|
|
1357
1374
|
await pluginDriver.modifySearchIndexData(pages);
|
|
1358
1375
|
const versioned = userConfig.search && userConfig.search.mode !== "remote" && userConfig.search.versioned;
|
|
@@ -1376,8 +1393,8 @@ async function siteDataVMPlugin(context) {
|
|
|
1376
1393
|
const [version, lang] = group.split("###");
|
|
1377
1394
|
const indexVersion = version ? `.${version.replace(".", "_")}` : "";
|
|
1378
1395
|
const indexLang = lang ? `.${lang}` : "";
|
|
1379
|
-
await
|
|
1380
|
-
await
|
|
1396
|
+
await fs7.mkdir(TEMP_DIR, { recursive: true });
|
|
1397
|
+
await fs7.writeFile(
|
|
1381
1398
|
path8.join(
|
|
1382
1399
|
TEMP_DIR,
|
|
1383
1400
|
`${SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`
|
|
@@ -1520,18 +1537,21 @@ function rsbuildPluginDocVM(factoryContext) {
|
|
|
1520
1537
|
}
|
|
1521
1538
|
|
|
1522
1539
|
// src/node/searchIndex.ts
|
|
1540
|
+
import { createReadStream } from "fs";
|
|
1541
|
+
import fs8 from "fs/promises";
|
|
1523
1542
|
import path9, { join as join2 } from "path";
|
|
1524
1543
|
import { SEARCH_INDEX_NAME as SEARCH_INDEX_NAME2, isSCM } from "@rspress/shared";
|
|
1525
1544
|
import chalk2 from "@rspress/shared/chalk";
|
|
1526
|
-
import fs7 from "@rspress/shared/fs-extra";
|
|
1527
1545
|
import { logger as logger2 } from "@rspress/shared/logger";
|
|
1528
1546
|
async function writeSearchIndex(config) {
|
|
1529
1547
|
if (config?.search === false) {
|
|
1530
1548
|
return;
|
|
1531
1549
|
}
|
|
1532
1550
|
const cwd = process.cwd();
|
|
1533
|
-
const searchIndexFiles = await
|
|
1551
|
+
const searchIndexFiles = await fs8.readdir(TEMP_DIR);
|
|
1534
1552
|
const outDir = config?.outDir ?? join2(cwd, OUTPUT_DIR);
|
|
1553
|
+
const targetDir = join2(outDir, "static");
|
|
1554
|
+
await fs8.mkdir(targetDir, { recursive: true });
|
|
1535
1555
|
let searchIndexData = "[]";
|
|
1536
1556
|
let scanning = false;
|
|
1537
1557
|
for (const searchIndexFile of searchIndexFiles) {
|
|
@@ -1539,13 +1559,13 @@ async function writeSearchIndex(config) {
|
|
|
1539
1559
|
continue;
|
|
1540
1560
|
}
|
|
1541
1561
|
const source = join2(TEMP_DIR, searchIndexFile);
|
|
1542
|
-
const target = join2(
|
|
1543
|
-
const searchIndex = await
|
|
1562
|
+
const target = join2(targetDir, searchIndexFile);
|
|
1563
|
+
const searchIndex = await fs8.readFile(
|
|
1544
1564
|
join2(TEMP_DIR, searchIndexFile),
|
|
1545
1565
|
"utf-8"
|
|
1546
1566
|
);
|
|
1547
1567
|
searchIndexData = `${searchIndexData.slice(0, -1)}${scanning ? "," : ""}${searchIndex.slice(1)}`;
|
|
1548
|
-
await
|
|
1568
|
+
await fs8.rename(source, target);
|
|
1549
1569
|
scanning = true;
|
|
1550
1570
|
}
|
|
1551
1571
|
if (isProduction() && isSCM() && config?.search?.mode === "remote") {
|
|
@@ -1577,7 +1597,7 @@ function serveSearchIndexMiddleware(config) {
|
|
|
1577
1597
|
if (req.url?.includes(searchIndexRequestMatch)) {
|
|
1578
1598
|
res.setHeader("Content-Type", "application/json");
|
|
1579
1599
|
const searchIndexFile = req.url?.split("/").pop();
|
|
1580
|
-
|
|
1600
|
+
createReadStream(
|
|
1581
1601
|
path9.join(
|
|
1582
1602
|
process.cwd(),
|
|
1583
1603
|
config?.outDir || OUTPUT_DIR,
|
|
@@ -1612,6 +1632,41 @@ var detectCustomIcon = async (customThemeDir) => {
|
|
|
1612
1632
|
return alias;
|
|
1613
1633
|
};
|
|
1614
1634
|
|
|
1635
|
+
// src/node/utils/getSocialIcons.ts
|
|
1636
|
+
var presetIcons = {
|
|
1637
|
+
discord: `<path fill="currentColor" d="M20.317 4.37a19.8 19.8 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.3 18.3 0 0 0-5.487 0a13 13 0 0 0-.617-1.25a.08.08 0 0 0-.079-.037A19.7 19.7 0 0 0 3.677 4.37a.1.1 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.08.08 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.08.08 0 0 0 .084-.028a14 14 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13 13 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10 10 0 0 0 .372-.292a.07.07 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.07.07 0 0 1 .078.01q.181.149.373.292a.077.077 0 0 1-.006.127a12.3 12.3 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.08.08 0 0 0 .084.028a19.8 19.8 0 0 0 6.002-3.03a.08.08 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.06.06 0 0 0-.031-.03M8.02 15.33c-1.182 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418m7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418"/>`,
|
|
1638
|
+
facebook: `<path fill="currentColor" d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978c.401 0 .955.042 1.468.103a9 9 0 0 1 1.141.195v3.325a9 9 0 0 0-.653-.036a27 27 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.7 1.7 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103l-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647"/>`,
|
|
1639
|
+
github: `<path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/>`,
|
|
1640
|
+
gitlab: `<path fill="currentColor" d="m23.6 9.593l-.033-.086L20.3.98a.85.85 0 0 0-.336-.405a.875.875 0 0 0-1 .054a.9.9 0 0 0-.29.44L16.47 7.818H7.537L5.333 1.07a.86.86 0 0 0-.29-.441a.875.875 0 0 0-1-.054a.86.86 0 0 0-.336.405L.433 9.502l-.032.086a6.066 6.066 0 0 0 2.012 7.01l.01.009l.03.021l4.977 3.727l2.462 1.863l1.5 1.132a1.01 1.01 0 0 0 1.22 0l1.499-1.132l2.461-1.863l5.006-3.75l.013-.01a6.07 6.07 0 0 0 2.01-7.002"/>`,
|
|
1641
|
+
instagram: `<path fill="currentColor" d="M7.03.084c-1.277.06-2.149.264-2.91.563a5.9 5.9 0 0 0-2.124 1.388a5.9 5.9 0 0 0-1.38 2.127C.321 4.926.12 5.8.064 7.076s-.069 1.688-.063 4.947s.021 3.667.083 4.947c.061 1.277.264 2.149.563 2.911c.308.789.72 1.457 1.388 2.123a5.9 5.9 0 0 0 2.129 1.38c.763.295 1.636.496 2.913.552c1.278.056 1.689.069 4.947.063s3.668-.021 4.947-.082c1.28-.06 2.147-.265 2.91-.563a5.9 5.9 0 0 0 2.123-1.388a5.9 5.9 0 0 0 1.38-2.129c.295-.763.496-1.636.551-2.912c.056-1.28.07-1.69.063-4.948c-.006-3.258-.02-3.667-.081-4.947c-.06-1.28-.264-2.148-.564-2.911a5.9 5.9 0 0 0-1.387-2.123a5.9 5.9 0 0 0-2.128-1.38c-.764-.294-1.636-.496-2.914-.55C15.647.009 15.236-.006 11.977 0S8.31.021 7.03.084m.14 21.693c-1.17-.05-1.805-.245-2.228-.408a3.7 3.7 0 0 1-1.382-.895a3.7 3.7 0 0 1-.9-1.378c-.165-.423-.363-1.058-.417-2.228c-.06-1.264-.072-1.644-.08-4.848c-.006-3.204.006-3.583.061-4.848c.05-1.169.246-1.805.408-2.228c.216-.561.477-.96.895-1.382a3.7 3.7 0 0 1 1.379-.9c.423-.165 1.057-.361 2.227-.417c1.265-.06 1.644-.072 4.848-.08c3.203-.006 3.583.006 4.85.062c1.168.05 1.804.244 2.227.408c.56.216.96.475 1.382.895s.681.817.9 1.378c.165.422.362 1.056.417 2.227c.06 1.265.074 1.645.08 4.848c.005 3.203-.006 3.583-.061 4.848c-.051 1.17-.245 1.805-.408 2.23c-.216.56-.477.96-.896 1.38a3.7 3.7 0 0 1-1.378.9c-.422.165-1.058.362-2.226.418c-1.266.06-1.645.072-4.85.079s-3.582-.006-4.848-.06m9.783-16.192a1.44 1.44 0 1 0 1.437-1.442a1.44 1.44 0 0 0-1.437 1.442M5.839 12.012a6.161 6.161 0 1 0 12.323-.024a6.162 6.162 0 0 0-12.323.024M8 12.008A4 4 0 1 1 12.008 16A4 4 0 0 1 8 12.008"/>`,
|
|
1642
|
+
linkedin: `<path fill="currentColor" d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037c-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85c3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.06 2.06 0 0 1-2.063-2.065a2.064 2.064 0 1 1 2.063 2.065m1.782 13.019H3.555V9h3.564zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0z"/>`,
|
|
1643
|
+
slack: `<path fill="currentColor" d="M5.042 15.165a2.53 2.53 0 0 1-2.52 2.523A2.53 2.53 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52a2.527 2.527 0 0 1 2.521 2.52v6.313A2.53 2.53 0 0 1 8.834 24a2.53 2.53 0 0 1-2.521-2.522zM8.834 5.042a2.53 2.53 0 0 1-2.521-2.52A2.53 2.53 0 0 1 8.834 0a2.53 2.53 0 0 1 2.521 2.522v2.52zm0 1.271a2.53 2.53 0 0 1 2.521 2.521a2.53 2.53 0 0 1-2.521 2.521H2.522A2.53 2.53 0 0 1 0 8.834a2.53 2.53 0 0 1 2.522-2.521zm10.122 2.521a2.53 2.53 0 0 1 2.522-2.521A2.53 2.53 0 0 1 24 8.834a2.53 2.53 0 0 1-2.522 2.521h-2.522zm-1.268 0a2.53 2.53 0 0 1-2.523 2.521a2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.53 2.53 0 0 1 2.523 2.522zm-2.523 10.122a2.53 2.53 0 0 1 2.523 2.522A2.53 2.53 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522zm0-1.268a2.527 2.527 0 0 1-2.52-2.523a2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.53 2.53 0 0 1-2.522 2.523z"/>`,
|
|
1644
|
+
youtube: `<path fill="currentColor" d="M23.498 6.186a3.02 3.02 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.02 3.02 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.02 3.02 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.02 3.02 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814M9.545 15.568V8.432L15.818 12z"/>`,
|
|
1645
|
+
juejin: `<path fill="currentColor" d="m12 14.316l7.454-5.88l-2.022-1.625L12 11.1l-.004.003l-5.432-4.288l-2.02 1.624l7.452 5.88Zm0-7.247l2.89-2.298L12 2.453l-.004-.005l-2.884 2.318l2.884 2.3Zm0 11.266l-.005.002l-9.975-7.87L0 12.088l.194.156l11.803 9.308l7.463-5.885L24 12.085l-2.023-1.624Z"/>`,
|
|
1646
|
+
qq: `<path fill="currentColor" d="M21.395 15.035a40 40 0 0 0-.803-2.264l-1.079-2.695c.001-.032.014-.562.014-.836C19.526 4.632 17.351 0 12 0S4.474 4.632 4.474 9.241c0 .274.013.804.014.836l-1.08 2.695a39 39 0 0 0-.802 2.264c-1.021 3.283-.69 4.643-.438 4.673c.54.065 2.103-2.472 2.103-2.472c0 1.469.756 3.387 2.394 4.771c-.612.188-1.363.479-1.845.835c-.434.32-.379.646-.301.778c.343.578 5.883.369 7.482.189c1.6.18 7.14.389 7.483-.189c.078-.132.132-.458-.301-.778c-.483-.356-1.233-.646-1.846-.836c1.637-1.384 2.393-3.302 2.393-4.771c0 0 1.563 2.537 2.103 2.472c.251-.03.581-1.39-.438-4.673"/>`,
|
|
1647
|
+
wechat: `<path fill="currentColor" d="M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213c0 .163.13.295.29.295a.33.33 0 0 0 .167-.054l1.903-1.114a.86.86 0 0 1 .717-.098a10.2 10.2 0 0 0 2.837.403c.276 0 .543-.027.811-.05c-.857-2.578.157-4.972 1.932-6.446c1.703-1.415 3.882-1.98 5.853-1.838c-.576-3.583-4.196-6.348-8.596-6.348M5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178a1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18m5.34 2.867c-1.797-.052-3.746.512-5.28 1.786c-1.72 1.428-2.687 3.72-1.78 6.22c.942 2.453 3.666 4.229 6.884 4.229c.826 0 1.622-.12 2.361-.336a.72.72 0 0 1 .598.082l1.584.926a.3.3 0 0 0 .14.047c.134 0 .24-.111.24-.247c0-.06-.023-.12-.038-.177l-.327-1.233a.6.6 0 0 1-.023-.156a.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983a.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983a.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982"/>`,
|
|
1648
|
+
weibo: `<path fill="currentColor" d="M17.525 11.378c1.263.392 2.669 1.336 2.669 3.004c0 2.763-3.98 6.239-9.964 6.239c-4.565 0-9.23-2.213-9.23-5.852c0-1.902 1.204-4.102 3.277-6.177c2.773-2.77 6.004-4.033 7.219-2.816c.537.537.588 1.464.244 2.572c-.178.557.525.25.525.25c2.24-.938 4.196-.994 4.909.027c.38.543.343 1.306-.008 2.19c-.163.407.048.471.36.563zm-7.282 7.939c3.641-.362 6.401-2.592 6.167-4.983c-.237-2.391-3.382-4.038-7.023-3.677c-3.64.36-6.403 2.59-6.167 4.98c.237 2.394 3.382 4.039 7.023 3.68zM6.16 14.438c.754-1.527 2.712-2.39 4.446-1.94c1.793.463 2.707 2.154 1.976 3.8c-.744 1.682-2.882 2.578-4.695 1.993c-1.752-.566-2.493-2.294-1.727-3.853zm1.446 2.587c.568.257 1.325.013 1.676-.55c.346-.568.163-1.217-.407-1.459c-.563-.237-1.291.008-1.64.553c-.354.547-.189 1.202.371 1.456zm2.206-1.808c.219.092.501-.012.628-.231c.123-.22.044-.466-.178-.548c-.216-.084-.486.018-.613.232c-.123.214-.054.458.163.547zM19.873 9.5a.725.725 0 1 1-1.378-.451a1.38 1.38 0 0 0-.288-1.357a1.395 1.395 0 0 0-1.321-.425a.723.723 0 1 1-.303-1.416a2.836 2.836 0 0 1 3.29 3.649zm-3.916-6.575A5.831 5.831 0 0 1 21.5 4.72a5.836 5.836 0 0 1 1.22 5.704a.838.838 0 0 1-1.06.54a.844.844 0 0 1-.542-1.062a4.143 4.143 0 0 0-4.807-5.327a.845.845 0 0 1-.354-1.65z"/>`,
|
|
1649
|
+
zhihu: `<path fill="currentColor" d="M5.721 0C2.251 0 0 2.25 0 5.719V18.28C0 21.751 2.252 24 5.721 24h12.56C21.751 24 24 21.75 24 18.281V5.72C24 2.249 21.75 0 18.281 0zm1.964 4.078q-.408 1.096-.68 2.11h4.587c.545-.006.445 1.168.445 1.171H9.384a58 58 0 0 1-.112 3.797h2.712c.388.023.393 1.251.393 1.266H9.183a9.2 9.2 0 0 1-.408 2.102l.757-.604c.452.456 1.512 1.712 1.906 2.177c.473.681.063 2.081.063 2.081l-2.794-3.382c-.653 2.518-1.845 3.607-1.845 3.607c-.523.468-1.58.82-2.64.516c2.218-1.73 3.44-3.917 3.667-6.497H4.491c0-.015.197-1.243.806-1.266h2.71c.024-.32.086-3.254.086-3.797H6.598c-.136.406-.158.447-.268.753c-.594 1.095-1.603 1.122-1.907 1.155c.906-1.821 1.416-3.6 1.591-4.064c.425-1.124 1.671-1.125 1.671-1.125M13.078 6h6.377v11.33h-2.573l-2.184 1.373l-.401-1.373h-1.219zm1.313 1.219v8.86h.623l.263.937l1.455-.938h1.456v-8.86z"/>`,
|
|
1650
|
+
bilibili: `<path fill="currentColor" d="M17.813 4.653h.854q2.266.08 3.773 1.574Q23.946 7.72 24 9.987v7.36q-.054 2.266-1.56 3.773c-1.506 1.507-2.262 1.524-3.773 1.56H5.333q-2.266-.054-3.773-1.56C.053 19.614.036 18.858 0 17.347v-7.36q.054-2.267 1.56-3.76t3.773-1.574h.774l-1.174-1.12a1.23 1.23 0 0 1-.373-.906q0-.534.373-.907l.027-.027q.4-.373.92-.373t.92.373L9.653 4.44q.107.106.187.213h4.267a.8.8 0 0 1 .16-.213l2.853-2.747q.4-.373.92-.373c.347 0 .662.151.929.4s.391.551.391.907q0 .532-.373.906zM5.333 7.24q-1.12.027-1.88.773q-.76.748-.786 1.894v7.52q.026 1.146.786 1.893t1.88.773h13.334q1.12-.026 1.88-.773t.786-1.893v-7.52q-.026-1.147-.786-1.894t-1.88-.773zM8 11.107q.56 0 .933.373q.375.374.4.96v1.173q-.025.586-.4.96q-.373.375-.933.374c-.56-.001-.684-.125-.933-.374q-.375-.373-.4-.96V12.44q0-.56.386-.947q.387-.386.947-.386m8 0q.56 0 .933.373q.375.374.4.96v1.173q-.025.586-.4.96q-.373.375-.933.374c-.56-.001-.684-.125-.933-.374q-.375-.373-.4-.96V12.44q.025-.586.4-.96q.373-.373.933-.373"/>`,
|
|
1651
|
+
lark: `<path d="M8.813 5.477c1.038.836 2.286 2.045 3.3 3.495.171.23.377.576.457.71l.034.056a8.803 8.803 0 0 0-.922 1.3l-.271-.494C9.655 7.53 6.3 5.477 6.137 5.377a.447.447 0 0 1-.006-.004l-.666-.393-.107-.086a.499.499 0 0 1 .306-.885L6.084 4h7.997c.159.006.318.037.47.092.174.064.317.174.458.308.134.143.272.296.403.448.622.675 1.324 1.688 1.324 1.688-.573.193-1.349.736-1.349.736a5.095 5.095 0 0 0-.348-.54 20.665 20.665 0 0 0-1.037-1.255H8.813Z" fill="currentColor"/>
|
|
1652
|
+
<path d="M18.482 7.507a5.42 5.42 0 0 1 4.04.717c.248.168.788.635.242 1.233-1.7 1.67-2.194 3.225-2.63 4.599-.278.873-.541 1.697-1.066 2.424-1.813 2.508-4.114 4-6.837 4.434-.561.089-1.132.131-1.7.131-3.958 0-7.498-2.035-8.75-2.844h.003l-.161-.107c-.534-.378-.61-.723-.623-.989V7.055a.486.486 0 0 1 .827-.317l.482.589c5.082 6.201 9.126 8.063 11.626 8.53 2.246.424 3.631-.165 4.022-.37.333-.51.534-1.143.764-1.865l.006-.021c.406-1.276.898-2.821 2.322-4.477a3.93 3.93 0 0 0-2.28-.168c-1.761.394-3.403 1.96-4.89 4.643a8.27 8.27 0 0 0-.341.671c-.724-.107-1.334-.65-1.334-.65.128-.269.22-.455.345-.672 1.718-3.125 3.714-4.962 5.933-5.441ZM2.477 16.889c1.145.744 5.341 3.232 9.532 2.563 1.56-.247 2.963-.915 4.196-1.99-2.771.254-7.557-.753-13.728-7.666v7.093Z" fill="currentColor"/>`,
|
|
1653
|
+
x: `<path fill="currentColor" d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584l-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"/>`,
|
|
1654
|
+
bluesky: `<path fill="currentColor" d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565C.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479c.815 2.736 3.713 3.66 6.383 3.364q.204-.03.415-.056q-.207.033-.415.056c-3.912.58-7.387 2.005-2.83 7.078c5.013 5.19 6.87-1.113 7.823-4.308c.953 3.195 2.05 9.271 7.733 4.308c4.267-4.308 1.172-6.498-2.74-7.078a9 9 0 0 1-.415-.056q.21.026.415.056c2.67.297 5.568-.628 6.383-3.364c.246-.828.624-5.79.624-6.478c0-.69-.139-1.861-.902-2.206c-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8"/>`
|
|
1655
|
+
};
|
|
1656
|
+
var formatIconName = (icon) => {
|
|
1657
|
+
return icon.toLowerCase();
|
|
1658
|
+
};
|
|
1659
|
+
function getSocialIcons(socialLinks = []) {
|
|
1660
|
+
const icons = {};
|
|
1661
|
+
for (const link of socialLinks) {
|
|
1662
|
+
if (typeof link.icon === "string") {
|
|
1663
|
+
const pathContent = presetIcons[formatIconName(link.icon)];
|
|
1664
|
+
icons[link.icon] = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 24 24">${pathContent}</svg>`;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
return icons;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1615
1670
|
// src/node/initRsbuild.ts
|
|
1616
1671
|
function isPluginIncluded(config, pluginName) {
|
|
1617
1672
|
return config.builderPlugins?.some((plugin) => plugin.name === pluginName) || config.builderConfig?.plugins?.some(
|
|
@@ -1714,7 +1769,10 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1714
1769
|
include: [PACKAGE_ROOT, path11.join(cwd, "node_modules", RSPRESS_TEMP_DIR2)],
|
|
1715
1770
|
define: {
|
|
1716
1771
|
"process.env.__REACT_GTE_18__": JSON.stringify(reactVersion >= 18),
|
|
1717
|
-
"process.env.TEST": JSON.stringify(process.env.TEST)
|
|
1772
|
+
"process.env.TEST": JSON.stringify(process.env.TEST),
|
|
1773
|
+
"process.env.RSPRESS_SOCIAL_ICONS": JSON.stringify(
|
|
1774
|
+
getSocialIcons(config.themeConfig.socialLinks)
|
|
1775
|
+
)
|
|
1718
1776
|
}
|
|
1719
1777
|
},
|
|
1720
1778
|
performance: {
|
|
@@ -1743,7 +1801,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1743
1801
|
chain.module.rule("MDX").type("javascript/auto").test(MDX_REGEXP3).resolve.merge({
|
|
1744
1802
|
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
1745
1803
|
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
1746
|
-
}).end().oneOf("MDXCompile").use("builtin:swc-loader").loader("builtin:swc-loader").options(swcLoaderOptions).end().use("mdx-loader").loader(__require.resolve("
|
|
1804
|
+
}).end().oneOf("MDXCompile").use("builtin:swc-loader").loader("builtin:swc-loader").options(swcLoaderOptions).end().use("mdx-loader").loader(__require.resolve("./loader.js")).options({
|
|
1747
1805
|
config,
|
|
1748
1806
|
docDirectory: userDocRoot,
|
|
1749
1807
|
checkDeadLinks,
|
|
@@ -1823,7 +1881,7 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1823
1881
|
const builderPlugins = config?.builderPlugins ?? [];
|
|
1824
1882
|
const runtimeTempDir = path11.join(RSPRESS_TEMP_DIR2, "runtime");
|
|
1825
1883
|
const runtimeAbsTempDir = path11.join(cwd, "node_modules", runtimeTempDir);
|
|
1826
|
-
await
|
|
1884
|
+
await fs9.mkdir(runtimeAbsTempDir, { recursive: true });
|
|
1827
1885
|
const routeService2 = await initRouteService({
|
|
1828
1886
|
config,
|
|
1829
1887
|
runtimeTempDir: runtimeAbsTempDir,
|
|
@@ -1852,14 +1910,14 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1852
1910
|
}
|
|
1853
1911
|
|
|
1854
1912
|
// src/node/utils/checkLanguageParity.ts
|
|
1855
|
-
import
|
|
1913
|
+
import fs10 from "fs/promises";
|
|
1856
1914
|
import path12 from "path";
|
|
1857
1915
|
import { logger as logger3 } from "@rspress/shared/logger";
|
|
1858
1916
|
function normalizePath2(filePath) {
|
|
1859
1917
|
return filePath.split(path12.sep).join("/");
|
|
1860
1918
|
}
|
|
1861
1919
|
async function getAllMarkdownFilesFrom(dirPath) {
|
|
1862
|
-
const files = await
|
|
1920
|
+
const files = await fs10.readdir(dirPath, { withFileTypes: true });
|
|
1863
1921
|
const allFiles = [];
|
|
1864
1922
|
for (const file of files) {
|
|
1865
1923
|
const fullPath = path12.join(dirPath, file.name);
|
|
@@ -1876,7 +1934,7 @@ async function collectModuleFiles(contentPath, lang, includedDir, excludedDirs,
|
|
|
1876
1934
|
const langDirPath = path12.join(contentPath, lang);
|
|
1877
1935
|
const langModuleDir = path12.join(langDirPath, includedDir);
|
|
1878
1936
|
try {
|
|
1879
|
-
const moduleDirStats = await
|
|
1937
|
+
const moduleDirStats = await fs10.stat(langModuleDir);
|
|
1880
1938
|
if (!moduleDirStats.isDirectory())
|
|
1881
1939
|
return fileLangMap;
|
|
1882
1940
|
const files = await getAllMarkdownFilesFrom(langModuleDir);
|
|
@@ -1983,6 +2041,7 @@ async function dev(options) {
|
|
|
1983
2041
|
}
|
|
1984
2042
|
|
|
1985
2043
|
// src/node/build.ts
|
|
2044
|
+
import fs12 from "fs/promises";
|
|
1986
2045
|
import { dirname as dirname2, join as join3 } from "path";
|
|
1987
2046
|
import { pathToFileURL } from "url";
|
|
1988
2047
|
import {
|
|
@@ -1991,16 +2050,15 @@ import {
|
|
|
1991
2050
|
withBase as withBase3
|
|
1992
2051
|
} from "@rspress/shared";
|
|
1993
2052
|
import chalk3 from "@rspress/shared/chalk";
|
|
1994
|
-
import fs10 from "@rspress/shared/fs-extra";
|
|
1995
2053
|
import { logger as logger4 } from "@rspress/shared/logger";
|
|
1996
2054
|
|
|
1997
2055
|
// src/node/utils/renderHead.ts
|
|
1998
|
-
import
|
|
2056
|
+
import fs11 from "fs/promises";
|
|
1999
2057
|
import { loadFrontMatter as loadFrontMatter2 } from "@rspress/shared/node-utils";
|
|
2000
2058
|
async function renderFrontmatterHead(route) {
|
|
2001
2059
|
if (!isRouteMeta(route))
|
|
2002
2060
|
return "";
|
|
2003
|
-
const content = await
|
|
2061
|
+
const content = await fs11.readFile(route.absolutePath, {
|
|
2004
2062
|
encoding: "utf-8"
|
|
2005
2063
|
});
|
|
2006
2064
|
const {
|
|
@@ -2059,13 +2117,15 @@ async function bundle(docDirectory, config, pluginDriver, enableSSG) {
|
|
|
2059
2117
|
await checkLanguageParity(config);
|
|
2060
2118
|
}
|
|
2061
2119
|
}
|
|
2120
|
+
function emptyDir(path13) {
|
|
2121
|
+
return fs12.rm(path13, { force: true, recursive: true });
|
|
2122
|
+
}
|
|
2062
2123
|
async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
2063
2124
|
logger4.info("Rendering pages...");
|
|
2064
2125
|
const startTime = Date.now();
|
|
2065
2126
|
const outputPath = config?.outDir ?? join3(appDirectory, OUTPUT_DIR);
|
|
2066
2127
|
const ssrBundlePath = join3(outputPath, "ssr", "main.cjs");
|
|
2067
2128
|
try {
|
|
2068
|
-
const { default: fs11 } = await import("@rspress/shared/fs-extra");
|
|
2069
2129
|
const { version } = await Promise.resolve().then(() => __toESM(require_package()));
|
|
2070
2130
|
let render = null;
|
|
2071
2131
|
if (ssgConfig) {
|
|
@@ -2088,7 +2148,7 @@ async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
|
2088
2148
|
const routes = routeService.getRoutes();
|
|
2089
2149
|
const base = config?.base ?? "";
|
|
2090
2150
|
const htmlTemplatePath = join3(outputPath, "index.html");
|
|
2091
|
-
const htmlTemplate = await
|
|
2151
|
+
const htmlTemplate = await fs12.readFile(htmlTemplatePath, "utf-8");
|
|
2092
2152
|
const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route) => ({
|
|
2093
2153
|
routePath: withBase3(route.path, base)
|
|
2094
2154
|
}));
|
|
@@ -2161,14 +2221,16 @@ async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
|
2161
2221
|
return `${path13}.html`.replace(normalizedBase, "");
|
|
2162
2222
|
};
|
|
2163
2223
|
const fileName = normalizeHtmlFilePath(routePath);
|
|
2164
|
-
await
|
|
2165
|
-
|
|
2224
|
+
await fs12.mkdir(join3(outputPath, dirname2(fileName)), {
|
|
2225
|
+
recursive: true
|
|
2226
|
+
});
|
|
2227
|
+
await fs12.writeFile(join3(outputPath, fileName), html);
|
|
2166
2228
|
})
|
|
2167
2229
|
);
|
|
2168
2230
|
if (!isDebugMode2()) {
|
|
2169
|
-
await
|
|
2231
|
+
await emptyDir(join3(outputPath, "ssr"));
|
|
2170
2232
|
}
|
|
2171
|
-
await
|
|
2233
|
+
await emptyDir(join3(outputPath, "html"));
|
|
2172
2234
|
const totalTime = Date.now() - startTime;
|
|
2173
2235
|
logger4.success(`Pages rendered in ${chalk3.yellow(totalTime)} ms.`);
|
|
2174
2236
|
} catch (e) {
|
|
@@ -2183,7 +2245,7 @@ async function build(options) {
|
|
|
2183
2245
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
2184
2246
|
await pluginDriver.beforeBuild();
|
|
2185
2247
|
const ssgConfig = modifiedConfig.ssg ?? true;
|
|
2186
|
-
await
|
|
2248
|
+
await emptyDir(TEMP_DIR);
|
|
2187
2249
|
await bundle(docDirectory, modifiedConfig, pluginDriver, Boolean(ssgConfig));
|
|
2188
2250
|
await renderPages(appDirectory, modifiedConfig, pluginDriver, ssgConfig);
|
|
2189
2251
|
await pluginDriver.afterBuild();
|