@rspress/core 2.0.0-rc.3 → 2.0.0-rc.4

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 (99) hide show
  1. package/dist/0~7675.723d12b2.js +4 -4
  2. package/dist/{3521.56e42d70.js → 3521.9eb6b114.js} +12 -12
  3. package/dist/4669.69cb6b18.js +1 -0
  4. package/dist/{5485.077f14ff.js → 5485.9fc7f63d.js} +5 -5
  5. package/dist/6289.29817fb4.js +4 -0
  6. package/dist/8813.4b28f4bb.js +1 -0
  7. package/dist/9643.2dff683e.js +4 -0
  8. package/dist/cli/config/loadConfigFile.js +2 -2
  9. package/dist/cli/index.44f3184c.js +2 -0
  10. package/dist/cli/index.js +3 -3
  11. package/dist/eject-theme/components/HoverGroup/index.scss +3 -2
  12. package/dist/eject-theme/components/HoverGroup/index.tsx +104 -22
  13. package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
  14. package/dist/eject-theme/components/Nav/NavMenu.tsx +50 -28
  15. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +26 -11
  16. package/dist/eject-theme/components/Overview/index.tsx +65 -0
  17. package/dist/index.js +7 -11
  18. package/dist/node/PluginDriver.js +3 -3
  19. package/dist/node/auto-nav-sidebar/index.js +3 -3
  20. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  21. package/dist/node/auto-nav-sidebar/normalize.js +2 -2
  22. package/dist/node/auto-nav-sidebar/utils.js +2 -2
  23. package/dist/node/auto-nav-sidebar/walk.js +13 -9
  24. package/dist/node/constants.js +2 -2
  25. package/dist/node/eject.js +2 -5
  26. package/dist/node/initRsbuild.js +14 -8
  27. package/dist/node/logger/hint.js +1 -1
  28. package/dist/node/mdx/loader.7c249a26.js +12 -0
  29. package/dist/node/mdx/options.js +3 -3
  30. package/dist/node/mdx/processor.js +2 -2
  31. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  32. package/dist/node/mdx/rehypePlugins/headerAnchor.js +4 -4
  33. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  34. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -5
  35. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  36. package/dist/node/mdx/remarkPlugins/containerSyntax.js +1 -1
  37. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
  38. package/dist/node/mdx/remarkPlugins/image.js +3 -3
  39. package/dist/node/mdx/remarkPlugins/link.js +3 -3
  40. package/dist/node/mdx/remarkPlugins/toc.js +3 -3
  41. package/dist/node/medium-zoom/index.js +1 -1
  42. package/dist/node/route/RoutePage.js +1 -1
  43. package/dist/node/route/RouteService.js +3 -3
  44. package/dist/node/route/extractPageData.js +5 -5
  45. package/dist/node/route/normalizeRoutePath.js +2 -2
  46. package/dist/node/runtimeModule/i18n.js +2 -2
  47. package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
  48. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  49. package/dist/node/runtimeModule/searchHooks.js +1 -1
  50. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  51. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  52. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  53. package/dist/node/serve.js +1 -1
  54. package/dist/node/ssg/renderPage.js +2 -2
  55. package/dist/node/ssg/renderPageWorker.165b5d46.js +1 -0
  56. package/dist/node/ssg/renderPageWorker.js +2 -2
  57. package/dist/node/ssg/renderPages.js +3 -3
  58. package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
  59. package/dist/node/ssg/ssgEnv.js +1 -1
  60. package/dist/node/ssg-md/llms/emitLlmsTxt.js +9 -7
  61. package/dist/node/ssg-md/llms/llmsTxt.js +2 -2
  62. package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
  63. package/dist/node/ssg-md/renderPage.js +2 -2
  64. package/dist/node/ssg-md/renderPages.js +2 -2
  65. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +2 -2
  66. package/dist/node/utils/checkLanguageParity.js +1 -1
  67. package/dist/node/utils/createHash.js +1 -1
  68. package/dist/node/utils/error.js +1 -1
  69. package/dist/node/utils/flattenMdxContent.js +5 -5
  70. package/dist/node/utils/fs.js +1 -1
  71. package/dist/node/utils/getPageKey.js +1 -1
  72. package/dist/node/utils/normalizePath.js +3 -3
  73. package/dist/node/utils/reactAlias.js +2 -2
  74. package/dist/runtime/App.js +4 -2
  75. package/dist/runtime.js +1 -2
  76. package/dist/shiki-transformers.js +2 -2
  77. package/dist/theme/components/HoverGroup/index.css +3 -2
  78. package/dist/theme/components/HoverGroup/index.js +88 -17
  79. package/dist/theme/components/Nav/NavMenu.css +1 -1
  80. package/dist/theme/components/Nav/NavMenu.d.ts +6 -1
  81. package/dist/theme/components/Nav/NavMenu.js +47 -45
  82. package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +1 -1
  83. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -11
  84. package/dist/theme/components/Overview/index.js +45 -2
  85. package/dist/theme/layout/DocLayout/index.js +10 -0
  86. package/dist/theme/layout/HomeLayout/index.js +40 -0
  87. package/dist/theme/layout/Layout/index.js +10 -6
  88. package/dist/theme/logic/useStorageValue.js +6 -3
  89. package/dist/theme/styles/vars/base-vars.css +2 -2
  90. package/dist/theme/styles/vars/code-vars.css +2 -2
  91. package/nav-json-schema.json +2 -2
  92. package/package.json +6 -6
  93. package/dist/4669.12208c6a.js +0 -2
  94. package/dist/6289.c67fe0d5.js +0 -5
  95. package/dist/8813.9da1f210.js +0 -2
  96. package/dist/9643.f109822d.js +0 -5
  97. package/dist/cli/index.cb89dbd1.js +0 -3
  98. package/dist/node/mdx/loader.e1578c62.js +0 -13
  99. package/dist/node/ssg/renderPageWorker.474f9f73.js +0 -2
