@rspress/core 0.1.1 → 1.0.0-beta.0

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.
Files changed (42) hide show
  1. package/dist/index.js +62 -24
  2. package/dist/index.js.map +1 -1
  3. package/dist/loader.d.ts +1 -1
  4. package/dist/loader.js +17 -33
  5. package/dist/loader.js.map +1 -1
  6. package/dist/runtime/App.js +4 -4
  7. package/dist/runtime/Content.js +14 -2
  8. package/dist/runtime/hooks.d.ts +17 -0
  9. package/dist/runtime/hooks.js +27 -1
  10. package/dist/runtime/index.d.ts +1 -1
  11. package/dist/runtime/index.js +1 -1
  12. package/dist/runtime/utils.d.ts +3 -2
  13. package/dist/runtime/utils.js +6 -2
  14. package/dist/theme/bundle.css +44 -4
  15. package/dist/theme/bundle.d.ts +6 -1
  16. package/dist/theme/bundle.js +150 -77
  17. package/dist/theme/bundle.js.map +1 -1
  18. package/package.json +7 -7
  19. package/src/runtime/App.tsx +5 -6
  20. package/src/runtime/Content.tsx +24 -2
  21. package/src/runtime/global.d.ts +4 -5
  22. package/src/runtime/hooks.ts +67 -1
  23. package/src/runtime/index.ts +1 -1
  24. package/src/runtime/utils.ts +9 -8
  25. package/src/theme-default/components/DocFooter/index.tsx +1 -1
  26. package/src/theme-default/components/HomeHero/index.tsx +1 -1
  27. package/src/theme-default/components/Link/index.module.scss +0 -1
  28. package/src/theme-default/components/Link/index.tsx +21 -2
  29. package/src/theme-default/components/Nav/NavMenuSingleItem.tsx +1 -1
  30. package/src/theme-default/components/Nav/index.tsx +19 -5
  31. package/src/theme-default/components/Overview/index.tsx +1 -1
  32. package/src/theme-default/components/Search/logic/search.ts +1 -1
  33. package/src/theme-default/components/Sidebar/SidebarGroup.tsx +1 -1
  34. package/src/theme-default/components/Sidebar/SidebarItem.tsx +1 -1
  35. package/src/theme-default/index.ts +2 -0
  36. package/src/theme-default/layout/DocLayout/docComponents/index.module.scss +4 -0
  37. package/src/theme-default/layout/DocLayout/docComponents/link.tsx +14 -23
  38. package/src/theme-default/layout/DocLayout/index.module.scss +46 -0
  39. package/src/theme-default/layout/HomeLayout/index.tsx +1 -0
  40. package/src/theme-default/logic/index.ts +1 -0
  41. package/src/theme-default/logic/sideEffects.ts +7 -0
  42. package/src/theme-default/logic/usePathUtils.ts +73 -0
@@ -50,7 +50,7 @@ import globalComponents from "virtual-global-components";
50
50
 
51
51
  // src/theme-default/layout/DocLayout/index.tsx
52
52
  import { jsx as _jsx14, jsxs as _jsxs8 } from "react/jsx-runtime";
53
- import { useLocation as useLocation3 } from "react-router-dom";
53
+ import { useLocation as useLocation4 } from "react-router-dom";
54
54
  import { useEffect as useEffect7, useState as useState4 } from "react";
55
55
  import { MDXProvider } from "@mdx-js/react";
56
56
  import { getCustomMDXComponent } from "@theme";
@@ -315,6 +315,13 @@ function bindingWindowScroll() {
315
315
  history.pushState(null, "", hash);
316
316
  scrollTo(link, hash, true);
317
317
  window.dispatchEvent(new Event("hashchange"));
318
+ } else {
319
+ window.addEventListener("RspressReloadContent", () => {
320
+ if (location.hash.length > 1) {
321
+ const ele = document.getElementById(location.hash.slice(1));
322
+ scrollToTarget(ele, false);
323
+ }
324
+ });
318
325
  }
319
326
  }
320
327
  }
@@ -395,6 +402,58 @@ function setup() {
395
402
  bindingWindowScroll();
396
403
  }
397
404
 
405
+ // src/theme-default/logic/usePathUtils.ts
406
+ import { isExternalUrl } from "@rspress/shared";
407
+ import { removeBase, useLang, usePageData as usePageData4, normalizeHrefInRuntime as normalizeHref, useVersion, withBase as withBase3 } from "@/runtime";
408
+ function usePathUtils() {
409
+ const currentLang = useLang();
410
+ const currentVersion = useVersion();
411
+ const pageData = usePageData4();
412
+ const defaultLang = pageData.siteData.lang;
413
+ const defaultVersion = pageData.siteData.multiVersion.default;
414
+ const normalizeLinkHref = (rawHref) => {
415
+ let href = rawHref;
416
+ if ((defaultLang || defaultVersion) && !isExternalUrl(href) && !href.startsWith("#")) {
417
+ href = removeBase(href);
418
+ const linkParts = href.split("/").filter(Boolean);
419
+ let versionPart = "";
420
+ let langPart = "";
421
+ let purePathPart = "";
422
+ if (defaultVersion) {
423
+ if (currentVersion !== defaultVersion) {
424
+ versionPart = currentVersion;
425
+ if (linkParts[0] === currentVersion) {
426
+ linkParts.shift();
427
+ }
428
+ } else if (linkParts[0] === defaultVersion) {
429
+ linkParts.shift();
430
+ }
431
+ }
432
+ if (defaultLang) {
433
+ if (currentLang !== defaultLang) {
434
+ langPart = currentLang;
435
+ if (linkParts[0] === currentLang) {
436
+ linkParts.shift();
437
+ }
438
+ } else if (linkParts[0] === defaultLang) {
439
+ linkParts.shift();
440
+ }
441
+ }
442
+ purePathPart = linkParts.join("/");
443
+ return normalizeHref(withBase3([
444
+ versionPart,
445
+ langPart,
446
+ purePathPart
447
+ ].filter(Boolean).join("/")));
448
+ } else {
449
+ return href;
450
+ }
451
+ };
452
+ return {
453
+ normalizeLinkHref
454
+ };
455
+ }
456
+
398
457
  // src/theme-default/logic/utils.ts
