@rspress/core 2.0.0-beta.27 → 2.0.0-beta.29

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 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
- 980: 0
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('{"i8":"2.0.0-beta.27"}');
155
- const RSPRESS_VERSION = package_namespaceObject.i8;
153
+ var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.29"}');
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 = `{
@@ -467,8 +466,13 @@ class RouteService {
467
466
  getRoutePages() {
468
467
  return Array.from(this.routeData.values());
469
468
  }
470
- isExistRoute(routePath) {
471
- return this.routeData.has(routePath);
469
+ isExistRoute(link) {
470
+ function linkToRoutePath(routePath) {
471
+ return decodeURIComponent(routePath.split('#')[0]).replace(/\.html$/, '').replace(/\/index$/, '/');
472
+ }
473
+ const cleanLinkPath = linkToRoutePath(link);
474
+ if (!this.routeData.has((0, shared_.removeTrailingSlash)(cleanLinkPath)) && !this.routeData.has((0, shared_.addTrailingSlash)(cleanLinkPath))) return false;
475
+ return true;
472
476
  }
473
477
  generateRoutesCode() {
474
478
  return this.generateRoutesCodeByRouteMeta(this.getRoutes());
@@ -909,6 +913,65 @@ async function modifyConfigWithAutoNavSide(config) {
909
913
  }
910
914
  return config;
911
915
  }
916
+ const globalStylesVMPlugin = (context)=>({
917
+ ["virtual-global-styles"]: ()=>{
918
+ const { config, pluginDriver } = context;
919
+ const globalStylesByPlugins = pluginDriver.globalStyles();
920
+ const moduleContent = [
921
+ config?.globalStyles,
922
+ ...globalStylesByPlugins
923
+ ].filter(Boolean).map((source)=>`import ${JSON.stringify(source)};`).join('');
924
+ return moduleContent;
925
+ }
926
+ });
927
+ const globalUIComponentsVMPlugin = (context)=>({
928
+ ["virtual-global-components"]: ()=>{
929
+ const { config, pluginDriver } = context;
930
+ let index = 0;
931
+ const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();
932
+ const globalComponents = [
933
+ ...config?.globalUIComponents || [],
934
+ ...globalUIComponentsByPlugins
935
+ ];
936
+ const moduleContent = globalComponents.map((source)=>{
937
+ const name = `Comp_${index}`;
938
+ if (Array.isArray(source)) return `import ${name} from ${JSON.stringify(source[0])};
939
+ const Props_${index++} = ${JSON.stringify(source[1])};\n`;
940
+ index++;
941
+ return `import ${name} from ${JSON.stringify(source)};\n`;
942
+ }).concat(`export default [${Array.from({
943
+ length: index
944
+ }, (_, i)=>{
945
+ if (Array.isArray(globalComponents[i])) return `[Comp_${i}, Props_${i}]`;
946
+ return `Comp_${i}`;
947
+ }).join(', ')}];`).join('');
948
+ return moduleContent;
949
+ }
950
+ });
951
+ const i18n_require = createRequire(import.meta.url);
952
+ const DEFAULT_I18N_SOURCE = (0, external_node_path_.join)(process.cwd(), 'i18n.json');
953
+ function getI18nData(docConfig) {
954
+ const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
955
+ try {
956
+ delete i18n_require.cache[i18nSourcePath];
957
+ const i18nSource = i18n_require(i18nSourcePath);
958
+ return i18nSource;
959
+ } catch (e) {
960
+ logger.debug('getI18nData Failed: \n', e);
961
+ return {};
962
+ }
963
+ }
964
+ const i18nVMPlugin = (context)=>{
965
+ const { config } = context;
966
+ return {
967
+ ["virtual-i18n-text"]: ({ addDependency, addMissingDependency })=>{
968
+ addDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
969
+ addMissingDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
970
+ const i18nData = getI18nData(config);
971
+ return `export default ${JSON.stringify(i18nData, null, 2)}`;
972
+ }
973
+ };
974
+ };
912
975
  var external_node_fs_ = __webpack_require__("node:fs");
913
976
  let flattenMdxContent_resolver;
914
977
  let startFlatten = false;
@@ -1099,41 +1162,128 @@ async function extractPageData(routeService, options) {
1099
1162
  function createHash_createHash(str) {
1100
1163
  return createHash('sha256').update(str).digest('hex').slice(0, 8);
1101
1164
  }
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
- }
1165
+ function deletePrivateField(obj) {
1166
+ if ('object' != typeof obj || null === obj) return obj;
1167
+ const newObj = {
1168
+ ...obj
1169
+ };
1170
+ for(const key in newObj)if (key.startsWith('_')) delete newObj[key];
1171
+ return newObj;
1125
1172
  }
1126
- const i18nVMPlugin = (context)=>{
1127
- const { config } = context;
1173
+ async function createPageData(context) {
1174
+ const { config, alias, userDocRoot, routeService, pluginDriver } = context;
1175
+ const userConfig = config;
1176
+ const tempSearchObj = Object.assign({}, userConfig.search);
1177
+ if (tempSearchObj) tempSearchObj.searchHooks = void 0;
1178
+ const replaceRules = userConfig?.replaceRules || [];
1179
+ const searchConfig = userConfig?.search || {};
1180
+ const searchCodeBlocks = 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : true;
1181
+ const pages = await extractPageData(routeService, {
1182
+ replaceRules,
1183
+ alias,
1184
+ root: userDocRoot,
1185
+ searchCodeBlocks
1186
+ });
1187
+ await pluginDriver.modifySearchIndexData(pages);
1188
+ const versioned = 'boolean' != typeof userConfig.search && userConfig.search?.versioned;
1189
+ const groupedPages = groupBy(pages, (page)=>{
1190
+ if (page.frontmatter?.pageType === 'home') return 'noindex';
1191
+ const version = versioned ? page.version : '';
1192
+ const lang = page.lang || '';
1193
+ return `${version}###${lang}`;
1194
+ });
1195
+ delete groupedPages.noindex;
1196
+ const indexHashByGroup = {};
1197
+ const searchIndex = {};
1198
+ await Promise.all(Object.keys(groupedPages).map(async (group)=>{
1199
+ const stringifiedIndex = JSON.stringify(groupedPages[group].map(deletePrivateField));
1200
+ const indexHash = createHash_createHash(stringifiedIndex);
1201
+ indexHashByGroup[group] = indexHash;
1202
+ const [version, lang] = group.split('###');
1203
+ const indexVersion = version ? `.${version.replace('.', '_')}` : '';
1204
+ const indexLang = lang ? `.${lang}` : '';
1205
+ const filename = `${shared_.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`;
1206
+ searchIndex[filename] = stringifiedIndex;
1207
+ }));
1208
+ await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
1209
+ const filepaths = [];
1210
+ const pageData = {
1211
+ pages: pages.map((page)=>{
1212
+ const { content: _content, _filepath, _html, _flattenContent, ...rest } = page;
1213
+ filepaths.push(_filepath);
1214
+ return rest;
1215
+ })
1216
+ };
1128
1217
  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)}`;
1218
+ filepaths,
1219
+ pageData,
1220
+ searchIndex,
1221
+ indexHashByGroup
1222
+ };
1223
+ }
1224
+ const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
1225
+ const ref = {
1226
+ pageData: null,
1227
+ searchIndex: null,
1228
+ indexHashByGroup: null,
1229
+ filepaths: []
1230
+ };
1231
+ const searchIndexRsbuildPlugin = {
1232
+ name: 'rsbuild-plugin-searchIndex',
1233
+ async setup (api) {
1234
+ api.modifyBundlerChain(async (bundlerChain)=>{
1235
+ const alias = bundlerChain.resolve.alias.entries();
1236
+ const { pageData, indexHashByGroup, searchIndex, filepaths } = await createPageData({
1237
+ config,
1238
+ alias: alias,
1239
+ userDocRoot,
1240
+ routeService,
1241
+ pluginDriver
1242
+ });
1243
+ ref.pageData = pageData;
1244
+ ref.searchIndex = searchIndex;
1245
+ ref.indexHashByGroup = indexHashByGroup;
1246
+ ref.filepaths = filepaths;
1247
+ api.processAssets({
1248
+ stage: 'report',
1249
+ environments: [
1250
+ 'web'
1251
+ ]
1252
+ }, ({ compilation, compiler })=>{
1253
+ for (const [filename, stringifiedIndex] of Object.entries(searchIndex))compilation.emitAsset(`static/${filename}`, new compiler.webpack.sources.RawSource(stringifiedIndex));
1254
+ });
1255
+ });
1134
1256
  }
1135
1257
  };
1258
+ return [
1259
+ searchIndexRsbuildPlugin,
1260
+ pluginVirtualModule({
1261
+ tempDir: '.rspress',
1262
+ virtualModules: {
1263
+ ["virtual-page-data"]: async ({ addDependency })=>{
1264
+ for (const file of ref.filepaths)addDependency(file);
1265
+ return `export const pageData = ${JSON.stringify(ref.pageData, null, 2)};
1266
+ export const searchIndexHash = ${JSON.stringify(ref.indexHashByGroup, null, 2)};`;
1267
+ }
1268
+ }
1269
+ })
1270
+ ];
1271
+ };
1272
+ const routeListVMPlugin = (context)=>{
1273
+ const { routeService } = context;
1274
+ return {
1275
+ ["virtual-routes"]: ()=>routeService.generateRoutesCode()
1276
+ };
1136
1277
  };
1278
+ const searchHookVMPlugin = (context)=>({
1279
+ ["virtual-search-hooks"]: ()=>{
1280
+ const { config } = context;
1281
+ let content = 'export const onSearch = () => {};';
1282
+ const searchHooks = 'object' == typeof config.search && config.search?.searchHooks;
1283
+ if (searchHooks) content = `export * from ${JSON.stringify(external_node_path_["default"].posix.normalize(searchHooks))}`;
1284
+ return content;
1285
+ }
1286
+ });
1137
1287
  function normalizeThemeConfig(docConfig) {
1138
1288
  const { locales: siteLocales, lang, replaceRules = [], multiVersion } = docConfig;
1139
1289
  const { versions = [] } = multiVersion || {};
@@ -1142,38 +1292,41 @@ function normalizeThemeConfig(docConfig) {
1142
1292
  const { themeConfig } = docConfig;
1143
1293
  const locales = siteLocales ?? (themeConfig?.locales || []);
1144
1294
  const i18nTextData = getI18nData(docConfig);
1145
- const normalizeLinkPrefix = (link = '', currentLang = '')=>{
1295
+ const normalizeLinkPrefix = (link, currentLang)=>{
1146
1296
  const normalizedLink = (0, shared_.slash)(link);
1147
1297
  if (!currentLang || !link || normalizedLink.startsWith(`/${currentLang}`) || (0, shared_.isExternalUrl)(normalizedLink) || hasMultiVersion) return normalizedLink;
1148
1298
  return lang === currentLang ? normalizedLink : `/${currentLang}${(0, shared_.addLeadingSlash)(normalizedLink)}`;
1149
1299
  };
1150
- const getI18nText = (key = '', currentLang = '')=>{
1300
+ const getI18nText = (key, currentLang)=>{
1151
1301
  const text = i18nTextData[key]?.[currentLang];
1152
1302
  return text || key;
1153
1303
  };
1154
- const normalizeSidebar = (sidebar, currentLang = '')=>{
1304
+ const cleanUrls = false;
1305
+ const transformLink = (link, currentLang)=>(0, shared_.normalizeHref)(normalizeLinkPrefix(link, currentLang), cleanUrls);
1306
+ const textReplace = (text, currentLang)=>applyReplaceRules(getI18nText(text, currentLang), replaceRules);
1307
+ const normalizeSidebar = (sidebar, currentLang)=>{
1155
1308
  const normalizedSidebar = {};
1156
1309
  if (!sidebar) return {};
1157
1310
  const normalizeSidebarItem = (item)=>{
1158
1311
  if ('object' == typeof item && 'dividerType' in item) return item;
1159
1312
  if ('object' == typeof item && 'sectionHeaderText' in item) {
1160
- item.sectionHeaderText = applyReplaceRules(getI18nText(item.sectionHeaderText, currentLang), replaceRules);
1313
+ item.sectionHeaderText = textReplace(item.sectionHeaderText, currentLang);
1161
1314
  return item;
1162
1315
  }
1163
1316
  if ('object' == typeof item && 'items' in item) return {
1164
1317
  ...item,
1165
- text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
1166
- link: normalizeLinkPrefix(item.link),
1318
+ text: textReplace(item.text, currentLang),
1319
+ ...'link' in item && item.link ? {
1320
+ link: transformLink(item.link, currentLang)
1321
+ } : {},
1167
1322
  collapsed: item.collapsed ?? false,
1168
1323
  collapsible: item.collapsible ?? true,
1169
- tag: item.tag,
1170
1324
  items: item.items.map((subItem)=>normalizeSidebarItem(subItem))
1171
1325
  };
1172
1326
  return {
1173
1327
  ...item,
1174
- text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
1175
- link: normalizeLinkPrefix(item.link),
1176
- tag: item.tag
1328
+ text: textReplace(item.text, currentLang),
1329
+ link: transformLink(item.link, currentLang)
1177
1330
  };
1178
1331
  };
1179
1332
  const normalizeSidebar = (sidebar)=>{
@@ -1187,24 +1340,18 @@ function normalizeThemeConfig(docConfig) {
1187
1340
  };
1188
1341
  const normalizeNav = (nav, currentLang)=>{
1189
1342
  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 {
1343
+ const transformNavItem = (navItem)=>({
1198
1344
  ...navItem,
1199
- text,
1200
- items: navItem.items.map((item)=>({
1201
- ...item,
1202
- text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
1203
- link: normalizeLinkPrefix(item.link, currentLang)
1204
- }))
1205
- };
1206
- return navItem;
1207
- };
1345
+ ...navItem.text ? {
1346
+ text: textReplace(navItem.text, currentLang)
1347
+ } : {},
1348
+ ...'link' in navItem ? {
1349
+ link: transformLink(navItem.link, currentLang)
1350
+ } : {},
1351
+ ...'items' in navItem ? {
1352
+ items: navItem.items.map((item)=>transformNavItem(item))
1353
+ } : {}
1354
+ });
1208
1355
  if (Array.isArray(nav)) return nav.map(transformNavItem);
1209
1356
  return Object.entries(nav).reduce((acc, [key, value])=>{
1210
1357
  acc[key] = value.map(transformNavItem);
@@ -1216,63 +1363,24 @@ function normalizeThemeConfig(docConfig) {
1216
1363
  return {
1217
1364
  lang: currentLang,
1218
1365
  label,
1219
- ...localeInThemeConfig || {},
1366
+ ...localeInThemeConfig,
1220
1367
  sidebar: normalizeSidebar(localeInThemeConfig?.sidebar ?? themeConfig.sidebar, currentLang),
1221
1368
  nav: normalizeNav(localeInThemeConfig?.nav ?? themeConfig.nav, currentLang)
1222
1369
  };
1223
1370
  });
1224
1371
  else {
1225
- themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar);
1226
- themeConfig.nav = normalizeNav(themeConfig?.nav);
1372
+ themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar, '');
1373
+ themeConfig.nav = normalizeNav(themeConfig?.nav, '');
1227
1374
  }
1228
1375
  return themeConfig;
1229
1376
  }
1230
- function deletePrivateField(obj) {
1231
- if ('object' != typeof obj || null === obj) return obj;
1232
- const newObj = {
1233
- ...obj
1234
- };
1235
- for(const key in newObj)if (key.startsWith('_')) delete newObj[key];
1236
- return newObj;
1237
- }
1238
- async function siteDataVMPlugin(context) {
1239
- const { config, alias, userDocRoot, routeService, pluginDriver } = context;
1240
- const userConfig = config;
1377
+ async function createSiteData(userConfig) {
1241
1378
  const tempSearchObj = Object.assign({}, userConfig.search);
1242
1379
  if (tempSearchObj) tempSearchObj.searchHooks = void 0;
1243
- const replaceRules = userConfig?.replaceRules || [];
1244
- const searchConfig = userConfig?.search || {};
1245
- const searchCodeBlocks = 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : true;
1246
- const pages = await extractPageData(routeService, {
1247
- replaceRules,
1248
- alias,
1249
- root: userDocRoot,
1250
- searchCodeBlocks
1251
- });
1252
- await pluginDriver.modifySearchIndexData(pages);
1253
- const versioned = 'boolean' != typeof userConfig.search && userConfig.search?.versioned;
1254
- const groupedPages = groupBy(pages, (page)=>{
1255
- if (page.frontmatter?.pageType === 'home') return 'noindex';
1256
- const version = versioned ? page.version : '';
1257
- const lang = page.lang || '';
1258
- return `${version}###${lang}`;
1259
- });
1260
- delete groupedPages.noindex;
1261
- const indexHashByGroup = {};
1262
- await Promise.all(Object.keys(groupedPages).map(async (group)=>{
1263
- const stringifiedIndex = JSON.stringify(groupedPages[group].map(deletePrivateField));
1264
- const indexHash = createHash_createHash(stringifiedIndex);
1265
- indexHashByGroup[group] = indexHash;
1266
- const [version, lang] = group.split('###');
1267
- const indexVersion = version ? `.${version.replace('.', '_')}` : '';
1268
- const indexLang = lang ? `.${lang}` : '';
1269
- await node_fs_promises.mkdir(constants_TEMP_DIR, {
1270
- recursive: true
1271
- });
1272
- await node_fs_promises.writeFile(external_node_path_["default"].join(constants_TEMP_DIR, `${shared_.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`), stringifiedIndex);
1273
- }));
1274
- await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
1380
+ const { base } = userConfig;
1381
+ const normalizedBase = (0, shared_.addTrailingSlash)((0, shared_.addLeadingSlash)(base ?? '/'));
1275
1382
  const siteData = {
1383
+ base: normalizedBase,
1276
1384
  title: userConfig?.title || '',
1277
1385
  description: userConfig?.description || '',
1278
1386
  icon: getIconUrlPath(userConfig?.icon) || '',
@@ -1289,13 +1397,6 @@ async function siteDataVMPlugin(context) {
1289
1397
  search: tempSearchObj ?? {
1290
1398
  mode: 'local'
1291
1399
  },
1292
- pages: pages.map((page)=>{
1293
- const { content: _content, _filepath, _html, _flattenContent, ...rest } = page;
1294
- return isProduction() ? rest : {
1295
- ...rest,
1296
- _filepath
1297
- };
1298
- }),
1299
1400
  markdown: {
1300
1401
  showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,
1301
1402
  defaultWrapCode: userConfig?.markdown?.defaultWrapCode ?? false,
@@ -1303,132 +1404,54 @@ async function siteDataVMPlugin(context) {
1303
1404
  }
1304
1405
  };
1305
1406
  return {
1306
- [`${types_RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(siteData, null, 2)}`,
1307
- [types_RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByGroup, null, 2)}`
1407
+ siteData
1308
1408
  };
1309
1409
  }
1310
- const runtimeModuleFactory = [
1311
- siteDataVMPlugin
1312
- ];
1313
- function rsbuildPluginDocVM(factoryContext) {
1410
+ const siteDataVMPlugin = (context)=>{
1411
+ const { config } = context;
1314
1412
  return {
1315
- name: 'rsbuild-plugin-doc-vm',
1316
- setup (api) {
1317
- api.modifyBundlerChain(async (bundlerChain)=>{
1318
- const alias = bundlerChain.resolve.alias.entries();
1319
- const runtimeModule = {};
1320
- for (const factory of runtimeModuleFactory){
1321
- const moduleResult = await factory({
1322
- ...factoryContext,
1323
- alias: alias
1324
- });
1325
- Object.assign(runtimeModule, moduleResult);
1326
- }
1327
- bundlerChain.plugin('rspress-runtime-module').use(new RspackVirtualModulePlugin(runtimeModule));
1328
- });
1413
+ ["virtual-site-data"]: async ()=>{
1414
+ const { siteData } = await createSiteData(config);
1415
+ return `export default ${JSON.stringify(siteData, null, 2)}`;
1329
1416
  }
1330
1417
  };
1418
+ };
1419
+ const presetIcons = {
1420
+ 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"/>',
1421
+ 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"/>',
1422
+ 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"/>',
1423
+ 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"/>',
1424
+ 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"/>',
1425
+ 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"/>',
1426
+ 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"/>',
1427
+ 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"/>',
1428
+ 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"/>',
1429
+ 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"/>',
1430
+ 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"/>',
1431
+ 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"/>',
1432
+ 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"/>',
1433
+ 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"/>',
1434
+ 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>',
1435
+ 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"/>',
1436
+ 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"/>',
1437
+ 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"/>'
1438
+ };
1439
+ const formatIconName = (icon)=>icon.toLowerCase();
1440
+ function getSocialIcons(socialLinks = []) {
1441
+ const icons = {};
1442
+ for (const link of socialLinks)if ('string' == typeof link.icon) {
1443
+ const pathContent = presetIcons[formatIconName(link.icon)];
1444
+ if (!pathContent) throw new Error(`Icon "${link.icon}" not found in preset icons.`);
1445
+ icons[link.icon] = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 24 24">${pathContent}</svg>`;
1446
+ }
1447
+ return icons;
1331
1448
  }
1332
- async function getVirtualModulesFromPlugins(pluginDriver) {
1333
- const runtimeModule = {};
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;
1449
+ const socialLinksVMPlugin = (context)=>{
1450
+ const { config } = context;
1378
1451
  return {
1379
- [types_RuntimeModuleID.Routes]: ()=>routeService.generateRoutesCode()
1452
+ ["virtual-social-links"]: ()=>`export default ${JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks), null, 2)}`
1380
1453
  };
1381
1454
  };
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
1455
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
1433
1456
  return new Promise((resolve_, reject_)=>{
1434
1457
  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 +1920,21 @@ const detectCustomIcon = async (customThemeDir)=>{
1897
1920
  });
1898
1921
  return alias;
1899
1922
  };
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
1923
  function isPluginIncluded(config, pluginName) {
1931
1924
  return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
1932
1925
  }
1933
1926
  const initRsbuild_require = createRequire(import.meta.url);
1934
1927
  const initRsbuild_filename = (0, external_node_url_.fileURLToPath)(import.meta.url);
1935
1928
  const initRsbuild_dirname = external_node_path_["default"].dirname(initRsbuild_filename);
1929
+ async function getVirtualModulesFromPlugins(pluginDriver) {
1930
+ const runtimeModule = {};
1931
+ const modulesByPlugin = await pluginDriver.addRuntimeModules();
1932
+ Object.keys(modulesByPlugin).forEach((key)=>{
1933
+ if (runtimeModule[key]) throw new Error(`The runtime module ${key} is duplicated, please check your plugin`);
1934
+ runtimeModule[key] = ()=>modulesByPlugin[key];
1935
+ });
1936
+ return runtimeModule;
1937
+ }
1936
1938
  async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
1937
1939
  const cwd = process.cwd();
1938
1940
  const CUSTOM_THEME_DIR = config?.themeDir ?? external_node_path_["default"].join(process.cwd(), 'theme');
@@ -1966,17 +1968,23 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1966
1968
  ...isPluginIncluded(config, PLUGIN_REACT_NAME) ? [] : [
1967
1969
  pluginReact()
1968
1970
  ],
1969
- rsbuildPluginDocVM(context),
1971
+ rsbuildPluginDocVM({
1972
+ config,
1973
+ pluginDriver,
1974
+ routeService,
1975
+ userDocRoot
1976
+ }),
1970
1977
  pluginVirtualModule({
1971
1978
  tempDir: '.rspress/runtime',
1972
1979
  virtualModules: {
1980
+ ...socialLinksVMPlugin(context),
1973
1981
  ...i18nVMPlugin(context),
1974
1982
  ...globalUIComponentsVMPlugin(context),
1975
1983
  ...globalStylesVMPlugin(context),
1976
1984
  ...searchHookVMPlugin(context),
1977
1985
  ...routeListVMPlugin(context),
1978
1986
  ...await getVirtualModulesFromPlugins(pluginDriver),
1979
- ...runtimeConfigVMPlugin(context)
1987
+ ...siteDataVMPlugin(context)
1980
1988
  }
1981
1989
  }),
1982
1990
  enableSSG ? rsbuildPluginSSG({
@@ -1998,9 +2006,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1998
2006
  },
1999
2007
  dev: {
2000
2008
  lazyCompilation: 'false' !== process.env.RSPRESS_LAZY_COMPILATION,
2001
- setupMiddlewares: (middlewares)=>{
2002
- middlewares.unshift(serveSearchIndexMiddleware(config));
2003
- },
2004
2009
  cliShortcuts: {
2005
2010
  custom: (shortcuts)=>shortcuts.filter(({ key })=>'r' !== key)
2006
2011
  }
@@ -2044,8 +2049,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
2044
2049
  external_node_path_["default"].join(cwd, 'node_modules', shared_.RSPRESS_TEMP_DIR)
2045
2050
  ],
2046
2051
  define: {
2047
- 'process.env.TEST': JSON.stringify(process.env.TEST),
2048
- 'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks))
2052
+ 'process.env.TEST': JSON.stringify(process.env.TEST)
2049
2053
  }
2050
2054
  },
2051
2055
  performance: {
@@ -2218,13 +2222,13 @@ class PluginDriver {
2218
2222
  const mediumZoomConfig = config?.mediumZoom ?? true;
2219
2223
  if (enableLastUpdated) {
2220
2224
  const { pluginLastUpdated } = await Promise.all([
2221
- __webpack_require__.e("94"),
2222
- __webpack_require__.e("208")
2225
+ __webpack_require__.e("101"),
2226
+ __webpack_require__.e("220")
2223
2227
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/node/last-updated/index.ts"));
2224
2228
  this.addPlugin(pluginLastUpdated());
2225
2229
  }
2226
2230
  if (mediumZoomConfig) {
2227
- const { pluginMediumZoom } = await __webpack_require__.e("309").then(__webpack_require__.bind(__webpack_require__, "./src/node/medium-zoom/index.ts"));
2231
+ const { pluginMediumZoom } = await __webpack_require__.e("335").then(__webpack_require__.bind(__webpack_require__, "./src/node/medium-zoom/index.ts"));
2228
2232
  this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
2229
2233
  }
2230
2234
  (config.plugins || []).forEach((plugin)=>{
@@ -2391,7 +2395,6 @@ async function bundle(docDirectory, config, pluginDriver, enableSSG) {
2391
2395
  await pluginDriver.beforeBuild();
2392
2396
  await rsbuild.build();
2393
2397
  } finally{
2394
- await writeSearchIndex(config);
2395
2398
  await checkLanguageParity(config);
2396
2399
  }
2397
2400
  await pluginDriver.afterBuild();
@@ -2429,7 +2432,6 @@ async function dev(options) {
2429
2432
  });
2430
2433
  return server;
2431
2434
  } finally{
2432
- await writeSearchIndex(modifiedConfig);
2433
2435
  await checkLanguageParity(modifiedConfig);
2434
2436
  }
2435
2437
  }
@@ -2488,7 +2490,7 @@ Please use below:
2488
2490
  });
2489
2491
  await Promise.all(promiseList);
2490
2492
  };
2491
- function link_checkDeadLinks(checkDeadLinks, internalLinks, filePath, routeService) {
2493
+ function link_checkDeadLinks(checkDeadLinks, internalLinks, filePath) {
2492
2494
  const errorInfos = [];
2493
2495
  const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
2494
2496
  const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
@@ -2499,10 +2501,8 @@ function link_checkDeadLinks(checkDeadLinks, internalLinks, filePath, routeServi
2499
2501
  ].forEach(([nodeUrl, link])=>{
2500
2502
  if (excludesUrl?.has(nodeUrl)) return;
2501
2503
  if (excludesFn?.(nodeUrl)) return;
2502
- const cleanLinkPath = linkToRoutePath(link);
2503
- if (!cleanLinkPath) return;
2504
2504
  if (!nodeUrl.startsWith('/') && /^\w/.test(nodeUrl)) possibleBreakingChange = true;
2505
- if (!routeService.isExistRoute((0, shared_.removeTrailingSlash)(cleanLinkPath)) && !routeService.isExistRoute((0, shared_.addTrailingSlash)(cleanLinkPath))) errorInfos.push([
2505
+ errorInfos.push([
2506
2506
  nodeUrl,
2507
2507
  link
2508
2508
  ]);
@@ -2531,7 +2531,7 @@ function looseMarkdownLink(url, routeService, filePath) {
2531
2531
  }
2532
2532
  return url;
2533
2533
  }
2534
- function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, internalLinks, __base) {
2534
+ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, deadLinks, __base) {
2535
2535
  if (!nodeUrl) return '';
2536
2536
  if (nodeUrl.startsWith('#')) return nodeUrl;
2537
2537
  let { url, hash } = (0, shared_.parseUrl)(nodeUrl);
@@ -2550,28 +2550,28 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, i
2550
2550
  url = (0, shared_.normalizeHref)(url, false);
2551
2551
  url = url.replace(/\.html$/, cleanUrls);
2552
2552
  }
2553
- internalLinks.set(nodeUrl, url);
2553
+ if (!routeService.isExistRoute(url)) {
2554
+ deadLinks.set(nodeUrl, url);
2555
+ return nodeUrl;
2556
+ }
2554
2557
  if (hash) url += `#${hash}`;
2555
2558
  if (__base) url = (0, shared_.withBase)(url, __base);
2556
2559
  return url;
2557
2560
  }
2558
- function linkToRoutePath(routePath) {
2559
- return decodeURIComponent(routePath.split('#')[0]).replace(/\.html$/, '').replace(/\/index$/, '/');
2560
- }
2561
2561
  const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, __base })=>(tree, file)=>{
2562
2562
  const { checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
2563
- const internalLinks = new Map();
2563
+ const deadLinks = new Map();
2564
2564
  visit(tree, 'link', (node)=>{
2565
2565
  const { url: nodeUrl } = node;
2566
- const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, internalLinks, __base);
2566
+ const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
2567
2567
  node.url = link;
2568
2568
  });
2569
2569
  visit(tree, 'definition', (node)=>{
2570
2570
  const { url: nodeUrl } = node;
2571
- const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, internalLinks, __base);
2571
+ const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
2572
2572
  node.url = link;
2573
2573
  });
2574
- if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, internalLinks, file.path, routeService);
2574
+ if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file.path);
2575
2575
  };
2576
2576
  async function serve(options) {
2577
2577
  const { config, port: userPort, host: userHost, configFilePath } = options;