package/dist/runtime.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import "./runtime.72d450ac.js";
2
- import "./4669.12208c6a.js";
3
2
  export * from "@rspress/runtime";
4
- export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "@rspress/shared";
3
+ export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "./4669.69cb6b18.js";
@@ -1,6 +1,6 @@
1
1
  import "./node/mdx/rehypePlugins/transformers/index.js";
2
+ export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from "./node/mdx/rehypePlugins/transformers/add-lang.js";
2
3
  export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers } from "./node/mdx/rehypePlugins/transformers/add-line-numbers.js";
3
- export { SHIKI_TRANSFORMER_META_HIGHLIGHT, transformerCompatibleMetaHighlight } from "./node/mdx/rehypePlugins/transformers/meta-highlight.js";
4
4
  export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from "./node/mdx/rehypePlugins/transformers/add-title.js";
5
- export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from "./node/mdx/rehypePlugins/transformers/add-lang.js";
6
5
  export { SHIKI_TRANSFORMER_ADD_WRAP_CODE, transformerAddWrapCode } from "./node/mdx/rehypePlugins/transformers/add-wrap-code.js";
6
+ export { SHIKI_TRANSFORMER_META_HIGHLIGHT, transformerCompatibleMetaHighlight } from "./node/mdx/rehypePlugins/transformers/meta-highlight.js";
@@ -43,7 +43,6 @@
43
43
  border-radius: 8px;
44
44
  flex: 1;
45
45
  align-self: stretch;
46
- padding-left: 8px;
47
46
  padding-right: 8px;
48
47
  font-size: 14px;
49
48
  font-style: normal;
@@ -54,8 +53,10 @@
54
53
  }
55
54
 
56
55
  .rp-hover-group__item__link {
56
+ align-items: center;
57
+ gap: 2px;
57
58
  height: 100%;
58
- display: block;
59
+ display: flex;
59
60
  }
60
61
 
61
62
  .rp-hover-group__item--active {
@@ -1,7 +1,89 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Link } from "@theme";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { matchNavbar, useLocation } from "@rspress/core/runtime";
3
+ import { Link, Tag } from "@theme";
3
4
  import clsx from "clsx";
4
5
  import "./index.css";
