@rspress/core 1.0.2 → 1.1.1-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 (33) hide show
  1. package/dist/index.js +62 -16
  2. package/dist/index.js.map +1 -1
  3. package/dist/loader.d.ts +1 -0
  4. package/dist/loader.js +24 -105
  5. package/dist/loader.js.map +1 -1
  6. package/dist/theme/bundle.css +291 -293
  7. package/dist/theme/bundle.d.ts +1 -1
  8. package/dist/theme/bundle.js +567 -511
  9. package/dist/theme/bundle.js.map +1 -1
  10. package/package.json +14 -14
  11. package/src/theme-default/components/HomeHero/index.tsx +5 -4
  12. package/src/theme-default/components/Nav/NavBarTitle.tsx +2 -1
  13. package/src/theme-default/components/Nav/NavMenuGroup.tsx +1 -14
  14. package/src/theme-default/components/Nav/NavTranslations.tsx +16 -0
  15. package/src/theme-default/components/Nav/NavVersions.tsx +16 -0
  16. package/src/theme-default/components/Nav/index.tsx +12 -50
  17. package/src/theme-default/components/Nav/menuDataHooks.tsx +75 -0
  18. package/src/theme-default/components/{NavScreenMenuGroup → NavScreen}/NavScreenMenuGroup.tsx +1 -1
  19. package/src/theme-default/components/NavScreen/index.module.scss +42 -0
  20. package/src/theme-default/components/NavScreen/index.tsx +26 -54
  21. package/src/theme-default/components/Overview/index.module.scss +4 -5
  22. package/src/theme-default/components/Overview/index.tsx +7 -2
  23. package/src/theme-default/components/Search/index.module.scss +2 -0
  24. package/src/theme-default/components/Search/index.tsx +11 -3
  25. package/src/theme-default/components/Sidebar/index.tsx +1 -1
  26. package/src/theme-default/components/SocialLinks/HiddenLinks.tsx +1 -1
  27. package/src/theme-default/components/SocialLinks/ShownLinks.tsx +1 -1
  28. package/src/theme-default/layout/DocLayout/docComponents/code.tsx +4 -27
  29. package/src/theme-default/layout/DocLayout/index.module.scss +1 -0
  30. package/src/theme-default/layout/DocLayout/index.tsx +15 -5
  31. package/src/theme-default/layout/Layout/index.tsx +25 -1
  32. package/src/theme-default/logic/useHiddenNav.ts +4 -1
  33. package/src/theme-default/components/NavScreenMenuGroup/index.module.scss +0 -41
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "1.0.2",
3
+ "version": "1.1.1-beta.0",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -40,10 +40,10 @@
40
40
  "@mdx-js/loader": "2.2.1",
41
41
  "@mdx-js/mdx": "2.2.1",
42
42
  "@mdx-js/react": "2.2.1",
43
- "@modern-js/builder": "2.36.0",
44
- "@modern-js/builder-rspack-provider": "2.36.0",
45
- "@rspress/mdx-rs": "0.3.3",
46
- "@modern-js/utils": "2.36.0",
43
+ "@modern-js/builder": "2.37.0",
44
+ "@modern-js/builder-rspack-provider": "2.37.0",
45
+ "@rspress/mdx-rs": "0.4.0",
46
+ "@modern-js/utils": "2.37.0",
47
47
  "@types/compression": "^1.7.2",
48
48
  "@types/polka": "^0.5.4",
49
49
  "autoprefixer": "10.4.13",
@@ -89,17 +89,17 @@
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.2",
93
- "@rspress/plugin-medium-zoom": "1.0.2",
94
- "@rspress/plugin-last-updated": "1.0.2",
95
- "@rspress/plugin-auto-nav-sidebar": "1.0.2",
96
- "@rspress/plugin-container-syntax": "1.0.2"
92
+ "@rspress/shared": "1.1.1-beta.0",
93
+ "@rspress/plugin-medium-zoom": "1.1.1-beta.0",
94
+ "@rspress/plugin-last-updated": "1.1.1-beta.0",
95
+ "@rspress/plugin-auto-nav-sidebar": "1.1.1-beta.0",
96
+ "@rspress/plugin-container-syntax": "1.1.1-beta.0"
97
97
  },
