@rspress/core 2.0.0-beta.27 → 2.0.0-beta.28
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/README.md +17 -1
- package/dist/{94.js → 101.js} +3 -2
- package/dist/{208.js → 220.js} +3 -2
- package/dist/{309.js → 335.js} +2 -1
- package/dist/cli.js +3 -3
- package/dist/index.js +210 -230
- package/dist/renderPageWorker.js +2 -2
- package/package.json +6 -10
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<picture>
|
|
2
|
+
<img alt="Rspress Banner" src="https://assets.rspack.rs/rspress/rspress-banner.png">
|
|
3
|
+
</picture>
|
|
4
|
+
|
|
1
5
|
# @rspress/core
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
A fast Rsbuild-based static site generator.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
See [Documentation](https://rspress.rs/).
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/rspress/blob/main/CONTRIBUTING.md).
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Rspress is [MIT licensed](https://github.com/web-infra-dev/rspress/blob/main/LICENSE).
|
package/dist/{94.js → 101.js}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export const __webpack_id__ = "101";
|
|
1
2
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
3
|
+
"101"
|
|
3
4
|
];
|
|
4
5
|
export const __webpack_modules__ = {
|
|
5
6
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
@@ -434,7 +435,7 @@ export const __webpack_modules__ = {
|
|
|
434
435
|
},
|
|
435
436
|
"../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
436
437
|
__webpack_require__.d(__webpack_exports__, {
|
|
437
|
-
|
|
438
|
+
Ho: ()=>execa
|
|
438
439
|
});
|
|
439
440
|
var external_node_buffer_ = __webpack_require__("node:buffer");
|
|
440
441
|
var external_node_path_ = __webpack_require__("node:path");
|
package/dist/{208.js → 220.js}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export const __webpack_id__ = "220";
|
|
1
2
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
3
|
+
"220"
|
|
3
4
|
];
|
|
4
5
|
export const __webpack_modules__ = {
|
|
5
6
|
"./src/node/last-updated/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -13,7 +14,7 @@ export const __webpack_modules__ = {
|
|
|
13
14
|
async function getGitLastUpdatedTimeStamp(filePath) {
|
|
14
15
|
let lastUpdated;
|
|
15
16
|
try {
|
|
16
|
-
const { stdout } = await (0, execa__WEBPACK_IMPORTED_MODULE_0__.
|
|
17
|
+
const { stdout } = await (0, execa__WEBPACK_IMPORTED_MODULE_0__.Ho)('git', [
|
|
17
18
|
'log',
|
|
18
19
|
'-1',
|
|
19
20
|
'--format=%at',
|
package/dist/{309.js → 335.js}
RENAMED
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import picocolors from "picocolors";
|
|
|
6
6
|
import { build, dev, serve } from "./index.js";
|
|
7
7
|
import node_fs from "node:fs";
|
|
8
8
|
import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "@rspress/shared/constants";
|
|
9
|
-
var package_namespaceObject = JSON.parse('{"
|
|
9
|
+
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.28"}');
|
|
10
10
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
11
11
|
async function loadConfigFile(customConfigFile) {
|
|
12
12
|
const baseDir = process.cwd();
|
|
@@ -42,8 +42,8 @@ const META_FILES = [
|
|
|
42
42
|
'_meta.json',
|
|
43
43
|
'_nav.json'
|
|
44
44
|
];
|
|
45
|
-
const cli = cac('rspress').version(package_namespaceObject.
|
|
46
|
-
const landingMessage = `\u{1F525} Rspress v${package_namespaceObject.
|
|
45
|
+
const cli = cac('rspress').version(package_namespaceObject.rE).help();
|
|
46
|
+
const landingMessage = `\u{1F525} Rspress v${package_namespaceObject.rE}\n`;
|
|
47
47
|
logger.greet(landingMessage);
|
|
48
48
|
const setNodeEnv = (env)=>{
|
|
49
49
|
process.env.NODE_ENV = env;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ import { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
|
|
|
22
22
|
import { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
23
23
|
import picocolors from "picocolors";
|
|
24
24
|
import { glob } from "tinyglobby";
|
|
25
|
-
import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
|
|
26
25
|
import { chunk, groupBy } from "lodash-es";
|
|
27
26
|
import { compile } from "@rspress/mdx-rs";
|
|
28
27
|
import { htmlToText } from "html-to-text";
|
|
@@ -110,7 +109,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
110
109
|
})();
|
|
111
110
|
(()=>{
|
|
112
111
|
var installedChunks = {
|
|
113
|
-
|
|
112
|
+
410: 0
|
|
114
113
|
};
|
|
115
114
|
var installChunk = (data)=>{
|
|
116
115
|
var __webpack_ids__ = data.__webpack_ids__;
|
|
@@ -151,8 +150,8 @@ function defineConfig(config) {
|
|
|
151
150
|
}
|
|
152
151
|
var external_node_path_ = __webpack_require__("node:path");
|
|
153
152
|
var external_node_url_ = __webpack_require__("node:url");
|
|
154
|
-
var package_namespaceObject = JSON.parse('{"
|
|
155
|
-
const RSPRESS_VERSION = package_namespaceObject.
|
|
153
|
+
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.28"}');
|
|
154
|
+
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
156
155
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
157
156
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
158
157
|
const inlineThemeScript = `{
|
|
@@ -909,6 +908,89 @@ async function modifyConfigWithAutoNavSide(config) {
|
|
|
909
908
|
}
|
|
910
909
|
return config;
|
|
911
910
|
}
|
|
911
|
+
const globalStylesVMPlugin = (context)=>({
|
|
912
|
+
["virtual-global-styles"]: ()=>{
|
|
913
|
+
const { config, pluginDriver } = context;
|
|
914
|
+
const globalStylesByPlugins = pluginDriver.globalStyles();
|
|
915
|
+
const moduleContent = [
|
|
916
|
+
config?.globalStyles,
|
|
917
|
+
...globalStylesByPlugins
|
|
918
|
+
].filter(Boolean).map((source)=>`import ${JSON.stringify(source)};`).join('');
|
|
919
|
+
return moduleContent;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
const globalUIComponentsVMPlugin = (context)=>({
|
|
923
|
+
["virtual-global-components"]: ()=>{
|
|
924
|
+
const { config, pluginDriver } = context;
|
|
925
|
+
let index = 0;
|
|
926
|
+
const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();
|
|
927
|
+
const globalComponents = [
|
|
928
|
+
...config?.globalUIComponents || [],
|
|
929
|
+
...globalUIComponentsByPlugins
|
|
930
|
+
];
|
|
931
|
+
const moduleContent = globalComponents.map((source)=>{
|
|
932
|
+
const name = `Comp_${index}`;
|
|
933
|
+
if (Array.isArray(source)) return `import ${name} from ${JSON.stringify(source[0])};
|
|
934
|
+
const Props_${index++} = ${JSON.stringify(source[1])};\n`;
|
|
935
|
+
index++;
|
|
936
|
+
return `import ${name} from ${JSON.stringify(source)};\n`;
|
|
937
|
+
}).concat(`export default [${Array.from({
|
|
938
|
+
length: index
|
|
939
|
+
}, (_, i)=>{
|
|
940
|
+
if (Array.isArray(globalComponents[i])) return `[Comp_${i}, Props_${i}]`;
|
|
941
|
+
return `Comp_${i}`;
|
|
942
|
+
}).join(', ')}];`).join('');
|
|
943
|
+
return moduleContent;
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
const i18n_require = createRequire(import.meta.url);
|
|
947
|
+
const DEFAULT_I18N_SOURCE = (0, external_node_path_.join)(process.cwd(), 'i18n.json');
|
|
948
|
+
function getI18nData(docConfig) {
|
|
949
|
+
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
950
|
+
try {
|
|
951
|
+
delete i18n_require.cache[i18nSourcePath];
|
|
952
|
+
const i18nSource = i18n_require(i18nSourcePath);
|
|
953
|
+
return i18nSource;
|
|
954
|
+
} catch (e) {
|
|
955
|
+
logger.debug('getI18nData Failed: \n', e);
|
|
956
|
+
return {};
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
const i18nVMPlugin = (context)=>{
|
|
960
|
+
const { config } = context;
|
|
961
|
+
return {
|
|
962
|
+
["virtual-i18n-text"]: ({ addDependency, addMissingDependency })=>{
|
|
963
|
+
addDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
|
|
964
|
+
addMissingDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
|
|
965
|
+
const i18nData = getI18nData(config);
|
|
966
|
+
return `export default ${JSON.stringify(i18nData, null, 2)}`;
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
};
|
|
970
|
+
const routeListVMPlugin = (context)=>{
|
|
971
|
+
const { routeService } = context;
|
|
972
|
+
return {
|
|
973
|
+
["virtual-routes"]: ()=>routeService.generateRoutesCode()
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
const runtimeConfigVMPlugin = (context)=>({
|
|
977
|
+
["virtual-runtime-config"]: ()=>{
|
|
978
|
+
const { config } = context;
|
|
979
|
+
const { base } = config;
|
|
980
|
+
const normalizedBase = (0, shared_.normalizeSlash)(base ?? '/');
|
|
981
|
+
return `export const base = ${JSON.stringify(normalizedBase)};`;
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
var external_path_ = __webpack_require__("path");
|
|
985
|
+
const searchHookVMPlugin = (context)=>({
|
|
986
|
+
["virtual-search-hooks"]: ()=>{
|
|
987
|
+
const { config } = context;
|
|
988
|
+
let content = 'export const onSearch = () => {};';
|
|
989
|
+
const searchHooks = 'object' == typeof config.search && config.search?.searchHooks;
|
|
990
|
+
if (searchHooks) content = `export * from ${JSON.stringify(external_path_["default"].posix.normalize(searchHooks))}`;
|
|
991
|
+
return content;
|
|
992
|
+
}
|
|
993
|
+
});
|
|
912
994
|
var external_node_fs_ = __webpack_require__("node:fs");
|
|
913
995
|
let flattenMdxContent_resolver;
|
|
914
996
|
let startFlatten = false;
|
|
@@ -1099,41 +1181,6 @@ async function extractPageData(routeService, options) {
|
|
|
1099
1181
|
function createHash_createHash(str) {
|
|
1100
1182
|
return createHash('sha256').update(str).digest('hex').slice(0, 8);
|
|
1101
1183
|
}
|
|
1102
|
-
var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
1103
|
-
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
1104
|
-
RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
|
|
1105
|
-
RuntimeModuleID["Routes"] = "virtual-routes";
|
|
1106
|
-
RuntimeModuleID["SiteData"] = "virtual-site-data";
|
|
1107
|
-
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
1108
|
-
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
1109
|
-
RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
|
|
1110
|
-
RuntimeModuleID["RuntimeConfig"] = "virtual-runtime-config";
|
|
1111
|
-
return RuntimeModuleID;
|
|
1112
|
-
}({});
|
|
1113
|
-
const i18n_require = createRequire(import.meta.url);
|
|
1114
|
-
const DEFAULT_I18N_SOURCE = (0, external_node_path_.join)(process.cwd(), 'i18n.json');
|
|
1115
|
-
function getI18nData(docConfig) {
|
|
1116
|
-
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
1117
|
-
try {
|
|
1118
|
-
delete i18n_require.cache[i18nSourcePath];
|
|
1119
|
-
const i18nSource = i18n_require(i18nSourcePath);
|
|
1120
|
-
return i18nSource;
|
|
1121
|
-
} catch (e) {
|
|
1122
|
-
logger.debug('getI18nData Failed: \n', e);
|
|
1123
|
-
return {};
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
const i18nVMPlugin = (context)=>{
|
|
1127
|
-
const { config } = context;
|
|
1128
|
-
return {
|
|
1129
|
-
[types_RuntimeModuleID.I18nText]: ({ addDependency, addMissingDependency })=>{
|
|
1130
|
-
addDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
|
|
1131
|
-
addMissingDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
|
|
1132
|
-
const i18nData = getI18nData(config);
|
|
1133
|
-
return `export default ${JSON.stringify(i18nData, null, 2)}`;
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
};
|
|
1137
1184
|
function normalizeThemeConfig(docConfig) {
|
|
1138
1185
|
const { locales: siteLocales, lang, replaceRules = [], multiVersion } = docConfig;
|
|
1139
1186
|
const { versions = [] } = multiVersion || {};
|
|
@@ -1142,38 +1189,41 @@ function normalizeThemeConfig(docConfig) {
|
|
|
1142
1189
|
const { themeConfig } = docConfig;
|
|
1143
1190
|
const locales = siteLocales ?? (themeConfig?.locales || []);
|
|
1144
1191
|
const i18nTextData = getI18nData(docConfig);
|
|
1145
|
-
const normalizeLinkPrefix = (link
|
|
1192
|
+
const normalizeLinkPrefix = (link, currentLang)=>{
|
|
1146
1193
|
const normalizedLink = (0, shared_.slash)(link);
|
|
1147
1194
|
if (!currentLang || !link || normalizedLink.startsWith(`/${currentLang}`) || (0, shared_.isExternalUrl)(normalizedLink) || hasMultiVersion) return normalizedLink;
|
|
1148
1195
|
return lang === currentLang ? normalizedLink : `/${currentLang}${(0, shared_.addLeadingSlash)(normalizedLink)}`;
|
|
1149
1196
|
};
|
|
1150
|
-
const getI18nText = (key
|
|
1197
|
+
const getI18nText = (key, currentLang)=>{
|
|
1151
1198
|
const text = i18nTextData[key]?.[currentLang];
|
|
1152
1199
|
return text || key;
|
|
1153
1200
|
};
|
|
1154
|
-
const
|
|
1201
|
+
const cleanUrls = docConfig.route?.cleanUrls ?? false;
|
|
1202
|
+
const transformLink = (link, currentLang)=>(0, shared_.normalizeHref)(normalizeLinkPrefix(link, currentLang), cleanUrls);
|
|
1203
|
+
const textReplace = (text, currentLang)=>applyReplaceRules(getI18nText(text, currentLang), replaceRules);
|
|
1204
|
+
const normalizeSidebar = (sidebar, currentLang)=>{
|
|
1155
1205
|
const normalizedSidebar = {};
|
|
1156
1206
|
if (!sidebar) return {};
|
|
1157
1207
|
const normalizeSidebarItem = (item)=>{
|
|
1158
1208
|
if ('object' == typeof item && 'dividerType' in item) return item;
|
|
1159
1209
|
if ('object' == typeof item && 'sectionHeaderText' in item) {
|
|
1160
|
-
item.sectionHeaderText =
|
|
1210
|
+
item.sectionHeaderText = textReplace(item.sectionHeaderText, currentLang);
|
|
1161
1211
|
return item;
|
|
1162
1212
|
}
|
|
1163
1213
|
if ('object' == typeof item && 'items' in item) return {
|
|
1164
1214
|
...item,
|
|
1165
|
-
text:
|
|
1166
|
-
link
|
|
1215
|
+
text: textReplace(item.text, currentLang),
|
|
1216
|
+
...'link' in item && item.link ? {
|
|
1217
|
+
link: transformLink(item.link, currentLang)
|
|
1218
|
+
} : {},
|
|
1167
1219
|
collapsed: item.collapsed ?? false,
|
|
1168
1220
|
collapsible: item.collapsible ?? true,
|
|
1169
|
-
tag: item.tag,
|
|
1170
1221
|
items: item.items.map((subItem)=>normalizeSidebarItem(subItem))
|
|
1171
1222
|
};
|
|
1172
1223
|
return {
|
|
1173
1224
|
...item,
|
|
1174
|
-
text:
|
|
1175
|
-
link:
|
|
1176
|
-
tag: item.tag
|
|
1225
|
+
text: textReplace(item.text, currentLang),
|
|
1226
|
+
link: transformLink(item.link, currentLang)
|
|
1177
1227
|
};
|
|
1178
1228
|
};
|
|
1179
1229
|
const normalizeSidebar = (sidebar)=>{
|
|
@@ -1187,24 +1237,18 @@ function normalizeThemeConfig(docConfig) {
|
|
|
1187
1237
|
};
|
|
1188
1238
|
const normalizeNav = (nav, currentLang)=>{
|
|
1189
1239
|
if (!nav) return [];
|
|
1190
|
-
const transformNavItem = (navItem)=>{
|
|
1191
|
-
const text = applyReplaceRules(getI18nText(navItem.text, currentLang), replaceRules);
|
|
1192
|
-
if ('link' in navItem) return {
|
|
1193
|
-
...navItem,
|
|
1194
|
-
text,
|
|
1195
|
-
link: normalizeLinkPrefix(navItem.link, currentLang)
|
|
1196
|
-
};
|
|
1197
|
-
if ('items' in navItem) return {
|
|
1240
|
+
const transformNavItem = (navItem)=>({
|
|
1198
1241
|
...navItem,
|
|
1199
|
-
text
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1242
|
+
...navItem.text ? {
|
|
1243
|
+
text: textReplace(navItem.text, currentLang)
|
|
1244
|
+
} : {},
|
|
1245
|
+
...'link' in navItem ? {
|
|
1246
|
+
link: transformLink(navItem.link, currentLang)
|
|
1247
|
+
} : {},
|
|
1248
|
+
...'items' in navItem ? {
|
|
1249
|
+
items: navItem.items.map((item)=>transformNavItem(item))
|
|
1250
|
+
} : {}
|
|
1251
|
+
});
|
|
1208
1252
|
if (Array.isArray(nav)) return nav.map(transformNavItem);
|
|
1209
1253
|
return Object.entries(nav).reduce((acc, [key, value])=>{
|
|
1210
1254
|
acc[key] = value.map(transformNavItem);
|
|
@@ -1216,14 +1260,14 @@ function normalizeThemeConfig(docConfig) {
|
|
|
1216
1260
|
return {
|
|
1217
1261
|
lang: currentLang,
|
|
1218
1262
|
label,
|
|
1219
|
-
...localeInThemeConfig
|
|
1263
|
+
...localeInThemeConfig,
|
|
1220
1264
|
sidebar: normalizeSidebar(localeInThemeConfig?.sidebar ?? themeConfig.sidebar, currentLang),
|
|
1221
1265
|
nav: normalizeNav(localeInThemeConfig?.nav ?? themeConfig.nav, currentLang)
|
|
1222
1266
|
};
|
|
1223
1267
|
});
|
|
1224
1268
|
else {
|
|
1225
|
-
themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar);
|
|
1226
|
-
themeConfig.nav = normalizeNav(themeConfig?.nav);
|
|
1269
|
+
themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar, '');
|
|
1270
|
+
themeConfig.nav = normalizeNav(themeConfig?.nav, '');
|
|
1227
1271
|
}
|
|
1228
1272
|
return themeConfig;
|
|
1229
1273
|
}
|
|
@@ -1235,7 +1279,7 @@ function deletePrivateField(obj) {
|
|
|
1235
1279
|
for(const key in newObj)if (key.startsWith('_')) delete newObj[key];
|
|
1236
1280
|
return newObj;
|
|
1237
1281
|
}
|
|
1238
|
-
async function
|
|
1282
|
+
async function createSiteData(context) {
|
|
1239
1283
|
const { config, alias, userDocRoot, routeService, pluginDriver } = context;
|
|
1240
1284
|
const userConfig = config;
|
|
1241
1285
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
@@ -1259,6 +1303,7 @@ async function siteDataVMPlugin(context) {
|
|
|
1259
1303
|
});
|
|
1260
1304
|
delete groupedPages.noindex;
|
|
1261
1305
|
const indexHashByGroup = {};
|
|
1306
|
+
const searchIndex = {};
|
|
1262
1307
|
await Promise.all(Object.keys(groupedPages).map(async (group)=>{
|
|
1263
1308
|
const stringifiedIndex = JSON.stringify(groupedPages[group].map(deletePrivateField));
|
|
1264
1309
|
const indexHash = createHash_createHash(stringifiedIndex);
|
|
@@ -1266,10 +1311,8 @@ async function siteDataVMPlugin(context) {
|
|
|
1266
1311
|
const [version, lang] = group.split('###');
|
|
1267
1312
|
const indexVersion = version ? `.${version.replace('.', '_')}` : '';
|
|
1268
1313
|
const indexLang = lang ? `.${lang}` : '';
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
});
|
|
1272
|
-
await node_fs_promises.writeFile(external_node_path_["default"].join(constants_TEMP_DIR, `${shared_.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`), stringifiedIndex);
|
|
1314
|
+
const filename = `${shared_.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`;
|
|
1315
|
+
searchIndex[filename] = stringifiedIndex;
|
|
1273
1316
|
}));
|
|
1274
1317
|
await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
|
|
1275
1318
|
const siteData = {
|
|
@@ -1303,132 +1346,90 @@ async function siteDataVMPlugin(context) {
|
|
|
1303
1346
|
}
|
|
1304
1347
|
};
|
|
1305
1348
|
return {
|
|
1306
|
-
|
|
1307
|
-
|
|
1349
|
+
siteData,
|
|
1350
|
+
searchIndex,
|
|
1351
|
+
indexHashByGroup
|
|
1308
1352
|
};
|
|
1309
1353
|
}
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1354
|
+
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
1355
|
+
const ref = {
|
|
1356
|
+
siteData: null,
|
|
1357
|
+
searchIndex: null,
|
|
1358
|
+
indexHashByGroup: null
|
|
1359
|
+
};
|
|
1360
|
+
const searchIndexRsbuildPlugin = {
|
|
1361
|
+
name: 'rsbuild-plugin-searchIndex',
|
|
1362
|
+
async setup (api) {
|
|
1317
1363
|
api.modifyBundlerChain(async (bundlerChain)=>{
|
|
1318
1364
|
const alias = bundlerChain.resolve.alias.entries();
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1365
|
+
const { siteData, searchIndex, indexHashByGroup } = await createSiteData({
|
|
1366
|
+
config,
|
|
1367
|
+
alias: alias,
|
|
1368
|
+
userDocRoot,
|
|
1369
|
+
routeService,
|
|
1370
|
+
pluginDriver
|
|
1371
|
+
});
|
|
1372
|
+
ref.siteData = siteData;
|
|
1373
|
+
ref.searchIndex = searchIndex;
|
|
1374
|
+
ref.indexHashByGroup = indexHashByGroup;
|
|
1375
|
+
api.processAssets({
|
|
1376
|
+
stage: 'report',
|
|
1377
|
+
environments: [
|
|
1378
|
+
'web'
|
|
1379
|
+
]
|
|
1380
|
+
}, ({ compilation, compiler })=>{
|
|
1381
|
+
for (const [filename, stringifiedIndex] of Object.entries(searchIndex))compilation.emitAsset(`static/${filename}`, new compiler.webpack.sources.RawSource(stringifiedIndex));
|
|
1382
|
+
});
|
|
1328
1383
|
});
|
|
1329
1384
|
}
|
|
1330
1385
|
};
|
|
1386
|
+
return [
|
|
1387
|
+
searchIndexRsbuildPlugin,
|
|
1388
|
+
pluginVirtualModule({
|
|
1389
|
+
tempDir: '.rspress',
|
|
1390
|
+
virtualModules: {
|
|
1391
|
+
["virtual-site-data"]: ()=>`export default ${JSON.stringify(ref.siteData, null, 2)}`,
|
|
1392
|
+
["virtual-search-index-hash"]: ()=>`export default ${JSON.stringify(ref.indexHashByGroup, null, 2)}`
|
|
1393
|
+
}
|
|
1394
|
+
})
|
|
1395
|
+
];
|
|
1396
|
+
};
|
|
1397
|
+
const presetIcons = {
|
|
1398
|
+
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"/>',
|
|
1399
|
+
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"/>',
|
|
1400
|
+
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"/>',
|
|
1401
|
+
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"/>',
|
|
1402
|
+
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"/>',
|
|
1403
|
+
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"/>',
|
|
1404
|
+
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"/>',
|
|
1405
|
+
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"/>',
|
|
1406
|
+
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"/>',
|
|
1407
|
+
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"/>',
|
|
1408
|
+
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"/>',
|
|
1409
|
+
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"/>',
|
|
1410
|
+
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"/>',
|
|
1411
|
+
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"/>',
|
|
1412
|
+
lark: '<path d="M6.14 3.8a28.88 28.88 0 0 1 6.6 7.63l1.7-1.67a8.37 8.37 0 0 1 2.82-1.83 12.23 12.23 0 0 0-2.32-4.28.67.67 0 0 0-.53-.25H6.28c-.21 0-.3.27-.14.4Z" fill="currentColor"></path><path d="m20.57 14.2.01-.02.04-.07-.05.08Z" fill="currentColor"></path><path d="M11.04 14.56c1.23.52 2.34.97 3.65 1.32a4.75 4.75 0 0 0 5.63-2.4l1.32-2.63c.3-.64.67-1.23 1.12-1.78a6.2 6.2 0 0 0-2.3-.44c-1.9 0-3.7.73-5.06 2.06l-2.02 2c-.72.7-1.5 1.33-2.34 1.87Z" fill="currentColor"></path><path d="M20.8 13.78v-.02l.01-.01s0 .02-.02.03Z" fill="currentColor"></path><path d="M1.63 9.75a.23.23 0 0 0-.4.16v7.96c0 .23.12.44.3.56a12.95 12.95 0 0 0 14.08.2c.78-.5 1.39-.92 2.04-1.55-1.05.3-2.2.33-3.37.01A28.99 28.99 0 0 1 1.63 9.75Z" fill="currentColor"></path>',
|
|
1413
|
+
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"/>',
|
|
1414
|
+
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"/>',
|
|
1415
|
+
npm: '<path fill="currentColor" d="M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019l-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z"/>'
|
|
1416
|
+
};
|
|
1417
|
+
const formatIconName = (icon)=>icon.toLowerCase();
|
|
1418
|
+
function getSocialIcons(socialLinks = []) {
|
|
1419
|
+
const icons = {};
|
|
1420
|
+
for (const link of socialLinks)if ('string' == typeof link.icon) {
|
|
1421
|
+
const pathContent = presetIcons[formatIconName(link.icon)];
|
|
1422
|
+
if (!pathContent) throw new Error(`Icon "${link.icon}" not found in preset icons.`);
|
|
1423
|
+
icons[link.icon] = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 24 24">${pathContent}</svg>`;
|
|
1424
|
+
}
|
|
1425
|
+
return icons;
|
|
1331
1426
|
}
|
|
1332
|
-
|
|
1333
|
-
const
|
|
1334
|
-
const modulesByPlugin = await pluginDriver.addRuntimeModules();
|
|
1335
|
-
Object.keys(modulesByPlugin).forEach((key)=>{
|
|
1336
|
-
if (runtimeModule[key]) throw new Error(`The runtime module ${key} is duplicated, please check your plugin`);
|
|
1337
|
-
runtimeModule[key] = ()=>modulesByPlugin[key];
|
|
1338
|
-
});
|
|
1339
|
-
return runtimeModule;
|
|
1340
|
-
}
|
|
1341
|
-
const globalStylesVMPlugin = (context)=>({
|
|
1342
|
-
[types_RuntimeModuleID.GlobalStyles]: ()=>{
|
|
1343
|
-
const { config, pluginDriver } = context;
|
|
1344
|
-
const globalStylesByPlugins = pluginDriver.globalStyles();
|
|
1345
|
-
const moduleContent = [
|
|
1346
|
-
config?.globalStyles,
|
|
1347
|
-
...globalStylesByPlugins
|
|
1348
|
-
].filter(Boolean).map((source)=>`import ${JSON.stringify(source)};`).join('');
|
|
1349
|
-
return moduleContent;
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1352
|
-
const globalUIComponentsVMPlugin = (context)=>({
|
|
1353
|
-
[types_RuntimeModuleID.GlobalComponents]: ()=>{
|
|
1354
|
-
const { config, pluginDriver } = context;
|
|
1355
|
-
let index = 0;
|
|
1356
|
-
const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();
|
|
1357
|
-
const globalComponents = [
|
|
1358
|
-
...config?.globalUIComponents || [],
|
|
1359
|
-
...globalUIComponentsByPlugins
|
|
1360
|
-
];
|
|
1361
|
-
const moduleContent = globalComponents.map((source)=>{
|
|
1362
|
-
const name = `Comp_${index}`;
|
|
1363
|
-
if (Array.isArray(source)) return `import ${name} from ${JSON.stringify(source[0])};
|
|
1364
|
-
const Props_${index++} = ${JSON.stringify(source[1])};\n`;
|
|
1365
|
-
index++;
|
|
1366
|
-
return `import ${name} from ${JSON.stringify(source)};\n`;
|
|
1367
|
-
}).concat(`export default [${Array.from({
|
|
1368
|
-
length: index
|
|
1369
|
-
}, (_, i)=>{
|
|
1370
|
-
if (Array.isArray(globalComponents[i])) return `[Comp_${i}, Props_${i}]`;
|
|
1371
|
-
return `Comp_${i}`;
|
|
1372
|
-
}).join(', ')}];`).join('');
|
|
1373
|
-
return moduleContent;
|
|
1374
|
-
}
|
|
1375
|
-
});
|
|
1376
|
-
const routeListVMPlugin = (context)=>{
|
|
1377
|
-
const { routeService } = context;
|
|
1427
|
+
const socialLinksVMPlugin = (context)=>{
|
|
1428
|
+
const { config } = context;
|
|
1378
1429
|
return {
|
|
1379
|
-
[
|
|
1430
|
+
["virtual-social-links"]: ()=>`export default ${JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks), null, 2)}`
|
|
1380
1431
|
};
|
|
1381
1432
|
};
|
|
1382
|
-
const runtimeConfigVMPlugin = (context)=>({
|
|
1383
|
-
[types_RuntimeModuleID.RuntimeConfig]: ()=>{
|
|
1384
|
-
const { config } = context;
|
|
1385
|
-
const { base } = config;
|
|
1386
|
-
const normalizedBase = (0, shared_.normalizeSlash)(base ?? '/');
|
|
1387
|
-
return `export const base = ${JSON.stringify(normalizedBase)};`;
|
|
1388
|
-
}
|
|
1389
|
-
});
|
|
1390
|
-
const searchHookVMPlugin = (context)=>({
|
|
1391
|
-
[`${types_RuntimeModuleID.SearchHooks}`]: ()=>{
|
|
1392
|
-
const { config } = context;
|
|
1393
|
-
let content = 'export const onSearch = () => {};';
|
|
1394
|
-
if ('object' == typeof config.search && 'string' == typeof config.search.searchHooks) content = `export * from '${config.search.searchHooks}'`;
|
|
1395
|
-
return content;
|
|
1396
|
-
}
|
|
1397
|
-
});
|
|
1398
|
-
async function writeSearchIndex(config) {
|
|
1399
|
-
if (config?.search === false) return;
|
|
1400
|
-
const cwd = process.cwd();
|
|
1401
|
-
const searchIndexFiles = await node_fs_promises.readdir(constants_TEMP_DIR);
|
|
1402
|
-
const outDir = config?.outDir ?? (0, external_node_path_.join)(cwd, OUTPUT_DIR);
|
|
1403
|
-
const targetDir = (0, external_node_path_.join)(outDir, 'static');
|
|
1404
|
-
await node_fs_promises.mkdir(targetDir, {
|
|
1405
|
-
recursive: true
|
|
1406
|
-
});
|
|
1407
|
-
let searchIndexData = '[]';
|
|
1408
|
-
let scanning = false;
|
|
1409
|
-
for (const searchIndexFile of searchIndexFiles){
|
|
1410
|
-
if (!searchIndexFile.includes(shared_.SEARCH_INDEX_NAME) || !searchIndexFile.endsWith('.json')) continue;
|
|
1411
|
-
const source = (0, external_node_path_.join)(constants_TEMP_DIR, searchIndexFile);
|
|
1412
|
-
const target = (0, external_node_path_.join)(targetDir, searchIndexFile);
|
|
1413
|
-
const searchIndex = await node_fs_promises.readFile((0, external_node_path_.join)(constants_TEMP_DIR, searchIndexFile), 'utf-8');
|
|
1414
|
-
searchIndexData = `${searchIndexData.slice(0, -1)}${scanning ? ',' : ''}${searchIndex.slice(1)}`;
|
|
1415
|
-
await node_fs_promises.rename(source, target);
|
|
1416
|
-
scanning = true;
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
function serveSearchIndexMiddleware(config) {
|
|
1420
|
-
return (req, res, next)=>{
|
|
1421
|
-
const searchIndexRequestMatch = `/${shared_.SEARCH_INDEX_NAME}.`;
|
|
1422
|
-
if (req.url?.includes(searchIndexRequestMatch)) {
|
|
1423
|
-
res.setHeader('Content-Type', 'application/json');
|
|
1424
|
-
const outDir = config?.outDir ?? (0, external_node_path_.join)(process.cwd(), OUTPUT_DIR);
|
|
1425
|
-
const searchIndexFile = req.url.split('/').pop();
|
|
1426
|
-
(0, external_node_fs_.createReadStream)((0, external_node_path_.join)(outDir, 'static', searchIndexFile), 'utf-8').pipe(res, {
|
|
1427
|
-
end: true
|
|
1428
|
-
});
|
|
1429
|
-
} else next?.();
|
|
1430
|
-
};
|
|
1431
|
-
}
|
|
1432
1433
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
1433
1434
|
return new Promise((resolve_, reject_)=>{
|
|
1434
1435
|
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})`);
|
|
@@ -1897,42 +1898,21 @@ const detectCustomIcon = async (customThemeDir)=>{
|
|
|
1897
1898
|
});
|
|
1898
1899
|
return alias;
|
|
1899
1900
|
};
|
|
1900
|
-
const presetIcons = {
|
|
1901
|
-
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"/>',
|
|
1902
|
-
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"/>',
|
|
1903
|
-
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"/>',
|
|
1904
|
-
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"/>',
|
|
1905
|
-
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"/>',
|
|
1906
|
-
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"/>',
|
|
1907
|
-
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"/>',
|
|
1908
|
-
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"/>',
|
|
1909
|
-
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"/>',
|
|
1910
|
-
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"/>',
|
|
1911
|
-
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"/>',
|
|
1912
|
-
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"/>',
|
|
1913
|
-
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"/>',
|
|
1914
|
-
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"/>',
|
|
1915
|
-
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"/>
|
|
1916
|
-
<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"/>`,
|
|
1917
|
-
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"/>',
|
|
1918
|
-
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"/>',
|
|
1919
|
-
npm: '<path fill="currentColor" d="M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019l-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z"/>'
|
|
1920
|
-
};
|
|
1921
|
-
const formatIconName = (icon)=>icon.toLowerCase();
|
|
1922
|
-
function getSocialIcons(socialLinks = []) {
|
|
1923
|
-
const icons = {};
|
|
1924
|
-
for (const link of socialLinks)if ('string' == typeof link.icon) {
|
|
1925
|
-
const pathContent = presetIcons[formatIconName(link.icon)];
|
|
1926
|
-
icons[link.icon] = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 24 24">${pathContent}</svg>`;
|
|
1927
|
-
}
|
|
1928
|
-
return icons;
|
|
1929
|
-
}
|
|
1930
1901
|
function isPluginIncluded(config, pluginName) {
|
|
1931
1902
|
return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
|
|
1932
1903
|
}
|
|
1933
1904
|
const initRsbuild_require = createRequire(import.meta.url);
|
|
1934
1905
|
const initRsbuild_filename = (0, external_node_url_.fileURLToPath)(import.meta.url);
|
|
1935
1906
|
const initRsbuild_dirname = external_node_path_["default"].dirname(initRsbuild_filename);
|
|
1907
|
+
async function getVirtualModulesFromPlugins(pluginDriver) {
|
|
1908
|
+
const runtimeModule = {};
|
|
1909
|
+
const modulesByPlugin = await pluginDriver.addRuntimeModules();
|
|
1910
|
+
Object.keys(modulesByPlugin).forEach((key)=>{
|
|
1911
|
+
if (runtimeModule[key]) throw new Error(`The runtime module ${key} is duplicated, please check your plugin`);
|
|
1912
|
+
runtimeModule[key] = ()=>modulesByPlugin[key];
|
|
1913
|
+
});
|
|
1914
|
+
return runtimeModule;
|
|
1915
|
+
}
|
|
1936
1916
|
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
|
|
1937
1917
|
const cwd = process.cwd();
|
|
1938
1918
|
const CUSTOM_THEME_DIR = config?.themeDir ?? external_node_path_["default"].join(process.cwd(), 'theme');
|
|
@@ -1966,10 +1946,16 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1966
1946
|
...isPluginIncluded(config, PLUGIN_REACT_NAME) ? [] : [
|
|
1967
1947
|
pluginReact()
|
|
1968
1948
|
],
|
|
1969
|
-
rsbuildPluginDocVM(
|
|
1949
|
+
rsbuildPluginDocVM({
|
|
1950
|
+
config,
|
|
1951
|
+
pluginDriver,
|
|
1952
|
+
routeService,
|
|
1953
|
+
userDocRoot
|
|
1954
|
+
}),
|
|
1970
1955
|
pluginVirtualModule({
|
|
1971
1956
|
tempDir: '.rspress/runtime',
|
|
1972
1957
|
virtualModules: {
|
|
1958
|
+
...socialLinksVMPlugin(context),
|
|
1973
1959
|
...i18nVMPlugin(context),
|
|
1974
1960
|
...globalUIComponentsVMPlugin(context),
|
|
1975
1961
|
...globalStylesVMPlugin(context),
|
|
@@ -1998,9 +1984,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1998
1984
|
},
|
|
1999
1985
|
dev: {
|
|
2000
1986
|
lazyCompilation: 'false' !== process.env.RSPRESS_LAZY_COMPILATION,
|
|
2001
|
-
setupMiddlewares: (middlewares)=>{
|
|
2002
|
-
middlewares.unshift(serveSearchIndexMiddleware(config));
|
|
2003
|
-
},
|
|
2004
1987
|
cliShortcuts: {
|
|
2005
1988
|
custom: (shortcuts)=>shortcuts.filter(({ key })=>'r' !== key)
|
|
2006
1989
|
}
|
|
@@ -2044,8 +2027,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2044
2027
|
external_node_path_["default"].join(cwd, 'node_modules', shared_.RSPRESS_TEMP_DIR)
|
|
2045
2028
|
],
|
|
2046
2029
|
define: {
|
|
2047
|
-
'process.env.TEST': JSON.stringify(process.env.TEST)
|
|
2048
|
-
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks))
|
|
2030
|
+
'process.env.TEST': JSON.stringify(process.env.TEST)
|
|
2049
2031
|
}
|
|
2050
2032
|
},
|
|
2051
2033
|
performance: {
|
|
@@ -2218,13 +2200,13 @@ class PluginDriver {
|
|
|
2218
2200
|
const mediumZoomConfig = config?.mediumZoom ?? true;
|
|
2219
2201
|
if (enableLastUpdated) {
|
|
2220
2202
|
const { pluginLastUpdated } = await Promise.all([
|
|
2221
|
-
__webpack_require__.e("
|
|
2222
|
-
__webpack_require__.e("
|
|
2203
|
+
__webpack_require__.e("101"),
|
|
2204
|
+
__webpack_require__.e("220")
|
|
2223
2205
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/node/last-updated/index.ts"));
|
|
2224
2206
|
this.addPlugin(pluginLastUpdated());
|
|
2225
2207
|
}
|
|
2226
2208
|
if (mediumZoomConfig) {
|
|
2227
|
-
const { pluginMediumZoom } = await __webpack_require__.e("
|
|
2209
|
+
const { pluginMediumZoom } = await __webpack_require__.e("335").then(__webpack_require__.bind(__webpack_require__, "./src/node/medium-zoom/index.ts"));
|
|
2228
2210
|
this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
|
|
2229
2211
|
}
|
|
2230
2212
|
(config.plugins || []).forEach((plugin)=>{
|
|
@@ -2391,7 +2373,6 @@ async function bundle(docDirectory, config, pluginDriver, enableSSG) {
|
|
|
2391
2373
|
await pluginDriver.beforeBuild();
|
|
2392
2374
|
await rsbuild.build();
|
|
2393
2375
|
} finally{
|
|
2394
|
-
await writeSearchIndex(config);
|
|
2395
2376
|
await checkLanguageParity(config);
|
|
2396
2377
|
}
|
|
2397
2378
|
await pluginDriver.afterBuild();
|
|
@@ -2429,7 +2410,6 @@ async function dev(options) {
|
|
|
2429
2410
|
});
|
|
2430
2411
|
return server;
|
|
2431
2412
|
} finally{
|
|
2432
|
-
await writeSearchIndex(modifiedConfig);
|
|
2433
2413
|
await checkLanguageParity(modifiedConfig);
|
|
2434
2414
|
}
|
|
2435
2415
|
}
|
package/dist/renderPageWorker.js
CHANGED
|
@@ -102,8 +102,8 @@ function hintSSGFailed() {
|
|
|
102
102
|
1. Fix code to make it SSR-compatible.
|
|
103
103
|
2. Set \`ssg: false\` if the code in node_modules may be difficult to fix, but the SSG feature will be lost.`);
|
|
104
104
|
}
|
|
105
|
-
var package_namespaceObject = JSON.parse('{"
|
|
106
|
-
const RSPRESS_VERSION = package_namespaceObject.
|
|
105
|
+
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.28"}');
|
|
106
|
+
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
107
107
|
`{
|
|
108
108
|
const saved = localStorage.getItem('${APPEARANCE_KEY}')
|
|
109
109
|
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.28",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"index.html"
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@mdx-js/loader": "^3.1.0",
|
|
55
54
|
"@mdx-js/mdx": "^3.1.0",
|
|
56
55
|
"@mdx-js/react": "^3.1.0",
|
|
57
56
|
"@rsbuild/core": "~1.4.15",
|
|
@@ -64,7 +63,6 @@
|
|
|
64
63
|
"chokidar": "^3.6.0",
|
|
65
64
|
"enhanced-resolve": "5.18.3",
|
|
66
65
|
"github-slugger": "^2.0.0",
|
|
67
|
-
"hast-util-from-html": "^2.0.3",
|
|
68
66
|
"hast-util-heading-rank": "^3.0.0",
|
|
69
67
|
"html-to-text": "^9.0.5",
|
|
70
68
|
"lodash-es": "^4.17.21",
|
|
@@ -77,29 +75,27 @@
|
|
|
77
75
|
"react-router-dom": "^6.30.1",
|
|
78
76
|
"rehype-external-links": "^3.0.0",
|
|
79
77
|
"rehype-raw": "^7.0.0",
|
|
80
|
-
"remark": "^15.0.1",
|
|
81
78
|
"remark-gfm": "^4.0.1",
|
|
82
|
-
"rspack-plugin-virtual-module": "1.0.1",
|
|
83
79
|
"shiki": "^3.9.2",
|
|
84
80
|
"tinyglobby": "^0.2.14",
|
|
85
81
|
"tinypool": "^1.1.1",
|
|
86
82
|
"unified": "^11.0.5",
|
|
87
83
|
"unist-util-visit": "^5.0.0",
|
|
88
84
|
"unist-util-visit-children": "^3.0.0",
|
|
89
|
-
"@rspress/runtime": "2.0.0-beta.
|
|
90
|
-
"@rspress/shared": "2.0.0-beta.
|
|
91
|
-
"@rspress/theme-default": "2.0.0-beta.
|
|
85
|
+
"@rspress/runtime": "2.0.0-beta.28",
|
|
86
|
+
"@rspress/shared": "2.0.0-beta.28",
|
|
87
|
+
"@rspress/theme-default": "2.0.0-beta.28"
|
|
92
88
|
},
|
|
93
89
|
"devDependencies": {
|
|
94
90
|
"@microsoft/api-extractor": "^7.52.10",
|
|
95
|
-
"@rslib/core": "0.
|
|
91
|
+
"@rslib/core": "0.12.1",
|
|
96
92
|
"@types/hast": "^3.0.4",
|
|
97
93
|
"@types/html-to-text": "^9.0.4",
|
|
98
94
|
"@types/jest": "~29.5.14",
|
|
99
95
|
"@types/lodash-es": "^4.17.12",
|
|
100
96
|
"@types/mdast": "^4.0.4",
|
|
101
97
|
"@types/node": "^22.8.1",
|
|
102
|
-
"@types/react": "^19.1.
|
|
98
|
+
"@types/react": "^19.1.10",
|
|
103
99
|
"@types/react-dom": "^19.1.7",
|
|
104
100
|
"execa": "8.0.1",
|
|
105
101
|
"mdast-util-directive": "^3.1.0",
|