399
458
  import { isEqualPath as isEqualPath3 } from "@/runtime";
400
459
  function isActive(currentPath, targetLink, strict = false) {
@@ -527,7 +586,7 @@ function EditLink() {
527
586
 
528
587
  // src/theme-default/components/Link/index.tsx
529
588
  import { jsx as _jsx4 } from "react/jsx-runtime";
530
- import { matchRoutes, useNavigate } from "react-router-dom";
589
+ import { matchRoutes, useLocation as useLocation3, useNavigate } from "react-router-dom";
531
590
  import nprogress from "nprogress";
532
591
  import { routes } from "virtual-routes";
533
592
 
@@ -535,7 +594,7 @@ import { routes } from "virtual-routes";
535
594
  var index_module_default2 = { "link": "link_b3367" };
536
595
 
537
596
  // src/theme-default/components/Link/index.tsx
538
- import { normalizeHref, normalizeRoutePath, withBase as withBase3 } from "@/runtime";
597
+ import { normalizeHrefInRuntime as normalizeHref2, normalizeRoutePath, withBase as withBase4 } from "@/runtime";
539
598
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
540
599
  try {
541
600
  var info = gen[key](arg);
@@ -574,11 +633,21 @@ function Link(props) {
574
633
  const isExternal = EXTERNAL_URL_RE.test(href);
575
634
  const target = isExternal ? "_blank" : "";
576
635
  const rel = isExternal ? "noopener noreferrer" : void 0;
577
- const withBaseUrl = isExternal ? href : withBase3(normalizeHref(href));
636
+ const withBaseUrl = isExternal ? href : withBase4(normalizeHref2(href));
578
637
  const navigate = useNavigate();
638
+ const { pathname } = useLocation3();
639
+ const inCurrentPage = withBaseUrl.startsWith(pathname);
579
640
  const handleNavigate = function() {
580
641
  var _ref = _async_to_generator(function* (e) {
581
642
  e.preventDefault();
643
+ const hash = withBaseUrl.split("#")[1];
644
+ if (!isExternal && inCurrentPage && hash) {
645
+ const el = document.getElementById(hash);
646
+ if (el) {
647
+ scrollToTarget(el, true);
648
+ }
649
+ return;
650
+ }
582
651
  if (!process.env.__SSR__) {
583
652
  const matchedRoutes = matchRoutes(routes, normalizeRoutePath(withBaseUrl));
584
653
  if (matchedRoutes === null || matchedRoutes === void 0 ? void 0 : matchedRoutes.length) {
@@ -623,11 +692,11 @@ function Link(props) {
623
692
  var index_module_default3 = { "pager": "pager_33e00", "has-next": "has-next_33e00", "hasNext": "has-next_33e00", "prev": "prev_33e00", "next": "next_33e00", "pager-link": "pager-link_33e00", "pagerLink": "pager-link_33e00", "title": "title_33e00", "desc": "desc_33e00" };
624
693
 
625
694
  // src/theme-default/components/DocFooter/index.tsx
626
- import { normalizeHref as normalizeHref2, usePageData as usePageData4 } from "@/runtime";
695
+ import { normalizeHrefInRuntime as normalizeHref3, usePageData as usePageData5 } from "@/runtime";
627
696
  function DocFooter() {
628
697
  const { prevPage, nextPage } = usePrevNextPage();
629
698
  const { prevPageText = "Previous Page", nextPageText = "Next page", lastUpdatedText: localesLastUpdatedText = "Last Updated", lastUpdated: localesLastUpdated = false } = useLocaleSiteData();
630
- const { page: { lastUpdatedTime }, siteData: siteData2 } = usePageData4();
699
+ const { page: { lastUpdatedTime }, siteData: siteData2 } = usePageData5();
631
700
  const { themeConfig } = siteData2;
632
701
  const lastUpdatedText = (themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.lastUpdatedText) || localesLastUpdatedText;
633
702
  const showLastUpdated = themeConfig.lastUpdated || localesLastUpdated;
@@ -661,7 +730,7 @@ function DocFooter() {
661
730
  /* @__PURE__ */ _jsx5("div", {
662
731
  className: `${index_module_default3.prev} flex flex-col`,
663
732
  children: prevPage ? /* @__PURE__ */ _jsxs3(Link, {
664
- href: normalizeHref2(prevPage.link),
733
+ href: normalizeHref3(prevPage.link),
665
734
  className: index_module_default3.pagerLink,
666
735
  children: [
667
736
  /* @__PURE__ */ _jsx5("span", {
@@ -678,7 +747,7 @@ function DocFooter() {
678
747
  /* @__PURE__ */ _jsx5("div", {
679
748
  className: `${index_module_default3.next} flex flex-col`,
680
749
  children: nextPage ? /* @__PURE__ */ _jsxs3(Link, {
681
- href: normalizeHref2(nextPage.link),
750
+ href: normalizeHref3(nextPage.link),
682
751
  className: `${index_module_default3.pagerLink} ${index_module_default3.next}`,
683
752
  children: [
684
753
  /* @__PURE__ */ _jsx5("span", {
@@ -813,7 +882,7 @@ var SvgArrowRight = (props) => /* @__PURE__ */ _jsx7("svg", _object_spread_props
813
882
  var arrow_right_default = SvgArrowRight;
814
883
 
815
884
  // src/theme-default/components/Sidebar/SidebarGroup.tsx
816
- import { normalizeHref as normalizeHref3, withBase as withBase4 } from "@/runtime";
885
+ import { normalizeHrefInRuntime as normalizeHref4, withBase as withBase5 } from "@/runtime";
817
886
  function _define_property4(obj, key, value) {
818
887
  if (key in obj) {
819
888
  Object.defineProperty(obj, key, {
@@ -955,7 +1024,7 @@ function SidebarGroup(props) {
955
1024
  onMouseEnter: () => item.link && props.preloadLink(item.link),
956
1025
  onClick: (e) => {
957
1026
  if (item.link) {
958
- navigate(withBase4(normalizeHref3(item.link)));
1027
+ navigate(withBase5(normalizeHref4(item.link)));
959
1028
  collapsed && toggleCollapse(e);
960
1029
  } else {
961
1030
  collapsible && toggleCollapse(e);
@@ -1015,7 +1084,7 @@ function SidebarGroup(props) {
1015
1084
  }
1016
1085
 
1017
1086
  // src/theme-default/components/Sidebar/SidebarItem.tsx
1018
- import { normalizeHref as normalizeHref4 } from "@/runtime";
1087
+ import { normalizeHrefInRuntime as normalizeHref5 } from "@/runtime";
1019
1088
  function _define_property5(obj, key, value) {
1020
1089
  if (key in obj) {
1021
1090
  Object.defineProperty(obj, key, {
@@ -1069,7 +1138,7 @@ function SidebarItem(props) {
1069
1138
  }, `${item.text}-${id}`);
1070
1139
  } else {
1071
1140
  return /* @__PURE__ */ _jsx9(Link, {
1072
- href: normalizeHref4(item.link),
1141
+ href: normalizeHref5(item.link),
1073
1142
  className: index_module_default4.menuLink,
1074
1143
  children: /* @__PURE__ */ _jsxs5("div", {
1075
1144
  ref,
@@ -1095,7 +1164,7 @@ function SidebarItem(props) {
1095
1164
  }
1096
1165
 
1097
1166
  // src/theme-default/components/Sidebar/index.tsx
1098
- import { removeBase, usePageData as usePageData5 } from "@/runtime";
1167
+ import { removeBase as removeBase2, usePageData as usePageData6 } from "@/runtime";
1099
1168
  function _define_property6(obj, key, value) {
1100
1169
  if (key in obj) {
1101
1170
  Object.defineProperty(obj, key, {
@@ -1133,7 +1202,7 @@ var highlightTitleStyle = {
1133
1202
  var matchCache = /* @__PURE__ */ new WeakMap();
1134
1203
  function SideBar(props) {
1135
1204
  const { isSidebarOpen, langRoutePrefix, pathname: rawPathname, sidebarData: rawSidebarData } = props;
1136
- const { siteData: { themeConfig }, page: { frontmatter } } = usePageData5();
1205
+ const { siteData: { themeConfig }, page: { frontmatter } } = usePageData6();
1137
1206
  var _frontmatter_hideNavbar, _ref;
1138
1207
  const hideNavbar = (_ref = (_frontmatter_hideNavbar = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.hideNavbar) !== null && _frontmatter_hideNavbar !== void 0 ? _frontmatter_hideNavbar : themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.hideNavbar) !== null && _ref !== void 0 ? _ref : false;
1139
1208
  const [sidebarData, setSidebarData] = useState2(rawSidebarData.filter(Boolean).flat());
@@ -1179,7 +1248,7 @@ function SideBar(props) {
1179
1248
  const removeLangPrefix = (path) => {
1180
1249
  return path.replace(langRoutePrefix, "");
1181
1250
  };
1182
- const activeMatcher = (path) => isActive(removeBase(removeLangPrefix(pathname)), removeLangPrefix(path), true);
1251
+ const activeMatcher = (path) => isActive(removeBase2(removeLangPrefix(pathname)), removeLangPrefix(path), true);
1183
1252
  const preloadLink = (link) => {
1184
1253
  const match = matchRoutes2(routes2, link);
1185
1254
  if (match === null || match === void 0 ? void 0 : match.length) {
@@ -1341,7 +1410,7 @@ import { useMemo } from "react";
1341
1410
  var index_module_default5 = { "header-anchor": "header-anchor_90d29", "headerAnchor": "header-anchor_90d29", "overview-groups": "overview-groups_90d29", "overviewGroups": "overview-groups_90d29", "overview-group-li": "overview-group-li_90d29", "overviewGroupLi": "overview-group-li_90d29", "level-2": "level-2_90d29", "level2": "level-2_90d29", "overview-group": "overview-group_90d29", "overviewGroup": "overview-group_90d29", "header": "header_90d29" };
1342
1411
 
1343
1412
  // src/theme-default/components/Overview/index.tsx
1344
- import { usePageData as usePageData6, normalizeHref as normalizeHref5, withBase as withBase5, isEqualPath as isEqualPath4 } from "@/runtime";
1413
+ import { usePageData as usePageData7, normalizeHrefInRuntime as normalizeHref6, withBase as withBase6, isEqualPath as isEqualPath4 } from "@/runtime";
1345
1414
  function _define_property8(obj, key, value) {
1346
1415
  if (key in obj) {
1347
1416
  Object.defineProperty(obj, key, {
@@ -1396,13 +1465,13 @@ function _object_spread_props5(target, source) {
1396
1465
  }
1397
1466
  var DEFAULT_GROUP = "Others";
1398
1467
  function Overview() {
1399
- const { siteData: siteData2, page: { routePath } } = usePageData6();
1468
+ const { siteData: siteData2, page: { routePath } } = usePageData7();
1400
1469
  const { pages } = siteData2;
1401
1470
  const overviewModules = pages.filter((page) => page.routePath.startsWith(routePath.replace(/overview$/, "")) && page.routePath !== routePath);
1402
1471
  const { items: overviewSidebarGroups } = useSidebarData();
1403
1472
  function normalizeSidebarItem(item) {
1404
1473
  var _pageModule_toc;
1405
- const pageModule = overviewModules.find((m) => isEqualPath4(m.routePath, withBase5(item.link || "")));
1474
+ const pageModule = overviewModules.find((m) => isEqualPath4(m.routePath, withBase6(item.link || "")));
1406
1475
  const getChildLink = (traverseItem) => {
1407
1476
  if (traverseItem.link) {
1408
1477
  return traverseItem.link;
@@ -1469,7 +1538,7 @@ function Overview() {
1469
1538
  marginBottom: 8
1470
1539
  },
1471
1540
  children: /* @__PURE__ */ _jsx13(Link, {
1472
- href: normalizeHref5(item.link),
1541
+ href: normalizeHref6(item.link),
1473
1542
  children: item.text
1474
1543
  })
1475
1544
  })
@@ -1479,7 +1548,7 @@ function Overview() {
1479
1548
  children: (_item_headers = item.headers) === null || _item_headers === void 0 ? void 0 : _item_headers.map((header) => /* @__PURE__ */ _jsx13("li", {
1480
1549
  className: `${index_module_default5.overviewGroupLi} ${index_module_default5[`level${header.depth}`]} first:mt-2`,
1481
1550
  children: /* @__PURE__ */ _jsx13(Link, {
1482
- href: `${normalizeHref5(item.link)}#${header.id}`,
1551
+ href: `${normalizeHref6(item.link)}#${header.id}`,
1483
1552
  children: header.text
1484
1553
  })
1485
1554
  }, header.id))
@@ -1499,10 +1568,10 @@ import { createContext } from "react";
1499
1568
  var TabDataContext = createContext({});
1500
1569
 
1501
1570
  // src/theme-default/layout/DocLayout/index.module.scss
1502
- var index_module_default6 = { "aside-container": "aside-container_feeda", "asideContainer": "aside-container_feeda", "docLayout": "docLayout_feeda", "content": "content_feeda" };
1571
+ var index_module_default6 = { "aside-container": "aside-container_feeda", "asideContainer": "aside-container_feeda", "fade-out": "fade-out_feeda", "fadeOut": "fade-out_feeda", "fade-in": "fade-in_feeda", "fadeIn": "fade-in_feeda", "docLayout": "docLayout_feeda", "content": "content_feeda" };
1503
1572
 
1504
1573
  // src/theme-default/layout/DocLayout/index.tsx
1505
- import { Content, usePageData as usePageData7, normalizeSlash } from "@/runtime";
1574
+ import { Content, usePageData as usePageData8, normalizeSlash } from "@/runtime";
1506
1575
  function _define_property9(obj, key, value) {
1507
1576
  if (key in obj) {
1508
1577
  Object.defineProperty(obj, key, {
@@ -1533,14 +1602,14 @@ function _object_spread9(target) {
1533
1602
  }
1534
1603
  function DocLayout(props) {
1535
1604
  const { beforeDocFooter, beforeDoc, afterDoc, beforeOutline, afterOutline } = props;
1536
- const { siteData: siteData2, page } = usePageData7();
1605
+ const { siteData: siteData2, page } = usePageData8();
1537
1606
  const { toc = [], frontmatter } = page;
1538
1607
  const [tabData, setTabData] = useState4({});
1539
1608
  const headers = toc;
1540
1609
  const { themeConfig } = siteData2;
1541
1610
  const localesData = useLocaleSiteData();
1542
1611
  const sidebar = localesData.sidebar || {};
1543
- const { pathname } = useLocation3();
1612
+ const { pathname } = useLocation4();
1544
1613
  const { items: sidebarData } = useSidebarData();
1545
1614
  const langRoutePrefix = normalizeSlash(localesData.langRoutePrefix || "");
1546
1615
  var _frontmatter_hideNavbar, _ref;
@@ -1633,7 +1702,7 @@ function DocLayout(props) {
1633
1702
  }
1634
1703
 
1635
1704
  // src/theme-default/layout/Layout/index.tsx
1636
- import { usePageData as usePageData8, Content as Content2, removeBase as removeBase2, withBase as withBase6 } from "@/runtime";
1705
+ import { usePageData as usePageData9, Content as Content2, removeBase as removeBase3, withBase as withBase7 } from "@/runtime";
1637
1706
  function _define_property10(obj, key, value) {
1638
1707
  if (key in obj) {
1639
1708
  Object.defineProperty(obj, key, {
@@ -1671,7 +1740,7 @@ var Layout = (props) => {
1671
1740
  beforeOutline,
1672
1741
  afterOutline
1673
1742
  };
1674
- const { siteData: siteData2, page } = usePageData8();
1743
+ const { siteData: siteData2, page } = usePageData9();
1675
1744
  const { themeConfig } = siteData2;
1676
1745
  const {
1677
1746
  pageType,
@@ -1715,7 +1784,7 @@ var Layout = (props) => {
1715
1784
  return;
1716
1785
  }
1717
1786
  const { pathname } = window.location;
1718
- const cleanPathname = removeBase2(pathname);
1787
+ const cleanPathname = removeBase3(pathname);
1719
1788
  const FIRST_VISIT_KEY = "rspress-visited";
1720
1789
  const visited = localStorage.getItem(FIRST_VISIT_KEY);
1721
1790
  if (visited) {
@@ -1731,7 +1800,7 @@ var Layout = (props) => {
1731
1800
  if (targetLang === defaultLang) {
1732
1801
  window.location.replace(pathname.replace(`/${currentLang}`, ""));
1733
1802
  } else if (currentLang === defaultLang) {
1734
- window.location.replace(withBase6(`/${targetLang}${cleanPathname}`));
1803
+ window.location.replace(withBase7(`/${targetLang}${cleanPathname}`));
1735
1804
  } else {
1736
1805
  window.location.replace(pathname.replace(`/${currentLang}`, `/${targetLang}`));
1737
1806
  }
@@ -1812,7 +1881,7 @@ function Button(props) {
1812
1881
  var index_module_default8 = { "clip": "clip_1e4a0", "mask": "mask_1e4a0" };
1813
1882
 
1814
1883
  // src/theme-default/components/HomeHero/index.tsx
1815
- import { normalizeHref as normalizeHref6 } from "@/runtime";
1884
+ import { normalizeHrefInRuntime as normalizeHref7 } from "@/runtime";
1816
1885
  var DEFAULT_HERO = {
1817
1886
  name: "modern",
1818
1887
  text: "modern ssg",
@@ -1867,7 +1936,7 @@ function HomeHero({ frontmatter }) {
1867
1936
  children: /* @__PURE__ */ _jsx16(Button, {
1868
1937
  type: "a",
1869
1938
  text: action.text,
1870
- href: normalizeHref6(action.link),
1939
+ href: normalizeHref7(action.link),
1871
1940
  theme: action.theme
1872
1941
  })
1873
1942
  }, action.link))
@@ -1957,10 +2026,10 @@ function HomeFeature({ frontmatter }) {
1957
2026
  }
1958
2027
 
1959
2028
  // src/theme-default/layout/HomeLayout/index.tsx
1960
- import { usePageData as usePageData9 } from "@/runtime";
2029
+ import { usePageData as usePageData10 } from "@/runtime";
1961
2030
  function HomeLayout(props) {
1962
2031
  const { beforeHero, afterHero, beforeFeatures, afterFeatures } = props;
1963
- const { page: { frontmatter } } = usePageData9();
2032
+ const { page: { frontmatter } } = usePageData10();
1964
2033
  return /* @__PURE__ */ _jsxs12("div", {
1965
2034
  className: "relative",
1966
2035
  style: {
@@ -1991,7 +2060,7 @@ function HomeLayout(props) {
1991
2060
  // src/theme-default/components/Nav/index.tsx
1992
2061
  import { jsx as _jsx36, jsxs as _jsxs23 } from "react/jsx-runtime";
1993
2062
  import { replaceLang } from "@rspress/shared";
1994
- import { useLocation as useLocation4 } from "react-router-dom";
2063
+ import { useLocation as useLocation5 } from "react-router-dom";
1995
2064
  import { Search } from "@theme";
1996
2065
  import { useContext as useContext3, useEffect as useEffect11, useState as useState10 } from "react";
1997
2066
 
@@ -2168,12 +2237,12 @@ import { withoutBase } from "@rspress/shared";
2168
2237
  var index_module_default11 = { "container": "container_47ac2", "leftNav": "leftNav_47ac2", "rightNav": "rightNav_47ac2", "activeItem": "activeItem_47ac2", "singleItem": "singleItem_47ac2", "navContainer": "navContainer_47ac2", "social-links-icon": "social-links-icon_47ac2", "socialLinksIcon": "social-links-icon_47ac2", "menu-item": "menu-item_47ac2", "menuItem": "menu-item_47ac2", "mobileNavMenu": "mobileNavMenu_47ac2", "mask": "mask_47ac2", "docPage": "docPage_47ac2" };
2169
2238
 
2170
2239
  // src/theme-default/components/Nav/NavMenuSingleItem.tsx
2171
- import { normalizeHref as normalizeHref7 } from "@/runtime";
2240
+ import { normalizeHrefInRuntime as normalizeHref8 } from "@/runtime";
2172
2241
  function NavMenuSingleItem(item) {
2173
2242
  const { pathname, base } = item;
2174
2243
  const isActive2 = new RegExp(item.activeMatch || item.link).test(withoutBase(pathname, base));
2175
2244
  return /* @__PURE__ */ _jsx21(Link, {
2176
- href: normalizeHref7(item.link),
2245
+ href: normalizeHref8(item.link),
2177
2246
  children: /* @__PURE__ */ _jsxs14("div", {
2178
2247
  className: `${index_module_default11.singleItem} ${isActive2 ? index_module_default11.activeItem : ""} text-sm font-medium mx-1.5 px-3 py-2 flex items-center`,
2179
2248
  children: [
@@ -3425,7 +3494,7 @@ function NavMenuGroup(item) {
3425
3494
  }
3426
3495
 
3427
3496
  // src/theme-default/components/Nav/index.tsx
3428
- import { ThemeContext as ThemeContext3, usePageData as usePageData10, withBase as withBase7 } from "@/runtime";
3497
+ import { ThemeContext as ThemeContext3, usePageData as usePageData11, useVersion as useVersion2, withBase as withBase8 } from "@/runtime";
3429
3498
  function _define_property20(obj, key, value) {
3430
3499
  if (key in obj) {
3431
3500
  Object.defineProperty(obj, key, {
@@ -3483,7 +3552,7 @@ var NavBarTitle = ({ title, langRoutePrefix, logo }) => {
3483
3552
  return /* @__PURE__ */ _jsx36("div", {
3484
3553
  className: `${index_module_default11.navBarTitle}`,
3485
3554
  children: /* @__PURE__ */ _jsx36("a", {
3486
- href: withBase7(langRoutePrefix),
3555
+ href: withBase8(langRoutePrefix),
3487
3556
  className: "flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60",
3488
3557
  children: logo ? /* @__PURE__ */ _jsx36("img", {
3489
3558
  src: logo,
@@ -3509,24 +3578,33 @@ var NavTranslations = ({ translationMenuData }) => {
3509
3578
  function Nav2(props) {
3510
3579
  var _localeLanguages_find, _siteData_themeConfig;
3511
3580
  const { beforeNavTitle, afterNavTitle, beforeNav } = props;
3512
- const { siteData: siteData2, page } = usePageData10();
3581
+ const { siteData: siteData2, page } = usePageData11();
3513
3582
  const { logo: rawLogo, base } = siteData2;
3514
- const { pathname } = useLocation4();
3583
+ const { pathname } = useLocation5();
3515
3584
  const { theme } = useContext3(ThemeContext3);
3516
3585
  const localeData = useLocaleSiteData();
3586
+ const currentVersion = useVersion2();
3517
3587
  const [isMobile, setIsMobile] = useState10(false);
3518
3588
  const localeLanguages = Object.values(siteData2.themeConfig.locales || {});
3519
3589
  const hasMultiLanguage = localeLanguages.length > 1;
3520
3590
  const socialLinks = siteData2.themeConfig.socialLinks || [];
3521
3591
  const hasSocialLinks = socialLinks.length > 0;
3522
- const defaultLang = siteData2.lang || "zh";
3592
+ const defaultLang = siteData2.lang || "";
3593
+ const defaultVersion = siteData2.multiVersion.default || "";
3523
3594
  const { lang } = page;
3524
- const langs = localeLanguages.map((item) => item.lang || "zh") || [];
3595
+ const langs = localeLanguages.map((item) => item.lang || "") || [];
3525
3596
  const [logo, setLogo] = useState10(getLogoUrl(rawLogo, theme));
3526
3597
  const translationMenuData = hasMultiLanguage ? {
3527
3598
  items: localeLanguages.map((item) => ({
3528
3599
  text: item === null || item === void 0 ? void 0 : item.label,
3529
- link: replaceLang(pathname, item.lang, defaultLang, langs, base)
3600
+ link: replaceLang(pathname, {
3601
+ current: lang,
3602
+ target: item.lang,
3603
+ default: defaultLang
3604
+ }, {
3605
+ current: currentVersion,
3606
+ default: defaultVersion
3607
+ }, base)
3530
3608
  })),
3531
3609
  activeValue: (_localeLanguages_find = localeLanguages.find((item) => lang === item.lang)) === null || _localeLanguages_find === void 0 ? void 0 : _localeLanguages_find.label
3532
3610
  } : null;
@@ -3605,7 +3683,7 @@ function Nav2(props) {
3605
3683
  });
3606
3684
  };
3607
3685
  return /* @__PURE__ */ _jsxs23("header", {
3608
- className: `top-0 left-0 md:fixed w-full`,
3686
+ className: "top-0 left-0 md:fixed w-full",
3609
3687
  style: {
3610
3688
  zIndex: "var(--rp-z-index-nav)",
3611
3689
  background: "var(--rp-c-bg)"
@@ -4502,7 +4580,7 @@ var RemoteProvider = class {
4502
4580
  };
4503
4581
 
4504
4582
  // src/theme-default/components/Search/logic/search.ts
4505
- import { normalizeHref as normalizeHref8 } from "@/runtime";
4583
+ import { normalizeHrefInRuntime as normalizeHref9 } from "@/runtime";
4506
4584
  function asyncGeneratorStep4(gen, resolve, reject, _next, _throw, key, arg) {
4507
4585
  try {
4508
4586
  var info = gen[key](arg);
@@ -4674,7 +4752,7 @@ function matchTitle(item, query2, matchedResult) {
4674
4752
  type: "title",
4675
4753
  title,
4676
4754
  header: title,
4677
- link: `${item.domain}${normalizeHref8(item.routePath)}`,
4755
+ link: `${item.domain}${normalizeHref9(item.routePath)}`,
4678
4756
  query: query2,
4679
4757
  highlightInfoList: [
4680
4758
  {
@@ -4707,7 +4785,7 @@ function matchHeader(item, query2, matchedResult) {
4707
4785
  length: getStrByteLength(query2)
4708
4786
  }
4709
4787
  ],
4710
- link: `${domain}${normalizeHref8(item.routePath)}#${header.id}`,
4788
+ link: `${domain}${normalizeHref9(item.routePath)}#${header.id}`,
4711
4789
  query: query2,
4712
4790
  group: _class_private_field_get3(this, _options2).extractGroupName(item.routePath)
4713
4791
  });
@@ -4762,7 +4840,7 @@ function matchContent(item, query2, matchedResult) {
4762
4840
  type: "content",
4763
4841
  title: item.title,
4764
4842
  header: (_currentHeader_text = currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.text) !== null && _currentHeader_text !== void 0 ? _currentHeader_text : item.title,
4765
- link: `${domain}${normalizeHref8(item.routePath)}${currentHeader ? `#${currentHeader.id}` : ""}`,
4843
+ link: `${domain}${normalizeHref9(item.routePath)}${currentHeader ? `#${currentHeader.id}` : ""}`,
4766
4844
  query: query2,
4767
4845
  highlightInfoList,
4768
4846
  group: _class_private_field_get3(this, _options2).extractGroupName(item.routePath),
@@ -4793,7 +4871,7 @@ function matchContent(item, query2, matchedResult) {
4793
4871
  header: (_currentHeader_text1 = currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.text) !== null && _currentHeader_text1 !== void 0 ? _currentHeader_text1 : item.title,
4794
4872
  statement,
4795
4873
  highlightInfoList,
4796
- link: `${domain}${normalizeHref8(item.routePath)}${currentHeader ? `#${currentHeader.id}` : ""}`,
4874
+ link: `${domain}${normalizeHref9(item.routePath)}${currentHeader ? `#${currentHeader.id}` : ""}`,
4797
4875
  query: query2,
4798
4876
  group: _class_private_field_get3(this, _options2).extractGroupName(item.routePath)
4799
4877
  });
@@ -5322,7 +5400,7 @@ function NoSearchResult({ query: query2 }) {
5322
5400
  }
5323
5401
 
5324
5402
  // src/theme-default/components/Search/SearchPanel.tsx
5325
- import { isProduction as isProduction2, usePageData as usePageData11 } from "@/runtime";
5403
+ import { isProduction as isProduction2, usePageData as usePageData12 } from "@/runtime";
5326
5404
  function asyncGeneratorStep5(gen, resolve, reject, _next, _throw, key, arg) {
5327
5405
  try {
5328
5406
  var info = gen[key](arg);
@@ -5425,7 +5503,7 @@ function SearchPanel({ focused, setFocused }) {
5425
5503
  const [initing, setIniting] = useState12(true);
5426
5504
  const [currentSuggestionIndex, setCurrentSuggestionIndex] = useState12(0);
5427
5505
  const pageSearcherRef = useRef5(null);
5428
- const { siteData: siteData2, page: { lang } } = usePageData11();
5506
+ const { siteData: siteData2, page: { lang } } = usePageData12();
5429
5507
  const { sidebar } = useLocaleSiteData();
5430
5508
  const { search } = siteData2;
5431
5509
  const suggestions = [
@@ -5750,9 +5828,9 @@ function Search2() {
5750
5828
 
5751
5829
  // src/theme-default/components/HomeFooter/index.tsx
5752
5830
  import { jsx as _jsx50 } from "react/jsx-runtime";
5753
- import { usePageData as usePageData12 } from "@/runtime";
5831
+ import { usePageData as usePageData13 } from "@/runtime";
5754
5832
  function HomeFooter2() {
5755
- const { siteData: siteData2 } = usePageData12();
5833
+ const { siteData: siteData2 } = usePageData13();
5756
5834
  const { message } = siteData2.themeConfig.footer || {};
5757
5835
  return /* @__PURE__ */ _jsx50("footer", {
5758
5836
  className: "absolute bottom-0 mt-12 py-8 px-6 sm:p-8 w-full border-t border-solid border-divider-light",
@@ -5768,7 +5846,7 @@ function HomeFooter2() {
5768
5846
 
5769
5847
  // src/theme-default/components/Toc/index.tsx
5770
5848
  import { jsx as _jsx51 } from "react/jsx-runtime";
5771
- import { usePageData as usePageData13 } from "@/runtime";
5849
+ import { usePageData as usePageData14 } from "@/runtime";
5772
5850
  function _define_property32(obj, key, value) {
5773
5851
  if (key in obj) {
5774
5852
  Object.defineProperty(obj, key, {
@@ -5822,7 +5900,7 @@ var TocItem = (header) => {
5822
5900
  }, header.id);
5823
5901
  };
5824
5902
  function Toc() {
5825
- const { page } = usePageData13();
5903
+ const { page } = usePageData14();
5826
5904
  return /* @__PURE__ */ _jsx51("ul", {
5827
5905
  children: page.toc.map((item) => /* @__PURE__ */ _jsx51(TocItem, _object_spread32({}, item), item.id))
5828
5906
  });
@@ -5967,7 +6045,7 @@ var prisim_theme_default = {
5967
6045
  };
5968
6046
 
5969
6047
  // src/theme-default/layout/DocLayout/docComponents/code.tsx
5970
- import { usePageData as usePageData14 } from "@/runtime";
6048
+ import { usePageData as usePageData15 } from "@/runtime";
5971
6049
  function _define_property33(obj, key, value) {
5972
6050
  if (key in obj) {
5973
6051
  Object.defineProperty(obj, key, {
@@ -6017,7 +6095,7 @@ function registerLanguages() {
6017
6095
  }
6018
6096
  function Code(props) {
6019
6097
  const copyButtonRef = useRef6(null);
6020
- const { siteData: siteData2 } = usePageData14();
6098
+ const { siteData: siteData2 } = usePageData15();
6021
6099
  const { showLineNumbers } = siteData2.markdown;
6022
6100
  if (!registered) {
6023
6101
  registerLanguages();
@@ -6586,7 +6664,7 @@ function PackageManagerTabs({ command, additionalTabs = [] }) {
6586
6664
  import { jsx as _jsx59 } from "react/jsx-runtime";
6587
6665
 
6588
6666
  // src/theme-default/layout/DocLayout/docComponents/index.module.scss
6589
- var index_module_default17 = { "title": "title_f1ea0", "blockquote": "blockquote_f1ea0", "link": "link_f1ea0" };
6667
+ var index_module_default17 = { "title": "title_f1ea0", "blockquote": "blockquote_f1ea0", "link": "link_f1ea0", "inline-link": "inline-link_f1ea0", "inlineLink": "inline-link_f1ea0" };
6590
6668
 
6591
6669
  // src/theme-default/layout/DocLayout/docComponents/title.tsx
6592
6670
  function _define_property38(obj, key, value) {
@@ -6879,8 +6957,6 @@ var Hr = (props) => {
6879
6957
 
6880
6958
  // src/theme-default/layout/DocLayout/docComponents/link.tsx
6881
6959
  import { jsx as _jsx63 } from "react/jsx-runtime";
6882
- import { isExternalUrl, normalizeHref as normalizeHref9, normalizeSlash as normalizeSlash2 } from "@rspress/shared";
6883
- import { withBase as withBase8, useLang, usePageData as usePageData15, removeBase as removeBase3 } from "@/runtime";
6884
6960
  function _define_property42(obj, key, value) {
6885
6961
  if (key in obj) {
6886
6962
  Object.defineProperty(obj, key, {
@@ -6934,25 +7010,18 @@ function _object_spread_props34(target, source) {
6934
7010
  return target;
6935
7011
  }
6936
7012
  var A = (props) => {
6937
- let { href = "" } = props;
6938
- const lang = useLang();
6939
- const pageData = usePageData15();
6940
- const defaultLang = pageData.siteData.lang;
6941
- if (defaultLang && !isExternalUrl(href) && !href.startsWith("#")) {
6942
- href = normalizeSlash2(href);
6943
- const startWithLang = removeBase3(href).startsWith(`/${lang}`);
6944
- if (lang !== defaultLang && !startWithLang) {
6945
- href = `/${lang}${href}`;
6946
- }
6947
- if (lang === defaultLang && startWithLang) {
6948
- href = removeBase3(href).replace(`/${lang}`, "");
6949
- }
6950
- href = normalizeHref9(withBase8(href || ""));
7013
+ const { href = "", className = "" } = props;
7014
+ const { normalizeLinkHref } = usePathUtils();
7015
+ if (className.includes("header-anchor")) {
7016
+ return /* @__PURE__ */ _jsx63("a", _object_spread_props34(_object_spread42({}, props), {
7017
+ className: `${index_module_default17.link} ${className}`
7018
+ }));
7019
+ } else {
7020
+ return /* @__PURE__ */ _jsx63(Link, _object_spread_props34(_object_spread42({}, props), {
7021
+ className: `${className} ${index_module_default17.link} ${index_module_default17["inline-link"]}`,
7022
+ href: normalizeLinkHref(href)
7023
+ }));
6951
7024
  }
6952
- return /* @__PURE__ */ _jsx63("a", _object_spread_props34(_object_spread42({}, props), {
6953
- className: `${index_module_default17.link} ${props.className}`,
6954
- href
6955
- }));
6956
7025
  };
6957
7026
 
6958
7027
  // src/theme-default/layout/DocLayout/docComponents/paragraph.tsx
@@ -7061,8 +7130,11 @@ var theme_default_default = {
7061
7130
  export {
7062
7131
  Button,
7063
7132
  HomeFooter2 as HomeFooter,
7133
+ HomeLayout,
7134
+ Layout,
7064
7135
  Link,
7065
7136
  Nav2 as Nav,
7137
+ NotFoundLayout,
7066
7138
  PackageManagerTabs,
7067
7139
  Search2 as Search,
7068
7140
  SearchPanel,
@@ -7080,6 +7152,7 @@ export {
7080
7152
  setup,
7081
7153
  useEditLink,
7082
7154
  useLocaleSiteData,
7155
+ usePathUtils,
7083
7156
  usePrevNextPage,
7084
7157
  useSidebarData
7085
7158
  };