@rspress/core 0.0.0-next-20230816082004 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "0.0.0-next-20230816082004",
3
+ "version": "0.0.1",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -92,10 +92,10 @@
92
92
  "unist-util-visit": "^4.1.1",
93
93
  "unist-util-visit-children": "^2.0.1",
94
94
  "yaml-front-matter": "^4.1.1",
95
- "@rspress/shared": "0.0.0-next-20230816082004",
96
- "@rspress/plugin-medium-zoom": "0.0.0-next-20230816082004",
97
- "@rspress/plugin-last-updated": "0.0.0-next-20230816082004",
98
- "@rspress/plugin-auto-sidebar": "0.0.0-next-20230816082004"
95
+ "@rspress/shared": "0.0.1",
96
+ "@rspress/plugin-medium-zoom": "0.0.1",
97
+ "@rspress/plugin-last-updated": "0.0.1",
98
+ "@rspress/plugin-auto-nav-sidebar": "0.0.1"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "react": ">=17"
@@ -23,7 +23,7 @@ export function HomeHero({ frontmatter }: { frontmatter: FrontMatterMeta }) {
23
23
  }}
24
24
  ></div>
25
25
  <div className="m-auto flex flex-col md:flex-row max-w-6xl">
26
- <div className="flex flex-col justify-center text-center max-w-xl sm:max-w-3xl m-auto order-2 md:order-1">
26
+ <div className="flex flex-col justify-center text-center max-w-xl sm:max-w-4xl m-auto order-2 md:order-1">
27
27
  <h1 className="font-bold text-3xl sm:text-6xl md:text-7xl m-auto sm:m-4 md:m-0 md:pb-3 lg:pb-5 leading-tight z-10">
28
28
  <span className={styles.clip} style={{ lineHeight: '1.15' }}>
29
29
  {hero.name}
