@rspress/core 1.0.0-beta.3 → 1.0.0-beta.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 (33) hide show
  1. package/dist/runtime/index.d.ts +2 -2
  2. package/dist/runtime/index.js +2 -2
  3. package/dist/runtime/utils.d.ts +1 -0
  4. package/dist/runtime/utils.js +7 -1
  5. package/dist/theme/bundle.css +132 -125
  6. package/dist/theme/bundle.d.ts +5 -2
  7. package/dist/theme/bundle.js +898 -893
  8. package/dist/theme/bundle.js.map +1 -1
  9. package/package.json +6 -6
  10. package/src/runtime/index.ts +2 -1
  11. package/src/runtime/utils.ts +9 -0
  12. package/src/theme-default/components/Aside/index.css +0 -1
  13. package/src/theme-default/components/Aside/index.tsx +7 -8
  14. package/src/theme-default/components/DocFooter/index.tsx +4 -1
  15. package/src/theme-default/components/HomeHero/index.module.scss +6 -0
  16. package/src/theme-default/components/HomeHero/index.tsx +8 -2
  17. package/src/theme-default/components/LocalSideBar/index.tsx +5 -15
  18. package/src/theme-default/components/Nav/NavBarTitle.tsx +42 -0
  19. package/src/theme-default/components/Nav/index.module.scss +18 -4
  20. package/src/theme-default/components/Nav/index.tsx +14 -54
  21. package/src/theme-default/components/NavHambmger/index.tsx +1 -3
  22. package/src/theme-default/components/NavScreen/index.tsx +31 -18
  23. package/src/theme-default/components/Sidebar/SidebarGroup.tsx +1 -1
  24. package/src/theme-default/components/Sidebar/index.module.scss +20 -11
  25. package/src/theme-default/components/Sidebar/index.tsx +25 -38
  26. package/src/theme-default/layout/DocLayout/index.module.scss +7 -3
  27. package/src/theme-default/layout/DocLayout/index.tsx +6 -19
  28. package/src/theme-default/layout/HomeLayout/index.tsx +1 -1
  29. package/src/theme-default/layout/Layout/index.tsx +3 -5
  30. package/src/theme-default/logic/index.ts +1 -0
  31. package/src/theme-default/logic/sideEffects.ts +8 -7
  32. package/src/theme-default/logic/useHiddenNav.ts +55 -0
  33. package/src/theme-default/styles/code.css +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -89,11 +89,11 @@
89
89
  "unist-util-visit-children": "^2.0.1",
90
90
  "yaml-front-matter": "^4.1.1",
91
91
  "rspack-plugin-virtual-module": "0.1.12",
92
- "@rspress/shared": "1.0.0-beta.3",
93
- "@rspress/plugin-medium-zoom": "1.0.0-beta.3",
94
- "@rspress/plugin-last-updated": "1.0.0-beta.3",
95
- "@rspress/plugin-auto-nav-sidebar": "1.0.0-beta.3",
96
- "@rspress/plugin-container-syntax": "1.0.0-beta.3"
92
+ "@rspress/shared": "1.0.0-beta.4",
93
+ "@rspress/plugin-medium-zoom": "1.0.0-beta.4",
94
+ "@rspress/plugin-last-updated": "1.0.0-beta.4",
95
+ "@rspress/plugin-auto-nav-sidebar": "1.0.0-beta.4",
96
+ "@rspress/plugin-container-syntax": "1.0.0-beta.4"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@modern-js/plugin-tailwindcss": "2.35.1",
@@ -2,6 +2,7 @@ export * from './hooks';
2
2
  export * from './Content';