6
+ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
7
+ const { pathname } = useLocation();
8
+ if ('items' in item && item.items && item.items.length > 0) {
9
+ const hasLink = 'link' in item && item.link;
10
+ return /*#__PURE__*/ jsxs(Fragment, {
11
+ children: [
12
+ hasLink && /*#__PURE__*/ jsx("li", {
13
+ className: "rp-hover-group__item",
14
+ style: {
15
+ paddingLeft: `${8 + 12 * depth}px`
16
+ },
17
+ "data-depth": depth,
18
+ children: /*#__PURE__*/ jsxs(Link, {
19
+ href: item.link,
20
+ "aria-label": item.text,
21
+ className: "rp-hover-group__item__link",
22
+ children: [
23
+ item.text,
24
+ 'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
25
+ tag: item.tag
26
+ })
27
+ ]
28
+ })
29
+ }, item.text),
30
+ item.items.map((subItem)=>/*#__PURE__*/ jsx(HoverGroupItem, {
31
+ item: subItem,
32
+ activeMatcher: activeMatcher,
33
+ depth: depth + 1
34
+ }, subItem.text))
35
+ ]
36
+ });
37
+ }
38
+ if ('link' in item) {
39
+ const { text, link } = item;
40
+ const isActiveItem = activeMatcher ? activeMatcher(item) : matchNavbar(item, pathname);
41
+ return /*#__PURE__*/ jsx("li", {
42
+ className: clsx('rp-hover-group__item', {
43
+ 'rp-hover-group__item--active': isActiveItem
44
+ }),
45
+ style: {
46
+ paddingLeft: `${8 + 12 * depth}px`
47
+ },
48
+ "data-depth": depth,
49
+ children: link ? /*#__PURE__*/ jsxs(Link, {
50
+ href: link,
51
+ "aria-label": text,
52
+ className: "rp-hover-group__item__link",
53
+ children: [
54
+ text,
55
+ 'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
56
+ tag: item.tag
57
+ })
58
+ ]
59
+ }) : /*#__PURE__*/ jsxs("div", {
60
+ className: "rp-hover-group__item__link",
61
+ children: [
62
+ text,
63
+ 'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
64
+ tag: item.tag
65
+ })
66
+ ]
67
+ })
68
+ }, text + link);
69
+ }
70
+ return /*#__PURE__*/ jsx("li", {
71
+ className: "rp-hover-group__item",
72
+ style: {
73
+ paddingLeft: `${8 + 12 * depth}px`
74
+ },
75
+ "data-depth": depth,
76
+ children: /*#__PURE__*/ jsxs("div", {
77
+ className: "rp-hover-group__item__link",
78
+ children: [
79
+ item.text,
80
+ 'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
81
+ tag: item.tag
82
+ })
83
+ ]
84
+ })
85
+ }, item.text);
86
+ }
5
87
  function HoverGroup({ items, customChildren, isOpen, position = 'center', activeMatcher }) {
6
88
  return /*#__PURE__*/ jsx("ul", {
7
89
  className: clsx('rp-hover-group', {
@@ -10,21 +92,10 @@ function HoverGroup({ items, customChildren, isOpen, position = 'center', active
10
92
  'rp-hover-group--center': 'center' === position,
11
93
  'rp-hover-group--right': 'right' === position
12
94
  }),
13
- children: customChildren ?? items?.map((item)=>{
14
- const { text, link } = item;
15
- const isActiveItem = activeMatcher ? activeMatcher(item) : false;
16
- return /*#__PURE__*/ jsx("li", {
17
- className: clsx('rp-hover-group__item', {
18
- 'rp-hover-group__item--active': isActiveItem
19
- }),
20
- children: /*#__PURE__*/ jsx(Link, {
21
- href: link,
22
- "aria-label": text,
23
- className: "rp-hover-group__item__link",
24
- children: text
25
- })
26
- }, text + link);
27
- })
95
+ children: customChildren ?? items?.map((item)=>/*#__PURE__*/ jsx(HoverGroupItem, {
96
+ item: item,
97
+ activeMatcher: activeMatcher
98
+ }, item.text))
28
99
  });
29
100
  }
30
101
  export { HoverGroup };
@@ -30,7 +30,7 @@
30
30
  text-align: center;
31
31
  justify-content: center;
32
32
  align-items: center;
33
- gap: 6px;
33
+ gap: 2px;
34
34
  height: 100%;
35
35
  font-size: 14px;
36
36
  font-style: normal;
@@ -1,7 +1,12 @@
1
1
  import type { NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren } from '@rspress/core';
2
2
  import type { HoverGroupProps } from '@theme';
3
+ import { type ReactNode } from 'react';
3
4
  import './NavMenu.scss';
4
5
  export declare const SvgDown: (props: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
6
+ export declare function NavMenuItemInner({ menuItem, children, }: {
7
+ menuItem: Partial<NavItemWithLink>;
8
+ children?: ReactNode;
9
+ }): import("react/jsx-runtime").JSX.Element;
5
10
  export declare function NavMenuItemWithChildren({ menuItem, activeMatcher, }: {
6
11
  menuItem: NavItemWithChildren | NavItemWithLinkAndChildren;
7
12
  activeMatcher?: HoverGroupProps['activeMatcher'];
@@ -9,7 +14,7 @@ export declare function NavMenuItemWithChildren({ menuItem, activeMatcher, }: {
9
14
  export declare function NavMenuItemWithLink({ menuItem, }: {
10
15
  menuItem: NavItemWithLink;
11
16
  }): import("react/jsx-runtime").JSX.Element;
12
- export declare function NavMenuItem({ menuItem: item }: {
17
+ export declare function NavMenuItem({ menuItem }: {
13
18
  menuItem: NavItem;
14
19
  }): import("react/jsx-runtime").JSX.Element;
15
20
  export declare function NavMenuDivider(): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { matchNavbar, useLocation } from "@rspress/core/runtime";
3
3
  import { IconArrowDown, Link, SvgWrapper, Tag, useHoverGroup } from "@theme";
4
4
  import clsx from "clsx";
@@ -9,47 +9,50 @@ const SvgDown = (props)=>/*#__PURE__*/ jsx(SvgWrapper, {
9
9
  icon: IconArrowDown,
10
10
  ...props
11
11
  });
12
+ function NavMenuItemInner({ menuItem, children }) {
13
+ return /*#__PURE__*/ jsx(Fragment, {
14
+ children: 'link' in menuItem && 'string' == typeof menuItem.link ? /*#__PURE__*/ jsxs(Link, {
15
+ href: menuItem.link,
16
+ className: "rp-nav-menu__item__container",
17
+ children: [
18
+ menuItem.text,
19
+ menuItem.tag && /*#__PURE__*/ jsx(Tag, {
20
+ tag: menuItem.tag
21
+ }),
22
+ children
23
+ ]
24
+ }) : /*#__PURE__*/ jsxs("div", {
25
+ className: "rp-nav-menu__item__container",
26
+ children: [
27
+ menuItem.text,
28
+ menuItem.tag && /*#__PURE__*/ jsx(Tag, {
29
+ tag: menuItem.tag
30
+ }),
31
+ children
32
+ ]
33
+ })
34
+ });
35
+ }
12
36
  function NavMenuItemWithChildren({ menuItem, activeMatcher }) {
13
37
  const { handleMouseEnter, handleMouseLeave, hoverGroup } = useHoverGroup({
14
38
  items: menuItem.items,
15
39
  activeMatcher
16
40
  });
17
- const inner = 'link' in menuItem && 'string' == typeof menuItem.link ? /*#__PURE__*/ jsxs(Link, {
18
- href: menuItem.link,
19
- className: "rp-nav-menu__item__container",
20
- children: [
21
- menuItem.text,
22
- menuItem.tag && /*#__PURE__*/ jsx(Tag, {
23
- tag: menuItem.tag
24
- }),
25
- /*#__PURE__*/ jsx(SvgDown, {
26
- className: "rp-nav-menu__item__icon"
27
- })
28
- ]
29
- }) : /*#__PURE__*/ jsxs("div", {
30
- className: "rp-nav-menu__item__container",
31
- children: [
32
- menuItem.text,
33
- menuItem.tag && /*#__PURE__*/ jsx(Tag, {
34
- tag: menuItem.tag
35
- }),
36
- /*#__PURE__*/ jsx(SvgDown, {
37
- className: "rp-nav-menu__item__icon"
38
- })
39
- ]
40
- });
41
- return menuItem.items.length > 0 ? /*#__PURE__*/ jsxs("li", {
41
+ const hasItems = menuItem.items.length > 0;
42
+ return /*#__PURE__*/ jsxs("li", {
42
43
  className: "rp-nav-menu__item",
43
44
  onMouseEnter: handleMouseEnter,
44
45
  onMouseLeave: handleMouseLeave,
45
46
  onClick: handleMouseEnter,
46
47
  children: [
47
- inner,
48
+ /*#__PURE__*/ jsx(NavMenuItemInner, {
49
+ menuItem: menuItem,
50
+ children: hasItems && /*#__PURE__*/ jsx(SvgDown, {
51
+ className: "rp-nav-menu__item__icon"
52
+ })
53
+ }),
48
54
  hoverGroup
49
55
  ]
50
- }) : /*#__PURE__*/ jsx("li", {
51
- className: "rp-nav-menu__item",
52
- children: inner
53
56
  });
54
57
  }
55
58
  function NavMenuItemWithLink({ menuItem }) {
@@ -60,24 +63,23 @@ function NavMenuItemWithLink({ menuItem }) {
60
63
  ]);
61
64
  return /*#__PURE__*/ jsx("li", {
62
65
  className: clsx('rp-nav-menu__item', isActive ? 'rp-nav-menu__item--active' : '', 'rspress-nav-menu-item', isActive ? 'rspress-nav-menu-item-active' : ''),
63
- children: /*#__PURE__*/ jsxs(Link, {
64
- href: menuItem.link,
65
- className: "rp-nav-menu__item__container",
66
- children: [
67
- menuItem.text,
68
- menuItem.tag && /*#__PURE__*/ jsx(Tag, {
69
- tag: menuItem.tag
70
- })
71
- ]
66
+ children: /*#__PURE__*/ jsx(NavMenuItemInner, {
67
+ menuItem: menuItem
72
68
  })
73
69
  });
74
70
  }
75
- function NavMenuItem({ menuItem: item }) {
76
- if ('items' in item && Array.isArray(item.items) && item.items.length > 0) return /*#__PURE__*/ jsx(NavMenuItemWithChildren, {
77
- menuItem: item
71
+ function NavMenuItem({ menuItem }) {
72
+ if ('items' in menuItem && Array.isArray(menuItem.items) && menuItem.items.length > 0) return /*#__PURE__*/ jsx(NavMenuItemWithChildren, {
73
+ menuItem: menuItem
78
74
  });
79
- return /*#__PURE__*/ jsx(NavMenuItemWithLink, {
80
- menuItem: item
75
+ if ('link' in menuItem && menuItem.link.length > 0) return /*#__PURE__*/ jsx(NavMenuItemWithLink, {
76
+ menuItem: menuItem
77
+ });
78
+ return /*#__PURE__*/ jsx("li", {
79
+ className: "rp-nav-menu__item",
80
+ children: /*#__PURE__*/ jsx(NavMenuItemInner, {
81
+ menuItem: menuItem
82
+ })
81
83
  });
82
84
  }
83
85
  function NavMenuDivider() {
@@ -118,4 +120,4 @@ function NavMenu({ menuItems, position }) {
118
120
  }, index))
119
121
  });
120
122
  }
121
- export { NavLangs, NavMenu, NavMenuDivider, NavMenuItem, NavMenuItemWithChildren, NavMenuItemWithLink, NavVersions, SvgDown };
123
+ export { NavLangs, NavMenu, NavMenuDivider, NavMenuItem, NavMenuItemInner, NavMenuItemWithChildren, NavMenuItemWithLink, NavVersions, SvgDown };
@@ -21,5 +21,5 @@ export declare function NavScreenMenuItemWithChildren({ menuItem, }: NavScreenMe
21
21
  interface NavScreenMenuItemProps {
22
22
  menuItem: NavItem;
23
23
  }
24
- export declare function NavScreenMenuItem({ menuItem: item }: NavScreenMenuItemProps): import("react/jsx-runtime").JSX.Element;
24
+ export declare function NavScreenMenuItem({ menuItem }: NavScreenMenuItemProps): import("react/jsx-runtime").JSX.Element;
25
25
  export {};
@@ -11,7 +11,7 @@ const SvgDown = (props)=>/*#__PURE__*/ jsx(SvgWrapper, {
11
11
  function NavScreenMenuItemRaw({ left, right, isOpen, isActive, onClick, href }) {
12
12
  if (href) return /*#__PURE__*/ jsxs(Link, {
13
13
  href: href,
14
- className: clsx('rp-nav-screen-menu-item', isActive && 'rp-nav-screen-menu-item--active'),
14
+ className: clsx('rp-nav-screen-menu-item', isOpen && 'rp-nav-screen-menu-item--open', isActive && 'rp-nav-screen-menu-item--active'),
15
15
  onClick: onClick,
16
16
  children: [
17
17
  /*#__PURE__*/ jsx("div", {
@@ -61,7 +61,7 @@ function NavScreenMenuItemWithLink({ menuItem }) {
61
61
  }
62
62
  function NavScreenMenuItemWithChildren({ menuItem }) {
63
63
  const [isOpen, setIsOpen] = useState(false);
64
- return menuItem.items?.length > 0 ? /*#__PURE__*/ jsxs(Fragment, {
64
+ return /*#__PURE__*/ jsxs(Fragment, {
65
65
  children: [
66
66
  /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
67
67
  left: /*#__PURE__*/ jsxs(Fragment, {
@@ -76,7 +76,8 @@ function NavScreenMenuItemWithChildren({ menuItem }) {
76
76
  className: "rp-nav-screen-menu-item__icon"
77
77
  }),
78
78
  isOpen: isOpen,
79
- onClick: ()=>setIsOpen(!isOpen)
79
+ onClick: ()=>setIsOpen(!isOpen),
80
+ href: 'link' in menuItem ? menuItem.link : void 0
80
81
  }),
81
82
  /*#__PURE__*/ jsx("div", {
82
83
  className: "rp-nav-screen-menu-item__group",
@@ -88,22 +89,31 @@ function NavScreenMenuItemWithChildren({ menuItem }) {
88
89
  },
89
90
  children: /*#__PURE__*/ jsx("div", {
90
91
  className: "rp-nav-screen-menu-item__group-inner",
91
- children: menuItem.items.map((item)=>/*#__PURE__*/ jsx(NavScreenMenuItemWithChildren, {
92
+ children: menuItem.items.map((item)=>/*#__PURE__*/ jsx(NavScreenMenuItem, {
92
93
  menuItem: item
93
94
  }, item.text))
94
95
  })
95
96
  })
96
97
  ]
97
- }) : /*#__PURE__*/ jsx(NavScreenMenuItemWithLink, {
98
- menuItem: menuItem
99
98
  });
100
99
  }
101
- function NavScreenMenuItem({ menuItem: item }) {
102
- if ('items' in item && Array.isArray(item.items) && item.items.length > 0) return /*#__PURE__*/ jsx(NavScreenMenuItemWithChildren, {
103
- menuItem: item
100
+ function NavScreenMenuItem({ menuItem }) {
101
+ if ('items' in menuItem && Array.isArray(menuItem.items) && menuItem.items.length > 0) return /*#__PURE__*/ jsx(NavScreenMenuItemWithChildren, {
102
+ menuItem: menuItem
104
103
  });
105
- return /*#__PURE__*/ jsx(NavScreenMenuItemWithLink, {
106
- menuItem: item
104
+ if ('link' in menuItem && 'string' == typeof menuItem.link) return /*#__PURE__*/ jsx(NavScreenMenuItemWithLink, {
105
+ menuItem: menuItem
106
+ });
107
+ return /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
108
+ left: /*#__PURE__*/ jsxs(Fragment, {
109
+ children: [
110
+ menuItem.text,
111
+ menuItem.tag && /*#__PURE__*/ jsx(Tag, {
112
+ tag: menuItem.tag
113
+ })
114
+ ]
115
+ }),
116
+ right: null
107
117
  });
108
118
  }
109
119
  export { NavScreenMenuItem, NavScreenMenuItemRaw, NavScreenMenuItemWithChildren, NavScreenMenuItemWithLink, SvgDown };
@@ -1,10 +1,49 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { isEqualPath, useI18n, usePageData, useSidebar } from "@rspress/core/runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { isEqualPath, normalizeHref, useI18n, usePageData, useSidebar, withBase } from "@rspress/core/runtime";
3
3
  import { FallbackHeading, OverviewGroup } from "@theme";
4
4
  import { useEffect, useMemo, useRef, useState } from "react";
5
5
  import { isSidebarDivider, isSidebarSectionHeader, isSidebarSingleFile } from "../Sidebar/utils.js";
6
6
  import "./index.css";
7
7
  import { findItemByRoutePath } from "./utils.js";
8
+ function routePathToMdPath(routePath) {
9
+ let url = routePath;
10
+ url = normalizeHref(url, false);
11
+ url = url.replace(/\.html$/, '.md');
12
+ return withBase(url);
13
+ }
14
+ function OverviewMarkdown({ title, groups }) {
15
+ const lines = [];
16
+ lines.push(`# ${title}`);
17
+ lines.push('');
18
+ for (const group of groups){
19
+ if (group.name) {
20
+ lines.push(`## ${group.name}`);
21
+ lines.push('');
22
+ }
23
+ for (const item of group.items){
24
+ const itemTitle = item.link ? `[${item.text}](${routePathToMdPath(item.link)})` : `**${item.text}**`;
25
+ lines.push(`### ${itemTitle}`);
26
+ lines.push('');
27
+ if (item.headers && item.headers.length > 0) {
28
+ for (const header of item.headers){
29
+ const headerLink = item.link ? `[${header.text}](${routePathToMdPath(item.link)}#${header.id})` : header.text;
30
+ lines.push(`- ${headerLink}`);
31
+ }
32
+ lines.push('');
33
+ }
34
+ if (item.items && item.items.length > 0) {
35
+ for (const subItem of item.items){
36
+ const subItemLink = subItem.link ? `[${subItem.text}](${routePathToMdPath(subItem.link)})` : subItem.text;
37
+ lines.push(`- ${subItemLink}`);
38
+ }
39
+ lines.push('');
40
+ }
41
+ }
42
+ }
43
+ return /*#__PURE__*/ jsx(Fragment, {
44
+ children: lines.join('\n')
45
+ });
46
+ }
8
47
  const normalizeText = (s)=>s.toLowerCase().replace(/-/g, ' ');
9
48
  const matchesQuery = (text, query)=>normalizeText(text).includes(normalizeText(query));
10
49
  const OverviewSearchInput = ({ query, setQuery, searchRef })=>{
@@ -115,6 +154,10 @@ function Overview(props) {
115
154
  query
116
155
  ]);
117
156
  const overviewTitle = title || 'Overview';
157
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(OverviewMarkdown, {
158
+ title: overviewTitle,
159
+ groups: groups
160
+ });
118
161
  return /*#__PURE__*/ jsxs("div", {
119
162
  className: "rspress-doc rp-doc rspress-overview rp-overview",
120
163
  children: [
@@ -9,6 +9,16 @@ function DocLayout(props) {
9
9
  const { frontmatter } = useFrontmatter();
10
10
  const isOverviewPage = frontmatter?.overview ?? false;
11
11
  const { sidebar: showSidebar = true, outline: showOutline = true, footer: showDocFooter = true, pageType } = frontmatter;
12
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
13
+ children: isOverviewPage ? /*#__PURE__*/ jsx(Overview, {
14
+ content: /*#__PURE__*/ jsx(DocContent, {
15
+ components: components,
16
+ isOverviewPage: true
17
+ })
18
+ }) : /*#__PURE__*/ jsx(DocContent, {
19
+ components: components
20
+ })
21
+ });
12
22
  const isDocWide = 'doc-wide' === pageType;
13
23
  const { isOutlineOpen, isSidebarOpen, sidebarMenu, asideLayoutRef, sidebarLayoutRef } = useSidebarMenu();
14
24
  const { rspressDocRef } = useWatchToc();
@@ -1,6 +1,46 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useFrontmatter } from "@rspress/core/runtime";
2
3
  import { HomeBackground, HomeFeature, HomeFooter, HomeHero } from "@theme";
4
+ function HomeLayoutMarkdown() {
5
+ const { frontmatter } = useFrontmatter();
6
+ const hero = frontmatter?.hero;
7
+ const features = frontmatter?.features;
8
+ const lines = [];
9
+ if (hero) {
10
+ if (hero.name) {
11
+ lines.push(`# ${hero.name}`);
12
+ lines.push('');
13
+ }
14
+ if (hero.text) {
15
+ lines.push(hero.text);
16
+ lines.push('');
17
+ }
18
+ if (hero.tagline) {
19
+ lines.push(`> ${hero.tagline}`);
20
+ lines.push('');
21
+ }
22
+ if (hero.actions && hero.actions.length > 0) {
23
+ const actionLinks = hero.actions.map((action)=>`[${action.text}](${action.link})`).join(' | ');
24
+ lines.push(actionLinks);
25
+ lines.push('');
26
+ }
27
+ }
28
+ if (features && features.length > 0) {
29
+ lines.push('## Features');
30
+ lines.push('');
31
+ for (const feature of features){
32
+ const icon = feature.icon ? `${feature.icon} ` : '';
33
+ const title = feature.link ? `[${icon}**${feature.title}**](${feature.link})` : `${icon}**${feature.title}**`;
34
+ lines.push(`- ${title}: ${feature.details}`);
35
+ }
36
+ lines.push('');
37
+ }
38
+ return /*#__PURE__*/ jsx(Fragment, {
39
+ children: lines.join('\n')
40
+ });
41
+ }
3
42
  function HomeLayout(props) {
43
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(HomeLayoutMarkdown, {});
4
44
  const { beforeHero, afterHero, beforeFeatures, afterFeatures, beforeHeroActions, afterHeroActions } = props;
5
45
  return /*#__PURE__*/ jsxs(Fragment, {
6
46
  children: [
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Content, useFrontmatter, useLocaleSiteData, usePageData, useSite } from "@rspress/core/runtime";
2
+ import { Content, useFrontmatter, useLocaleSiteData, usePage, useSite } from "@rspress/core/runtime";
3
3
  import { DocLayout, HomeLayout as external_theme_HomeLayout, Nav, NotFoundLayout as external_theme_NotFoundLayout, useRedirect4FirstVisit, useScrollReset, useSetup } from "@theme";
4
4
  import { Head, useHead } from "@unhead/react";
5
5
  import react, { memo, useMemo } from "react";
@@ -43,7 +43,7 @@ const HeadTags = /*#__PURE__*/ memo((props)=>{
43
43
  });
44
44
  });
45
45
  function Layout(props) {
46
- const { top, bottom, beforeDocFooter, afterDocFooter, beforeDoc, afterDoc, beforeDocContent, afterDocContent, beforeSidebar, afterSidebar, beforeOutline, afterOutline, beforeNavTitle, afterNavTitle, navTitle, beforeNav, afterNav, beforeHero, afterHero, beforeFeatures, afterFeatures, afterNavMenu, components, HomeLayout = external_theme_HomeLayout, NotFoundLayout = external_theme_NotFoundLayout } = props;
46
+ const { top, bottom, beforeDocFooter, afterDocFooter, beforeDoc, afterDoc, beforeDocContent, afterDocContent, beforeSidebar, afterSidebar, beforeOutline, afterOutline, beforeNavTitle, afterNavTitle, navTitle, beforeNav, afterNav, beforeHero, afterHero, beforeFeatures, afterFeatures, beforeNavMenu, afterNavMenu, components, HomeLayout = external_theme_HomeLayout, NotFoundLayout = external_theme_NotFoundLayout } = props;
47
47
  const docProps = {
48
48
  beforeDocFooter,
49
49
  afterDocFooter,
@@ -63,14 +63,11 @@ function Layout(props) {
63
63
  beforeFeatures,
64
64
  afterFeatures
65
65
  };
66
- const { page } = usePageData();
66
+ const { page } = usePage();
67
67
  const { site } = useSite();
68
68
  const { frontmatter } = useFrontmatter();
69
69
  const { pageType, lang: currentLang, title: articleTitle } = page;
70
70
  const localesData = useLocaleSiteData();
71
- useSetup();
72
- useScrollReset();
73
- useRedirect4FirstVisit();
74
71
  let title = frontmatter.title ?? articleTitle;
75
72
  const mainTitle = site.title || localesData.title || '';
76
73
  title = title && ('doc' === pageType || 'doc-wide' === pageType) ? concatTitle(title, frontmatter.titleSuffix || mainTitle) : 'home' === pageType ? concatTitle(mainTitle, frontmatter.titleSuffix) : '404' === pageType ? concatTitle('404', mainTitle) : mainTitle;
@@ -98,6 +95,12 @@ function Layout(props) {
98
95
  });
99
96
  }
100
97
  };
98
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
99
+ children: getContentLayout()
100
+ });
101
+ useSetup();
102
+ useScrollReset();
103
+ useRedirect4FirstVisit();
101
104
  const { frontmatter: { navbar: showNavbar = true } } = useFrontmatter();
102
105
  return /*#__PURE__*/ jsxs(Fragment, {
103
106
  children: [
@@ -115,6 +118,7 @@ function Layout(props) {
115
118
  beforeNavTitle: beforeNavTitle,
116
119
  afterNavTitle: afterNavTitle,
117
120
  navTitle: navTitle,
121
+ beforeNavMenu: beforeNavMenu,
118
122
  afterNavMenu: afterNavMenu
119
123
  }),
120
124
  afterNav
@@ -1,11 +1,14 @@
1
- import { useCallback, useEffect, useLayoutEffect, useState } from "react";
1
+ import { useCallback, useEffect, useState } from "react";
2
2
  const SYNC_STORAGE_EVENT_NAME = 'RSPRESS_SYNC_STORAGE_EVENT_NAME';
3
3
  const useStorageValue = (key, defaultValue)=>{
4
4
  const [value, setValueInternal] = useState(defaultValue);
5
- useLayoutEffect(()=>{
5
+ useEffect(()=>{
6
+ if ("u" < typeof window) return;
6
7
  const storedValue = localStorage.getItem(key);
7
8
  if (null != storedValue) setValueInternal(storedValue);
8
- }, []);
9
+ }, [
10
+ key
11
+ ]);
9
12
  const setValue = useCallback((value)=>{
10
13
  const next = value;
11
14
  if (null == next) localStorage.removeItem(key);
@@ -3,8 +3,8 @@
3
3
  --rp-c-bg-soft: #f8f8f9;
4
4
  --rp-c-bg-mute: #f1f1f1;
5
5
  --rp-c-bg-alt: #fff;
6
- --rp-c-divider: #0003;
7
- --rp-c-divider-light: #0000001a;
6
+ --rp-c-divider: #00000040;
7
+ --rp-c-divider-light: #0000001f;
8
8
  --rp-c-text-0: #000;
9
9
  --rp-c-text-1: #242424;
10
10
  --rp-c-text-2: #000000b3;
@@ -4,7 +4,7 @@
4
4
  --rp-code-block-color: #2e3440;
5
5
  --rp-code-block-bg: var(--rp-c-bg);
6
6
  --rp-code-block-border: 1px solid var(--rp-c-divider-light);
7
- --rp-code-block-shadow: var(--rp-shadow-1);
7
+ --rp-code-block-shadow: none;
8
8
  }
9
9
 
10
10
  :where(html.rp-dark) {
@@ -13,6 +13,6 @@
13
13
  --rp-code-block-color: #e5e7eb;
14
14
  --rp-code-block-bg: var(--rp-c-bg);
15
15
  --rp-code-block-border: 1px solid var(--rp-c-divider-light);
16
- --rp-code-block-shadow: var(--rp-shadow-1);
16
+ --rp-code-block-shadow: none;
17
17
  }
18
18
 
@@ -62,7 +62,7 @@
62
62
  "items": {
63
63
  "type": "array",
64
64
  "items": {
65
- "$ref": "#/definitions/NavItemWithLink"
65
+ "$ref": "#/definitions/NavItem"
66
66
  }
67
67
  },
68
68
  "position": {
@@ -90,7 +90,7 @@
90
90
  "items": {
91
91
  "type": "array",
92
92
  "items": {
93
- "$ref": "#/definitions/NavItemWithLink"
93
+ "$ref": "#/definitions/NavItem"
94
94
  }
95
95
  },
96
96
  "tag": {