@@ -32,7 +32,7 @@ export function HomeHero({ frontmatter }: { frontmatter: FrontMatterMeta }) {
32
32
  {hero.text?.length && (
33
33
  <p
34
34
  className={`mx-auto md:m-0 text-3xl sm:text-5xl md:text-6xl pb-2 font-bold z-10 max-w-392px ${
35
- hasImage ? 'sm:max-w-xl' : 'sm:max-w-3xl'
35
+ hasImage ? 'sm:max-w-xl' : 'sm:max-w-4xl'
36
36
  }`}
37
37
  style={{ lineHeight: '1.15' }}
38
38
  >
@@ -85,17 +85,21 @@ export function Search() {
85
85
  }
86
86
  break;
87
87
  case KEY_CODE.ARROW_DOWN:
88
- e.preventDefault();
89
- setCurrentSuggestionIndex(
90
- (currentSuggestionIndex + 1) % suggestions.length,
91
- );
88
+ if (focused) {
89
+ e.preventDefault();
90
+ setCurrentSuggestionIndex(
91
+ (currentSuggestionIndex + 1) % suggestions.length,
92
+ );
93
+ }
92
94
  break;
93
95
  case KEY_CODE.ARROW_UP:
94
- e.preventDefault();
95
- setCurrentSuggestionIndex(
96
- (currentSuggestionIndex - 1 + suggestions.length) %
97
- suggestions.length,
98
- );
96
+ if (focused) {
97
+ e.preventDefault();
98
+ setCurrentSuggestionIndex(
99
+ (currentSuggestionIndex - 1 + suggestions.length) %
100
+ suggestions.length,
101
+ );
102
+ }
99
103
  break;
100
104
  case KEY_CODE.ENTER:
101
105
  if (currentSuggestionIndex >= 0) {
@@ -95,3 +95,16 @@
95
95
  color: var(--modern-c-brand);
96
96
  font-weight: bolder;
97
97
  }
98
+
99
+ :global(.modern-sidebar-group) {
100
+ position: relative;
101
+ &::before {
102
+ content: '';
103
+ position: absolute;
104
+ top: 0;
105
+ left: 12px;
106
+ width: 1px;
107
+ height: 100%;
108
+ background-color: var(--modern-c-gray-light-4);
109
+ }
110
+ }
@@ -16,11 +16,10 @@ interface Props {
16
16
  sidebarData: (NormalizedSidebarGroup | SidebarItem)[];
17
17
  }
18
18
 
19
- const textEllipsisStyle = {
20
- whiteSpace: 'nowrap',
21
- overflow: 'hidden',
22
- textOverflow: 'ellipsis',
23
- } as const;
19
+ const highlightTitleStyle = {
20
+ color: 'var(--modern-c-text-1)',
21
+ fontSize: '14px',
22
+ };
24
23
 
25
24
  interface SidebarItemProps {
26
25
  id: string;
@@ -70,12 +69,12 @@ export function SidebarItemComp(props: SidebarItemProps) {
70
69
  onMouseEnter={() => props.preloadLink(item.link)}
71
70
  className={`${
72
71
  active ? styles.menuItemActive : styles.menuItem
73
- } mt-1 py-1.5 px-3 rounded-xl font-medium flex`}
72
+ } mt-1 py-1.5 px-2 rounded-xl font-medium flex`}
74
73
  style={{
75
- ...textEllipsisStyle,
76
74
  // The first level menu item will have the same font size as the sidebar group
77
75
  fontSize: depth === 0 ? '14px' : '13px',
78
- marginLeft: depth === 0 ? 0 : '12px',
76
+ marginLeft: depth === 0 ? 0 : '20px',
77
+ ...(depth === 0 ? highlightTitleStyle : {}),
79
78
  }}
80
79
  >
81
80
  <Tag tag={item.tag} />
@@ -176,7 +175,7 @@ export function SidebarGroupComp(props: SidebarItemProps) {
176
175
  key={id}
177
176
  className="mt-1 block"
178
177
  style={{
179
- marginLeft: depth === 0 ? 0 : '12px',
178
+ marginLeft: depth === 0 ? 0 : '20px',
180
179
  }}
181
180
  >
182
181
  <div
@@ -202,9 +201,9 @@ export function SidebarGroupComp(props: SidebarItemProps) {
202
201
  }}
203
202
  >
204
203
  <h2
205
- className="py-1 px-2 text-sm font-medium ml-1 flex"
204
+ className="py-1 px-2 text-sm font-medium flex"
206
205
  style={{
207
- ...textEllipsisStyle,
206
+ ...(depth === 0 ? highlightTitleStyle : {}),
208
207
  }}
209
208
  >
210
209
  <Tag tag={item.tag} />
@@ -229,7 +228,7 @@ export function SidebarGroupComp(props: SidebarItemProps) {
229
228
  >
230
229
  <div
231
230
  ref={innerRef}
232
- className="transition-opacity duration-500 ease-in-out"
231
+ className="modern-sidebar-group transition-opacity duration-500 ease-in-out"
233
232
  style={{
234
233
  opacity: initialState.current ? 0 : 1,
235
234
  }}
@@ -8,15 +8,22 @@ export const A = (props: ComponentProps<'a'>) => {
8
8
  const lang = useLang();
9
9
  const pageData = usePageData();
10
10
  const defaultLang = pageData.siteData.lang;
11
+
11
12
  if (defaultLang && !isExternalUrl(href) && !href.startsWith('#')) {
12
13
  href = normalizeSlash(href);
14
+ const startWithLang = removeBase(href).startsWith(`/${lang}`);
13
15
  // Add lang prefix if not default lang
14
- if (lang !== defaultLang && !removeBase(href).startsWith(`/${lang}`)) {
16
+ if (lang !== defaultLang && !startWithLang) {
15
17
  href = `/${lang}${href}`;
16
18
  }
17
19
 
20
+ if (lang === defaultLang && startWithLang) {
21
+ href = removeBase(href).replace(`/${lang}`, '');
22
+ }
23
+
18
24
  href = withBase(href || '');
19
25
  }
26
+
20
27
  return (
21
28
  <a {...props} className={`${styles.link} ${props.className}`} href={href} />
22
29
  );
@@ -86,7 +86,7 @@ export const Layout: React.FC<LayoutProps> = props => {
86
86
  };
87
87
 
88
88
  useEffect(() => {
89
- if (!defaultLang) {
89
+ if (!defaultLang || process.env.TEST === '1') {
90
90
  // Check the window.navigator.language to determine the default language
91
91
  // If the default language is not the same as the current language, redirect to the default language
92
92
  // The default language will not have a lang prefix in the URL