98
98
  "devDependencies": {
99
- "@modern-js/plugin-tailwindcss": "2.36.0",
100
- "@modern-js/plugin-testing": "2.36.0",
101
- "@modern-js/tsconfig": "2.36.0",
102
- "@modern-js/types": "2.36.0",
99
+ "@modern-js/plugin-tailwindcss": "2.37.0",
100
+ "@modern-js/plugin-testing": "2.37.0",
101
+ "@modern-js/tsconfig": "2.37.0",
102
+ "@modern-js/types": "2.37.0",
103
103
  "@types/body-scroll-lock": "^3.1.0",
104
104
  "@types/fs-extra": "^9.0.13",
105
105
  "@types/hast": "^2.3.4",
@@ -17,6 +17,7 @@ const DEFAULT_HERO = {
17
17
  export function HomeHero({ frontmatter }: { frontmatter: FrontMatterMeta }) {
18
18
  const hero = frontmatter?.hero || DEFAULT_HERO;
19
19
  const hasImage = hero.image !== undefined;
20
+ const textMaxWidth = hasImage ? 'sm:max-w-xl' : 'sm:max-w-4xl';
20
21
  return (
21
22
  <div className="m-auto pt-0 px-6 pb-12 sm:pt-10 sm:px-16 md:pt-16 md:px-16 md:pb-16">
22
23
  <div
@@ -34,16 +35,16 @@ export function HomeHero({ frontmatter }: { frontmatter: FrontMatterMeta }) {
34
35
  </h1>
35
36
  {hero.text?.length && (
36
37
  <p
37
- className={`mx-auto md:m-0 text-3xl sm:text-5xl md:text-6xl pb-2 font-bold z-10 max-w-392px ${
38
- hasImage ? 'sm:max-w-xl' : 'sm:max-w-4xl'
39
- }`}
38
+ className={`mx-auto md:m-0 text-3xl sm:text-5xl md:text-6xl pb-2 font-bold z-10 ${textMaxWidth}`}
40
39
  style={{ lineHeight: '1.2' }}
41
40
  >
42
41
  {hero.text}
43
42
  </p>
44
43
  )}
45
44
 
46
- <p className="whitespace-pre-wrap pt-4 m-auto md:m-0 text-sm sm:tex-xl md:text-2xl text-text-2 font-medium z-10">
45
+ <p
46
+ className={`whitespace-pre-wrap pt-4 m-auto md:m-0 text-sm sm:tex-xl md:text-2xl text-text-2 font-medium z-10 ${textMaxWidth}`}
47
+ >
47
48
  {hero.tagline}
48
49
  </p>
49
50
  <div className="flex flex-wrap justify-center gap-3 m--1.5 pt-8 z-10">
@@ -31,7 +31,8 @@ export const NavBarTitle = () => {
31
31
  src={normalizeImagePath(logo)}
32
32
  alt="logo"
33
33
  id="logo"
34
- className="w-24 mr-4 rspress-logo"
34
+ className="mr-4 rspress-logo"
35
+ style={{ height: '1.6rem' }}
35
36
  />
36
37
  ) : (
37
38
  <span>{title}</span>
@@ -7,7 +7,6 @@ import {
7
7
  withoutBase,
8
8
  } from '@rspress/shared';
9
9
  import { Link } from '../Link';
10
- import Translator from '../../assets/translator.svg';
11
10
  import Down from '../../assets/down.svg';
12
11
  import { Tag } from '../Tag';
13
12
  import { NavMenuSingleItem } from './NavMenuSingleItem';
@@ -25,8 +24,6 @@ export interface NavMenuGroupItem {
25
24
  base?: string;
26
25
  // Locales
27
26
  langs?: string[];
28
- // When the item is transition, we need to give a react element instead of a string.
29
- isTranslation?: boolean;
30
27
  }
31
28
 
32
29
  function ActiveGroupItem({ item }: { item: NavItemWithLink }) {
@@ -67,7 +64,6 @@ function NormalGroupItem({ item }: { item: NavItemWithLink }) {
67
64
  export function NavMenuGroup(item: NavMenuGroupItem) {
68
65
  const {
69
66
  activeValue,
70
- isTranslation,
71
67
  items: groupItems,
72
68
  base = '',
73
69
  link = '',
@@ -120,16 +116,7 @@ export function NavMenuGroup(item: NavMenuGroupItem) {
120
116
  }}
121
117
  >
122
118
  <Tag tag={item.tag} />
123
- {isTranslation ? (
124
- <Translator
125
- style={{
126
- with: '18px',
127
- height: '18px',
128
- }}
129
- />
130
- ) : (
131
- item.text
132
- )}
119
+ {item.text}
133
120
  </span>
134
121
  <Down />
135
122
  </>
@@ -0,0 +1,16 @@
1
+ import { NavMenuGroup } from './NavMenuGroup';
2
+ import styles from './index.module.scss';
3
+ import { useTranslationMenuData } from './menuDataHooks';
4
+
5
+ export function NavTranslations() {
6
+ const translationMenuData = useTranslationMenuData();
7
+ return (
8
+ <div
9
+ className={`translation ${styles.menuItem} flex text-sm font-bold items-center px-3 py-2`}
10
+ >
11
+ <div>
12
+ <NavMenuGroup {...translationMenuData} />
13
+ </div>
14
+ </div>
15
+ );
16
+ }
@@ -0,0 +1,16 @@
1
+ import { NavMenuGroup } from './NavMenuGroup';
2
+ import styles from './index.module.scss';
3
+ import { useVersionMenuData } from './menuDataHooks';
4
+
5
+ export function NavVersions() {
6
+ const versionsMenuData = useVersionMenuData();
7
+ return (
8
+ <div
9
+ className={`translation ${styles.menuItem} flex text-sm font-bold items-center px-3 py-2`}
10
+ >
11
+ <div>
12
+ <NavMenuGroup {...versionsMenuData} />
13
+ </div>
14
+ </div>
15
+ );
16
+ }
@@ -1,4 +1,4 @@
1
- import { NavItem, replaceLang } from '@rspress/shared';
1
+ import { NavItem } from '@rspress/shared';
2
2
  import { useLocation } from 'react-router-dom';
3
3
  import { Search } from '@theme';
4
4
  import { useEffect, useState } from 'react';
@@ -6,11 +6,13 @@ 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
- import { NavMenuGroup, NavMenuGroupItem } from './NavMenuGroup';
9
+ import { NavMenuGroup } from './NavMenuGroup';
10
10
  import { NavMenuSingleItem } from './NavMenuSingleItem';
11
11
  import styles from './index.module.scss';
12
12
  import { NavBarTitle } from './NavBarTitle';
13
- import { usePageData, useVersion } from '@/runtime';
13
+ import { NavTranslations } from './NavTranslations';
14
+ import { NavVersions } from './NavVersions';
15
+ import { usePageData } from '@/runtime';
14
16
 
15
17
  export interface NavProps {
16
18
  beforeNav?: React.ReactNode;
@@ -20,62 +22,23 @@ export interface NavProps {
20
22
 
21
23
  const DEFAULT_NAV_POSTION = 'right';
22
24
 
23
- const NavTranslations = ({
24
- translationMenuData,
25
- }: {
26
- translationMenuData: NavMenuGroupItem;
27
- }) => {
28
- return (
29
- <div
30
- className={`translation ${styles.menuItem} flex text-sm font-bold items-center px-3 py-2`}
31
- >
32
- <div>
33
- <NavMenuGroup {...translationMenuData} isTranslation />
34
- </div>
35
- </div>
36
- );
37
- };
38
-
39
25
  export function Nav(props: NavProps) {
40
26
  const { beforeNavTitle, afterNavTitle, beforeNav } = props;
41
- const { siteData, page } = usePageData();
27
+ const { siteData } = usePageData();
42
28
  const { base } = siteData;
43
29
  const { pathname } = useLocation();
44
30
  const localeData = useLocaleSiteData();
45
- const currentVersion = useVersion();
46
31
  const [isMobile, setIsMobile] = useState(false);
47
32
  const hiddenNav = useHiddenNav();
48
- const localeLanguages = Object.values(siteData.themeConfig.locales || {});
33
+ const localeLanguages = Object.values(
34
+ siteData.locales || siteData.themeConfig.locales || {},
35
+ );
49
36
  const hasMultiLanguage = localeLanguages.length > 1;
37
+ const hasMutilVersion = siteData.multiVersion.versions.length > 1;
50
38
  const socialLinks = siteData.themeConfig.socialLinks || [];
51
39
  const hasSocialLinks = socialLinks.length > 0;
52
- const defaultLang = siteData.lang || '';
53
- const defaultVersion = siteData.multiVersion.default || '';
54
- const { lang } = page;
55
40
  const langs = localeLanguages.map(item => item.lang || '') || [];
56
41
 
57
- const translationMenuData = hasMultiLanguage
58
- ? {
59
- items: localeLanguages.map(item => ({
60
- text: item?.label,
61
- link: replaceLang(
62
- pathname,
63
- {
64
- current: lang,
65
- target: item.lang,
66
- default: defaultLang,
67
- },
68
- {
69
- current: currentVersion,
70
- default: defaultVersion,
71
- },
72
- base,
73
- ),
74
- })),
75
- activeValue: localeLanguages.find(item => lang === item.lang)?.label,
76
- }
77
- : null;
78
-
79
42
  useEffect(() => {
80
43
  setIsMobile(isMobileDevice());
81
44
  }, []);
@@ -139,9 +102,8 @@ export function Nav(props: NavProps) {
139
102
  )}
140
103
  <NavMenu menuItems={rightMenuItems} />
141
104
  <div className="flex-center flex-row">
142
- {hasMultiLanguage && (
143
- <NavTranslations translationMenuData={translationMenuData} />
144
- )}
105
+ {hasMultiLanguage && <NavTranslations />}
106
+ {hasMutilVersion && <NavVersions />}
145
107
  {hasAppearanceSwitch && (
146
108
  <div className="mx-2">
147
109
  <SwitchAppearance />
@@ -0,0 +1,75 @@
1
+ import { replaceLang, replaceVersion } from '@rspress/shared';
2
+ import Translator from '../../assets/translator.svg';
3
+ import { useLocation, usePageData, useVersion } from '@/runtime';
4
+
5
+ export function useTranslationMenuData() {
6
+ const { siteData, page } = usePageData();
7
+ const currentVersion = useVersion();
8
+ const { pathname } = useLocation();
9
+ const defaultLang = siteData.lang || '';
10
+ const defaultVersion = siteData.multiVersion.default || '';
11
+ const localeLanguages = Object.values(
12
+ siteData.locales || siteData.themeConfig.locales || {},
13
+ );
14
+ const hasMultiLanguage = localeLanguages.length > 1;
15
+ const { lang: currentLang } = page;
16
+ const { base } = siteData;
17
+
18
+ const translationMenuData = hasMultiLanguage
19
+ ? {
20
+ text: (
21
+ <Translator
22
+ style={{
23
+ width: '18px',
24
+ height: '18px',
25
+ }}
26
+ />
27
+ ),
28
+ items: localeLanguages.map(item => ({
29
+ text: item?.label,
30
+ link: replaceLang(
31
+ pathname,
32
+ {
33
+ current: currentLang,
34
+ target: item.lang,
35
+ default: defaultLang,
36
+ },
37
+ {
38
+ current: currentVersion,
39
+ default: defaultVersion,
40
+ },
41
+ base,
42
+ ),
43
+ })),
44
+ activeValue: localeLanguages.find(item => currentLang === item.lang)
45
+ ?.label,
46
+ }
47
+ : null;
48
+ return translationMenuData;
49
+ }
50
+
51
+ export function useVersionMenuData() {
52
+ const { siteData } = usePageData();
53
+ const currentVersion = useVersion();
54
+ const { pathname } = useLocation();
55
+ const defaultVersion = siteData.multiVersion.default || '';
56
+ const versions = siteData.multiVersion.versions || [];
57
+ const { base } = siteData;
58
+ const versionsMenuData = {
59
+ items: versions.map(version => ({
60
+ text: version,
61
+ link: replaceVersion(
62
+ pathname,
63
+ {
64
+ current: currentVersion,
65
+ target: version,
66
+ default: defaultVersion,
67
+ },
68
+ base,
69
+ ),
70
+ })),
71
+ text: currentVersion,
72
+ activeValue: currentVersion,
73
+ };
74
+ return versionsMenuData;
75
+ }
@@ -21,7 +21,7 @@ export function NavScreenMenuGroup(item: NavScreenMenuGroupItem) {
21
21
 
22
22
  function ActiveGroupItem({ item }: { item: NavItemWithLink }) {
23
23
  return (
24
- <div className="p-1">
24
+ <div className="p-1 text-center">
25
25
  <span className="text-brand">{item.text}</span>
26
26
  </div>
27
27
  );
@@ -44,3 +44,45 @@
44
44
  .socialAndAppearance {
45
45
  padding: 8px 0 7px;
46
46
  }
47
+
48
+ .navScreenMenuGroup {
49
+ height: 39px;
50
+ overflow: hidden;
51
+ transition: border-color 0.5s;
52
+ }
53
+ .navScreenMenuGroup.open {
54
+ padding-bottom: 10px;
55
+ height: auto;
56
+ }
57
+ .button {
58
+ display: flex;
59
+ justify-content: center;
60
+ align-items: center;
61
+ padding: 8px 0 7px 0;
62
+ width: 100%;
63
+ line-height: 24px;
64
+ font-size: 14px;
65
+ font-weight: 500;
66
+ color: var(--rp-c-text-1);
67
+ transition: color 0.25s;
68
+ }
69
+
70
+ .buttonSpan {
71
+ display: flex;
72
+ align-items: center;
73
+ height: 24px;
74
+ padding-right: 4px;
75
+ }
76
+ .navScreenMenuGroup .items {
77
+ visibility: hidden;
78
+ }
79
+
80
+ .navScreenMenuGroup.open .items {
81
+ visibility: visible;
82
+ }
83
+ .down {
84
+ transition: all 0.5s;
85
+ }
86
+ .open.down {
87
+ transform: rotate(180deg);
88
+ }
@@ -1,22 +1,17 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
3
- import {
4
- LocaleConfig,
5
- NavItem,
6
- DefaultThemeConfig,
7
- replaceLang,
8
- } from '@rspress/shared';
3
+ import { LocaleConfig, NavItem, DefaultThemeConfig } from '@rspress/shared';
9
4
  import type { SiteData } from '@rspress/shared';
10
- import {
11
- NavScreenMenuGroup,
12
- NavScreenMenuGroupItem,
13
- } from '../NavScreenMenuGroup/NavScreenMenuGroup';
14
5
  import { NavMenuSingleItem } from '../Nav/NavMenuSingleItem';
15
6
  import { SwitchAppearance } from '../SwitchAppearance';
16
- import Translator from '../../assets/translator.svg';
17
7
  import { SocialLinks } from '../SocialLinks';
8
+ import {
9
+ useTranslationMenuData,
10
+ useVersionMenuData,
11
+ } from '../Nav/menuDataHooks';
12
+ import { NavScreenMenuGroup } from './NavScreenMenuGroup';
18
13
  import styles from './index.module.scss';
19
- import { NoSSR, useLang, useVersion } from '@/runtime';
14
+ import { NoSSR } from '@/runtime';
20
15
 
21
16
  interface Props {
22
17
  isScreenOpen: boolean;
@@ -25,11 +20,8 @@ interface Props {
25
20
  pathname: string;
26
21
  }
27
22
 
28
- const NavScreenTranslations = ({
29
- translationMenuData,
30
- }: {
31
- translationMenuData: NavScreenMenuGroupItem;
32
- }) => {
23
+ const NavScreenTranslations = () => {
24
+ const translationMenuData = useTranslationMenuData();
33
25
  return (
34
26
  <div
35
27
  className={`${styles.navTranslations} flex text-sm font-bold justify-center`}
@@ -41,50 +33,31 @@ const NavScreenTranslations = ({
41
33
  );
42
34
  };
43
35
 
36
+ const NavScreenVersions = () => {
37
+ const versionMenuData = useVersionMenuData();
38
+ return (
39
+ <div
40
+ className={`${styles.navTranslations} flex text-sm font-bold justify-center`}
41
+ >
42
+ <div className="mx-1.5 my-1">
43
+ <NavScreenMenuGroup {...versionMenuData} />
44
+ </div>
45
+ </div>
46
+ );
47
+ };
48
+
44
49
  export function NavScreen(props: Props) {
45
50
  const { isScreenOpen, localeData, siteData, pathname } = props;
46
- const currentVersion = useVersion();
47
- const currentLang = useLang();
48
51
  const screen = useRef<HTMLDivElement | null>(null);
49
52
  const localesData = siteData.themeConfig.locales || [];
50
53
  const hasMultiLanguage = localesData.length > 1;
54
+ const hasMultiVersion = siteData.multiVersion.versions.length > 1;
51
55
  const menuItems = localeData.nav || [];
52
56
  const hasAppearanceSwitch = siteData.themeConfig.darkMode !== false;
53
57
  const socialLinks = siteData?.themeConfig?.socialLinks || [];
54
58
  const hasSocialLinks = socialLinks.length > 0;
55
59
  const langs = localesData.map(item => item.lang || 'zh') || [];
56
- const { base, lang: defaultLang, multiVersion } = siteData;
57
- const { default: defaultVersion } = multiVersion;
58
- const translationMenuData = hasMultiLanguage
59
- ? {
60
- text: (
61
- <Translator
62
- style={{
63
- width: '18px',
64
- height: '18px',
65
- }}
66
- />
67
- ),
68
- items: localesData.map(item => ({
69
- text: item?.label,
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
- ),
83
- })),
84
- activeValue: localesData.find(item => item.lang === localeData.lang)
85
- ?.label,
86
- }
87
- : null;
60
+ const { base } = siteData;
88
61
  const NavScreenAppearance = () => {
89
62
  return (
90
63
  <div className={`mt-2 ${styles.navAppearance} flex justify-center`}>
@@ -140,9 +113,8 @@ export function NavScreen(props: Props) {
140
113
  <NavScreenMenu menuItems={menuItems} />
141
114
  <div className="flex-center flex-col gap-2">
142
115
  {hasAppearanceSwitch && <NavScreenAppearance />}
143
- {hasMultiLanguage && (
144
- <NavScreenTranslations translationMenuData={translationMenuData} />
145
- )}
116
+ {hasMultiLanguage && <NavScreenTranslations />}
117
+ {hasMultiVersion && <NavScreenVersions />}
146
118
  {hasSocialLinks && <SocialLinks socialLinks={socialLinks} />}
147
119
  </div>
148
120
  </div>
@@ -3,18 +3,17 @@
3
3
  h2,
4
4
  h3 {
5
5
  font-weight: 600;
6
+ }
7
+
8
+ h2,
9
+ h3 {
6
10
  line-height: 1;
7
11
  }
8
12
 
9
- h1,
10
13
  h2 {
11
14
  letter-spacing: -0.02em;
12
15
  }
13
16
 
14
- h1 {
15
- font-size: 38px;
16
- }
17
-
18
17
  h2 {
19
18
  font-size: 24px;
20
19
  color: var(--rp-c-text-1);
@@ -3,7 +3,12 @@ import { Header, NormalizedSidebarGroup, SidebarItem } from '@rspress/shared';
3
3
  import { useSidebarData } from '../../logic';
4
4
  import { Link } from '../Link';
5
5
  import styles from './index.module.scss';
6
- import { usePageData, normalizeHrefInRuntime as normalizeHref, withBase, isEqualPath } from '@/runtime';
6
+ import {
7
+ usePageData,
8
+ normalizeHrefInRuntime as normalizeHref,
9
+ withBase,
10
+ isEqualPath,
11
+ } from '@/runtime';
7
12
 
8
13
  interface GroupItem {
9
14
  text?: string;
@@ -85,7 +90,7 @@ export function Overview() {
85
90
  return (
86
91
  <div className="overview-index mx-auto px-8">
87
92
  <div className="flex items-center justify-between">
88
- <h1>Overview</h1>
93
+ <h1 className="text-3xl leading-10 tracking-tight">Overview</h1>
89
94
  </div>
90
95
 
91
96
  {groups.map(group => (
@@ -99,6 +99,8 @@
99
99
  color: var(--rp-c-gray);
100
100
  font-weight: 500;
101
101
  background-color: var(--rp-c-bg);
102
+ width: 43px;
103
+ transition: opacity 0.3s;
102
104
  > span {
103
105
  margin-left: 5px;
104
106
  + span {
@@ -1,18 +1,26 @@
1
- import { useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import SearchSvg from './assets/search.svg';
3
3
  import styles from './index.module.scss';
4
4
  import { SearchPanel } from './SearchPanel';
5
5
 
6
6
  export function Search() {
7
7
  const [focused, setFocused] = useState(false);
8
+ const [metaKey, setMetaKey] = useState<null | string>(null);
9
+
10
+ useEffect(() => {
11
+ setMetaKey(
12
+ /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) ? '⌘' : 'Ctrl',
13
+ );
14
+ }, []);
15
+
8
16
  return (
9
17
  <>
10
18
  <div className={styles.navSearchButton} onClick={() => setFocused(true)}>
11
19
  <button>
12
20
  <SearchSvg width="18" hight="18" />
13
21
  <p className={styles.searchWord}>Search Docs</p>
14
- <div>
15
- <span>⌘</span>
22
+ <div style={{ opacity: metaKey ? 1 : 0 }}>
23
+ <span>{metaKey}</span>
16
24
  <span>K</span>
17
25
  </div>
18
26
  </button>
@@ -51,7 +51,7 @@ export function SideBar(props: Props) {
51
51
  const { pathname: rawPathname } = useLocation();
52
52
 
53
53
  const langRoutePrefix = normalizeSlash(localesData.langRoutePrefix || '');
54
- const hideNavbar = useDisableNav();
54
+ const [hideNavbar] = useDisableNav();
55
55
  const [sidebarData, setSidebarData] = useState<
56
56
  (ISidebarItem | NormalizedSidebarGroup)[]
57
57
  >(rawSidebarData.filter(Boolean).flat());
@@ -15,7 +15,7 @@ export const HiddenLinks = (props: IHiddenLinksProps) => {
15
15
  marginRight: '-2px',
16
16
  border: '1px solid var(--rp-c-divider-light)',
17
17
  }}
18
- className="absolute top-13 right-0 z-1 p-3 w-32 rounded-xl bg-white flex flex-wrap gap-4"
18
+ className="absolute top-8 right-0 z-1 p-3 w-32 rounded-2xl bg-white flex flex-wrap gap-4"
19
19
  >
20
20
  {links.map(item => (
21
21
  <LinkContent
@@ -23,7 +23,7 @@ export const ShownLinks = (props: IShownLinksProps) => {
23
23
  ))}
24
24
  </div>
25
25
  {moreIconVisible ? (
26
- <div className="md:ml-1" onMouseEnter={mouseEnter}>
26
+ <div className="md:ml-1 p-2" onMouseEnter={mouseEnter}>
27
27
  <ArrowDown />
28
28
  </div>
29
29
  ) : null}