3
3
  export {
4
4
  normalizeHrefInRuntime,
5
+ normalizeImagePath,
5
6
  withBase,
6
7
  removeBase,
7
8
  addLeadingSlash,
@@ -11,6 +12,6 @@ export {
11
12
  normalizeRoutePath,
12
13
  isEqualPath,
13
14
  } from './utils';
14
- export { useLocation, useNavigate } from 'react-router-dom';
15
+ export { useLocation, useNavigate, matchRoutes } from 'react-router-dom';
15
16
  export { Helmet } from 'react-helmet-async';
16
17
  export { NoSSR } from './NoSSR';
@@ -7,6 +7,7 @@ import {
7
7
  normalizeHref,
8
8
  withBase as rawWithBase,
9
9
  removeBase as rawRemoveBase,
10
+ isExternalUrl,
10
11
  } from '@rspress/shared';
11
12
 
12
13
  export function normalizeRoutePath(routePath: string) {
@@ -34,4 +35,12 @@ export function normalizeHrefInRuntime(a: string) {
34
35
  return normalizeHref(a, cleanUrls);
35
36
  }
36
37
 
38
+ export function normalizeImagePath(imagePath: string) {
39
+ if (isExternalUrl(imagePath)) {
40
+ return imagePath;
41
+ }
42
+
43
+ return withBase(imagePath);
44
+ }
45
+
37
46
  export { addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction };
@@ -6,7 +6,6 @@
6
6
  white-space: nowrap;
7
7
  overflow: hidden;
8
8
  text-overflow: ellipsis;
9
- transition: all 0.2s ease-in-out;
10
9
  border-radius: 10px 0 0 10px;
11
10
  font-size: 13px;
12
11
  line-height: 1.75rem;
@@ -1,20 +1,19 @@
1
- import { useRef, useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
2
  import { Header } from '@rspress/shared';
3
- import { bindingAsideScroll, scrollToTarget } from '../../logic';
3
+ import { bindingAsideScroll, scrollToTarget, useHiddenNav } from '../../logic';
4
+ import { DEFAULT_NAV_HEIGHT } from '@/theme-default/logic/sideEffects';
4
5
  import './index.css';
5
6
 
6
7
  export function Aside(props: { headers: Header[]; outlineTitle: string }) {
7
8
  const { headers } = props;
8
9
  const hasOutline = headers.length > 0;
9
10
  // For outline text highlight
10
- const markerRef = useRef<HTMLDivElement>(null);
11
11
  const baseHeaderLevel = headers[0]?.depth || 2;
12
+ const hiddenNav = useHiddenNav();
12
13
 
13
14
  useEffect(() => {
14
15
  let unbinding: (() => void) | undefined;
15
- if (markerRef.current) {
16
- markerRef.current.style.opacity = '0';
17
- }
16
+
18
17
  setTimeout(() => {
19
18
  unbinding = bindingAsideScroll();
20
19
  }, 100);
@@ -24,7 +23,7 @@ export function Aside(props: { headers: Header[]; outlineTitle: string }) {
24
23
  } else {
25
24
  const target = document.getElementById(hash.slice(1));
26
25
  if (target) {
27
- scrollToTarget(target, false);
26
+ scrollToTarget(target, false, hiddenNav ? 0 : DEFAULT_NAV_HEIGHT);
28
27
  }
29
28
  }
30
29
  return () => {
@@ -49,7 +48,7 @@ export function Aside(props: { headers: Header[]; outlineTitle: string }) {
49
48
  window.location.hash = header.id;
50
49
  const target = document.getElementById(header.id);
51
50
  if (target) {
52
- scrollToTarget(target, false);
51
+ scrollToTarget(target, false, hiddenNav ? 0 : DEFAULT_NAV_HEIGHT);
53
52
  }
54
53
  }}
55
54
  >
@@ -2,7 +2,10 @@ import { useLocaleSiteData, usePrevNextPage } from '../../logic';
2
2
  import EditLink from '../EditLink';
3
3
  import { Link } from '../Link';
4
4
  import styles from './index.module.scss';
5
- import { normalizeHrefInRuntime as normalizeHref, usePageData } from '@/runtime';
5
+ import {
6
+ normalizeHrefInRuntime as normalizeHref,
7
+ usePageData,
8
+ } from '@/runtime';
6
9
 
7
10
  export function DocFooter() {
8
11
  const { prevPage, nextPage } = usePrevNextPage();
@@ -34,3 +34,9 @@
34
34
  width: 375px;
35
35
  }
36
36
  }
37
+
38
+ @media (max-width: 768px) {
39
+ .mask {
40
+ display: none;
41
+ }
42
+ }
@@ -1,7 +1,10 @@
1
1
  import { FrontMatterMeta } from '@rspress/shared';
2
2
  import { Button } from '../Button';
3
3
  import styles from './index.module.scss';
4
- import { normalizeHrefInRuntime as normalizeHref } from '@/runtime';
4
+ import {
5
+ normalizeHrefInRuntime as normalizeHref,
6
+ normalizeImagePath,
7
+ } from '@/runtime';
5
8
 
6
9
  const DEFAULT_HERO = {
7
10
  name: 'modern',
@@ -59,7 +62,10 @@ export function HomeHero({ frontmatter }: { frontmatter: FrontMatterMeta }) {
59
62
 
60
63
  {hasImage ? (
61
64
  <div className="rspress-home-hero-image md:flex-center m-auto order-1 md:order-2 sm:flex md:none lg:flex">
62
- <img src={hero.image?.src} alt={hero.image?.alt} />
65
+ <img
66
+ src={normalizeImagePath(hero.image?.src)}
67
+ alt={hero.image?.alt}
68
+ />
63
69
  </div>
64
70
  ) : null}
65
71
  </div>
@@ -1,18 +1,13 @@
1
1
  import { Fragment, useEffect, useState } from 'react';
2
- import { NormalizedSidebarGroup, SidebarItem } from '@rspress/shared';
3
2
  import { SideBar } from '../Sidebar';
4
3
  import MenuIcon from '../../assets/menu.svg';
5
4
  import './index.scss';
5
+ import { useLocation } from '@/runtime';
6
6
 
7
- interface Props {
8
- pathname: string;
9
- langRoutePrefix: string;
10
- sidebarData: (NormalizedSidebarGroup | SidebarItem)[];
11
- }
12
-
13
- export function SideMenu(props: Props) {
14
- const { langRoutePrefix, pathname, sidebarData } = props;
7
+ export function SideMenu() {
15
8
  const [isSidebarOpen, setIsOpen] = useState<boolean>(false);
9
+ const { pathname } = useLocation();
10
+
16
11
  function openSidebar() {
17
12
  setIsOpen(true);
18
13
  }
@@ -35,12 +30,7 @@ export function SideMenu(props: Props) {
35
30
  <span className="text-sm">Menu</span>
36
31
  </button>
37
32
  </div>
38
- <SideBar
39
- langRoutePrefix={langRoutePrefix}
40
- pathname={pathname}
41
- sidebarData={sidebarData}
42
- isSidebarOpen={isSidebarOpen}
43
- />
33
+ <SideBar isSidebarOpen={isSidebarOpen} />
44
34
  {isSidebarOpen ? (
45
35
  <div onClick={closeSidebar} className="rspress-sidebar-back-drop" />
46
36
  ) : null}
@@ -0,0 +1,42 @@
1
+ import { useContext, useEffect, useState } from 'react';
2
+ import styles from './index.module.scss';
3
+ import {
4
+ ThemeContext,
5
+ normalizeImagePath,
6
+ usePageData,
7
+ withBase,
8
+ } from '@/runtime';
9
+ import { getLogoUrl, useLocaleSiteData } from '@/theme-default/logic';
10
+
11
+ export const NavBarTitle = () => {
12
+ const { siteData } = usePageData();
13
+ const localeData = useLocaleSiteData();
14
+ const { logo: rawLogo } = siteData;
15
+ const title = localeData.title ?? siteData.title;
16
+ const { theme } = useContext(ThemeContext);
17
+ const [logo, setLogo] = useState(getLogoUrl(rawLogo, theme));
18
+
19
+ useEffect(() => {
20
+ setLogo(getLogoUrl(rawLogo, theme));
21
+ }, [theme]);
22
+
23
+ return (
24
+ <div className={`${styles.navBarTitle}`}>
25
+ <a
26
+ href={withBase(localeData.langRoutePrefix || '/')}
27
+ className="flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60"
28
+ >
29
+ {logo ? (
30
+ <img
31
+ src={normalizeImagePath(logo)}
32
+ alt="logo"
33
+ id="logo"
34
+ className="w-24 mr-4 rspress-logo"
35
+ />
36
+ ) : (
37
+ <span>{title}</span>
38
+ )}
39
+ </a>
40
+ </div>
41
+ );
42
+ };
@@ -1,7 +1,25 @@
1
+ .hidden {
2
+ transform: translate3d(0, calc(-100%), 0);
3
+ background: transparent;
4
+ opacity: 0;
5
+ }
6
+
1
7
  .container {
2
8
  margin: auto;
3
9
  }
4
10
 
11
+ .navContainer {
12
+ top: 0;
13
+ left: 0;
14
+ transition: all 0.3s ease;
15
+ transition-property: transform, opacity;
16
+ background: var(--rp-c-bg);
17
+ height: var(--rp-nav-height);
18
+ z-index: var(--rp-z-index-nav);
19
+ // Hidden the box shadow
20
+ // box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
21
+ }
22
+
5
23
  .leftNav {
6
24
  display: none;
7
25
  }
@@ -18,10 +36,6 @@
18
36
  border-radius: 12px;
19
37
  }
20
38
 
21
- .navContainer {
22
- height: var(--rp-nav-height);
23
- }
24
-
25
39
  .navContainer :deep(*) {
26
40
  pointer-events: all;
27
41
  }
@@ -1,15 +1,16 @@
1
1
  import { NavItem, replaceLang } from '@rspress/shared';
2
2
  import { useLocation } from 'react-router-dom';
3
3
  import { Search } from '@theme';
4
- import { useContext, useEffect, useState } from 'react';
5
- import { getLogoUrl, isMobileDevice, useLocaleSiteData } from '../../logic';
4
+ import { useEffect, useState } from 'react';
5
+ import { isMobileDevice, useHiddenNav, useLocaleSiteData } from '../../logic';
6
6
  import { NavHamburger } from '../NavHambmger';
7
7
  import { SocialLinks } from '../SocialLinks';
8
8
  import { SwitchAppearance } from '../SwitchAppearance';
9
9
  import { NavMenuGroup, NavMenuGroupItem } from './NavMenuGroup';
10
10
  import { NavMenuSingleItem } from './NavMenuSingleItem';
11
11
  import styles from './index.module.scss';
12
- import { ThemeContext, usePageData, useVersion, withBase } from '@/runtime';
12
+ import { NavBarTitle } from './NavBarTitle';
13
+ import { usePageData, useVersion } from '@/runtime';
13
14
 
14
15
  export interface NavProps {
15
16
  beforeNav?: React.ReactNode;
@@ -19,34 +20,6 @@ export interface NavProps {
19
20
 
20
21
  const DEFAULT_NAV_POSTION = 'right';
21
22
 
22
- interface NavBarTitleProps {
23
- title: string;
24
- langRoutePrefix: string;
25
- logo?: string;
26
- }
27
-
28
- const NavBarTitle = ({ title, langRoutePrefix, logo }: NavBarTitleProps) => {
29
- return (
30
- <div className={`${styles.navBarTitle}`}>
31
- <a
32
- href={withBase(langRoutePrefix)}
33
- className="flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60"
34
- >
35
- {logo ? (
36
- <img
37
- src={logo}
38
- alt="logo"
39
- id="logo"
40
- className="w-24 mr-4 rspress-logo"
41
- />
42
- ) : (
43
- <span>{title}</span>
44
- )}
45
- </a>
46
- </div>
47
- );
48
- };
49
-
50
23
  const NavTranslations = ({
51
24
  translationMenuData,
52
25
  }: {
@@ -66,12 +39,12 @@ const NavTranslations = ({
66
39
  export function Nav(props: NavProps) {
67
40
  const { beforeNavTitle, afterNavTitle, beforeNav } = props;
68
41
  const { siteData, page } = usePageData();
69
- const { logo: rawLogo, base } = siteData;
42
+ const { base } = siteData;
70
43
  const { pathname } = useLocation();
71
- const { theme } = useContext(ThemeContext);
72
44
  const localeData = useLocaleSiteData();
73
45
  const currentVersion = useVersion();
74
46
  const [isMobile, setIsMobile] = useState(false);
47
+ const hiddenNav = useHiddenNav();
75
48
  const localeLanguages = Object.values(siteData.themeConfig.locales || {});
76
49
  const hasMultiLanguage = localeLanguages.length > 1;
77
50
  const socialLinks = siteData.themeConfig.socialLinks || [];
@@ -80,7 +53,6 @@ export function Nav(props: NavProps) {
80
53
  const defaultVersion = siteData.multiVersion.default || '';
81
54
  const { lang } = page;
82
55
  const langs = localeLanguages.map(item => item.lang || '') || [];
83
- const [logo, setLogo] = useState(getLogoUrl(rawLogo, theme));
84
56
 
85
57
  const translationMenuData = hasMultiLanguage
86
58
  ? {
@@ -104,10 +76,6 @@ export function Nav(props: NavProps) {
104
76
  }
105
77
  : null;
106
78
 
107
- useEffect(() => {
108
- setLogo(getLogoUrl(rawLogo, theme));
109
- }, [theme]);
110
-
111
79
  useEffect(() => {
112
80
  setIsMobile(isMobileDevice());
113
81
  }, []);
@@ -151,7 +119,6 @@ export function Nav(props: NavProps) {
151
119
 
152
120
  const hasSearch = siteData?.themeConfig?.search !== false;
153
121
 
154
- const title = localeData.title ?? siteData.title;
155
122
  const hasAppearanceSwitch = siteData.themeConfig.darkMode !== false;
156
123
 
157
124
  const leftNav = () => {
@@ -186,24 +153,18 @@ export function Nav(props: NavProps) {
186
153
  );
187
154
  };
188
155
  return (
189
- <header
190
- className="top-0 left-0 md:fixed w-full"
191
- style={{
192
- zIndex: 'var(--rp-z-index-nav)',
193
- background: 'var(--rp-c-bg)',
194
- }}
195
- >
156
+ <>
196
157
  {beforeNav}
197
- <div className={`${styles.navContainer} rspress-nav px-6`}>
158
+ <div
159
+ className={`${styles.navContainer} sticky rspress-nav px-6 ${
160
+ hiddenNav ? styles.hidden : ''
161
+ }`}
162
+ >
198
163
  <div
199
164
  className={`${styles.container} flex justify-between items-center h-full`}
200
165
  >
201
166
  {beforeNavTitle}
202
- <NavBarTitle
203
- title={title}
204
- langRoutePrefix={localeData.langRoutePrefix || '/'}
205
- logo={logo}
206
- />
167
+ <NavBarTitle />
207
168
  {afterNavTitle}
208
169
  <div
209
170
  className={`${styles.content} flex flex-1 justify-end items-center`}
@@ -217,12 +178,11 @@ export function Nav(props: NavProps) {
217
178
  localeData={localeData}
218
179
  siteData={siteData}
219
180
  pathname={pathname}
220
- setLogo={setLogo}
221
181
  />
222
182
  </div>
223
183
  </div>
224
184
  </div>
225
185
  </div>
226
- </header>
186
+ </>
227
187
  );
228
188
  }
@@ -13,11 +13,10 @@ interface Props {
13
13
  localeData: LocaleConfig;
14
14
  siteData: SiteData<DefaultThemeConfig>;
15
15
  pathname: string;
16
- setLogo: (logo: string) => void;
17
16
  }
18
17
 
19
18
  export function NavHamburger(props: Props) {
20
- const { localeData, siteData, pathname, setLogo } = props;
19
+ const { localeData, siteData, pathname } = props;
21
20
  const { isScreenOpen, toggleScreen } = useNav();
22
21
  return (
23
22
  <Fragment>
@@ -26,7 +25,6 @@ export function NavHamburger(props: Props) {
26
25
  localeData={localeData}
27
26
  siteData={siteData}
28
27
  pathname={pathname}
29
- setLogo={setLogo}
30
28
  />
31
29
  <button
32
30
  onClick={toggleScreen}
@@ -1,6 +1,11 @@
1
- import { useContext, useEffect, useRef } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
  import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
3
- import { LocaleConfig, NavItem, DefaultThemeConfig } from '@rspress/shared';
3
+ import {
4
+ LocaleConfig,
5
+ NavItem,
6
+ DefaultThemeConfig,
7
+ replaceLang,
8
+ } from '@rspress/shared';
4
9
  import type { SiteData } from '@rspress/shared';
5
10
  import {
6
11
  NavScreenMenuGroup,
@@ -10,16 +15,14 @@ import { NavMenuSingleItem } from '../Nav/NavMenuSingleItem';
10
15
  import { SwitchAppearance } from '../SwitchAppearance';
11
16
  import Translator from '../../assets/translator.svg';
12
17
  import { SocialLinks } from '../SocialLinks';
13
- import { getLogoUrl } from '../../logic/utils';
14
18
  import styles from './index.module.scss';
15
- import { NoSSR, ThemeContext } from '@/runtime';
19
+ import { NoSSR, useLang, useVersion } from '@/runtime';
16
20
 
17
21
  interface Props {
18
22
  isScreenOpen: boolean;
19
23
  localeData: LocaleConfig;
20
24
  siteData: SiteData<DefaultThemeConfig>;
21
25
  pathname: string;
22
- setLogo: (logo: string) => void;
23
26
  }
24
27
 
25
28
  const NavScreenTranslations = ({
@@ -39,9 +42,10 @@ const NavScreenTranslations = ({
39
42
  };
40
43
 
41
44
  export function NavScreen(props: Props) {
42
- const { isScreenOpen, localeData, siteData, pathname, setLogo } = props;
45
+ const { isScreenOpen, localeData, siteData, pathname } = props;
46
+ const currentVersion = useVersion();
47
+ const currentLang = useLang();
43
48
  const screen = useRef<HTMLDivElement | null>(null);
44
- const { theme } = useContext(ThemeContext);
45
49
  const localesData = siteData.themeConfig.locales || [];
46
50
  const hasMultiLanguage = localesData.length > 1;
47
51
  const menuItems = localeData.nav || [];
@@ -49,7 +53,8 @@ export function NavScreen(props: Props) {
49
53
  const socialLinks = siteData?.themeConfig?.socialLinks || [];
50
54
  const hasSocialLinks = socialLinks.length > 0;
51
55
  const langs = localesData.map(item => item.lang || 'zh') || [];
52
- const { base, logo } = siteData;
56
+ const { base, lang: defaultLang, multiVersion } = siteData;
57
+ const { default: defaultVersion } = multiVersion;
53
58
  const translationMenuData = hasMultiLanguage
54
59
  ? {
55
60
  text: (
@@ -62,7 +67,19 @@ export function NavScreen(props: Props) {
62
67
  ),
63
68
  items: localesData.map(item => ({
64
69
  text: item?.label,
65
- link: `/${item.lang}`,
70
+ link: replaceLang(
71
+ pathname,
72
+ {
73
+ current: currentLang,
74
+ target: item.lang,
75
+ default: defaultLang,
76
+ },
77
+ {
78
+ current: currentVersion,
79
+ default: defaultVersion,
80
+ },
81
+ base,
82
+ ),
66
83
  })),
67
84
  activeValue: localesData.find(item => item.lang === localeData.lang)
68
85
  ?.label,
@@ -72,11 +89,7 @@ export function NavScreen(props: Props) {
72
89
  return (
73
90
  <div className={`mt-2 ${styles.navAppearance} flex justify-center`}>
74
91
  <NoSSR>
75
- <SwitchAppearance
76
- onClick={() => {
77
- setLogo(getLogoUrl(logo, theme === 'dark' ? 'light' : 'dark'));
78
- }}
79
- />
92
+ <SwitchAppearance />
80
93
  </NoSSR>
81
94
  </div>
82
95
  );
@@ -84,19 +97,19 @@ export function NavScreen(props: Props) {
84
97
  const NavScreenMenu = ({ menuItems }: { menuItems: NavItem[] }) => {
85
98
  return (
86
99
  <div className={styles.navMenu}>
87
- {menuItems.map((item, index) => {
100
+ {menuItems.map(item => {
88
101
  return (
89
- <div key={index} className={`${styles.navMenuItem} w-full`}>
102
+ <div key={item.text} className={`${styles.navMenuItem} w-full`}>
90
103
  {'link' in item ? (
91
104
  <NavMenuSingleItem
92
105
  pathname={pathname}
93
- key={index}
106
+ key={item.text}
94
107
  base={base}
95
108
  langs={langs}
96
109
  {...item}
97
110
  />
98
111
  ) : (
99
- <div key={index} className="mx-3 last:mr-0">
112
+ <div key={item.text} className="mx-3 last:mr-0">
100
113
  <NavScreenMenuGroup
101
114
  {...item}
102
115
  items={'items' in item ? item.items : item}
@@ -128,7 +128,7 @@ export function SidebarGroup(props: SidebarItemProps) {
128
128
  }}
129
129
  >
130
130
  <h2
131
- className="py-2.5 px-3 text-sm font-medium flex"
131
+ className="py-2 px-3 text-sm font-medium flex"
132
132
  style={{
133
133
  ...(depth === 0 ? highlightTitleStyle : {}),
134
134
  }}
@@ -1,26 +1,29 @@
1
+ .navTitleMask {
2
+ padding-left: 1.5rem;
3
+ height: var(--rp-nav-height);
4
+ display: flex;
5
+ align-items: center;
6
+ }
7
+
1
8
  .sidebar {
2
9
  position: fixed;
3
10
  top: 0;
4
11
  bottom: 0;
5
12
  left: 0;
6
13
  z-index: var(--rp-z-index-sidebar);
7
- padding: 12px 12px 96px 0;
14
+ padding: 0 12px 96px 0;
8
15
  width: calc(100vw - 64px);
9
16
  max-width: 320px;
10
- background-color: var(--rp-c-bg);
11
17
  opacity: 0;
12
18
  transform: translateX(-100%);
13
19
  transition: opacity 0.5s, transform 0.25s ease;
20
+ background: var(--rp-c-bg);
14
21
  }
15
22
 
16
23
  .sidebarContent {
17
24
  overflow-x: hidden;
18
25
  }
19
26
 
20
- :global(.dark) .sidebar {
21
- box-shadow: var(--rp-shadow-1);
22
- }
23
-
24
27
  .sidebar.open {
25
28
  opacity: 1;
26
29
  visibility: visible;
@@ -30,11 +33,13 @@
30
33
 
31
34
  @media (min-width: 960px) {
32
35
  .sidebar {
33
- z-index: 0;
34
- margin-top: calc(var(--rp-nav-height));
35
- padding-bottom: 128px;
36
+ // Lower than z-index of nav
37
+ z-index: 5;
36
38
  opacity: 1;
37
39
  visibility: visible;
40
+ position: sticky;
41
+ margin-top: calc(var(--rp-nav-height) * -1);
42
+ height: 100vh;
38
43
  width: var(--rp-sidebar-width);
39
44
  transform: translateX(0);
40
45
  box-shadow: var(--rp-c-shadow-3);
@@ -126,8 +131,12 @@
126
131
  }
127
132
  }
128
133
 
129
- :global(.dark .rspress-sidebar-group) {
130
- &::before {
134
+ :global(.dark) {
135
+ :global(.rspress-sidebar-group)::before {
131
136
  background-color: var(--rp-c-bg-mute);
132
137
  }
138
+
139
+ .sidebar {
140
+ box-shadow: var(--rp-shadow-1);
141
+ }
133
142
  }