@rspress/core 1.1.3 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "@mdx-js/react": "2.2.1",
43
43
  "@modern-js/builder": "2.37.1",
44
44
  "@modern-js/builder-rspack-provider": "2.37.1",
45
- "@rspress/mdx-rs": "0.4.0",
45
+ "@rspress/mdx-rs": "0.4.1",
46
46
  "@modern-js/utils": "2.37.1",
47
47
  "@types/compression": "^1.7.2",
48
48
  "@types/polka": "^0.5.4",
@@ -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.1.3",
93
- "@rspress/plugin-medium-zoom": "1.1.3",
94
- "@rspress/plugin-last-updated": "1.1.3",
95
- "@rspress/plugin-auto-nav-sidebar": "1.1.3",
96
- "@rspress/plugin-container-syntax": "1.1.3"
92
+ "@rspress/shared": "1.2.0",
93
+ "@rspress/plugin-medium-zoom": "1.2.0",
94
+ "@rspress/plugin-last-updated": "1.2.0",
95
+ "@rspress/plugin-auto-nav-sidebar": "1.2.0",
96
+ "@rspress/plugin-container-syntax": "1.2.0"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@modern-js/plugin-tailwindcss": "2.37.1",
@@ -1,10 +1,13 @@
1
1
  import { useState } from 'react';
2
2
  import { BrowserRouter } from 'react-router-dom';
3
3
  import { isProduction } from '@rspress/shared';
4
+ import siteData from 'virtual-site-data';
4
5
  import { App, initPageData } from './App';
5
6
  import { DataContext, ThemeContext } from './hooks';
6
7
  import { normalizeRoutePath } from './utils';
7
8
 
9
+ const enableSSG = siteData.ssg;
10
+
8
11
  // eslint-disable-next-line import/no-commonjs
9
12
  const { default: Theme } = require('@theme');
10
13
 
@@ -31,7 +34,7 @@ export async function renderInBrowser() {
31
34
  const RootApp = await enhancedApp();
32
35
  if (process.env.__IS_REACT_18__) {
33
36
  const { createRoot, hydrateRoot } = require('react-dom/client');
34
- if (isProduction()) {
37
+ if (isProduction() && enableSSG) {
35
38
  hydrateRoot(container, <RootApp />);
36
39
  } else {
37
40
  createRoot(container).render(<RootApp />);
@@ -26,10 +26,10 @@ interface Group {
26
26
  // In the meantime, some sidebar items also should be shown in the page, we collect them in the group named 'Others' and show them in the page.
27
27
  const DEFAULT_GROUP = 'Others';
28
28
 
29
- export function Overview() {
29
+ export function Overview(props: { content: React.ReactNode }) {
30
30
  const {
31
31
  siteData,
32
- page: { routePath },
32
+ page: { routePath, title },
33
33
  } = usePageData();
34
34
  const { pages } = siteData;
35
35
  const overviewModules = pages.filter(
@@ -90,9 +90,11 @@ export function Overview() {
90
90
  return (
91
91
  <div className="overview-index mx-auto px-8">
92
92
  <div className="flex items-center justify-between">
93
- <h1 className="text-3xl leading-10 tracking-tight">Overview</h1>
93
+ {!title && (
94
+ <h1 className="text-3xl leading-10 tracking-tight">Overview</h1>
95
+ )}
94
96
  </div>
95
-
97
+ {props.content}
96
98
  {groups.map(group => (
97
99
  <div className="mb-16" key={group.name}>
98
100
  {/* If there is no sidebar group, we show the sidebar items directly and hide the group name */}
@@ -14,8 +14,9 @@ export const HiddenLinks = (props: IHiddenLinksProps) => {
14
14
  boxShadow: 'var(--rp-shadow-3)',
15
15
  marginRight: '-2px',
16
16
  border: '1px solid var(--rp-c-divider-light)',
17
+ background: 'var(--rp-c-bg)',
17
18
  }}
18
- className="absolute top-8 right-0 z-1 p-3 w-32 rounded-2xl bg-white flex flex-wrap gap-4"
19
+ className="absolute top-8 right-0 z-1 p-3 w-32 rounded-2xl flex flex-wrap gap-4"
19
20
  >
20
21
  {links.map(item => (
21
22
  <LinkContent
@@ -55,7 +55,7 @@ export const LinkContent = (props: ILinkContentComp) => {
55
55
  border: '1px solid var(--rp-c-divider-light)',
56
56
  ...popperStyle,
57
57
  }}
58
- className="z-1 p-3 w-50 absolute right-0 bg-white dark:bg-dark"
58
+ className="z-[1] p-3 w-50 absolute right-0 bg-white dark:bg-dark"
59
59
  >
60
60
  <div className="text-md">{content}</div>
61
61
  </div>
@@ -73,7 +73,7 @@ export const LinkContent = (props: ILinkContentComp) => {
73
73
  {IconComp}
74
74
  {contentVisible ? (
75
75
  <div
76
- className="break-all z-1 p-3 w-50 absolute right-0 rounded-xl"
76
+ className="break-all z-[1] p-3 w-[50px] h-[50px] absolute right-0 bg-white dark:bg-dark rounded-xl"
77
77
  style={{
78
78
  boxShadow: 'var(--rp-shadow-3)',
79
79
  ...popperStyle,
@@ -63,6 +63,14 @@ export function DocLayout(props: DocLayoutProps) {
63
63
  }
64
64
  }, []);
65
65
 
66
+ const docContent = (
67
+ <TabDataContext.Provider value={{ tabData, setTabData }}>
68
+ <MDXProvider components={getCustomMDXComponent()}>
69
+ <Content />
70
+ </MDXProvider>
71
+ </TabDataContext.Provider>
72
+ );
73
+
66
74
  return (
67
75
  <div
68
76
  className={`${styles.docLayout} pt-0`}
@@ -77,16 +85,12 @@ export function DocLayout(props: DocLayoutProps) {
77
85
  >
78
86
  <div className="w-full">
79
87
  {isOverviewPage ? (
80
- <Overview />
88
+ <div className="rspress-doc">
89
+ <Overview content={docContent} />
90
+ </div>
81
91
  ) : (
82
92
  <div>
83
- <div className="rspress-doc">
84
- <TabDataContext.Provider value={{ tabData, setTabData }}>
85
- <MDXProvider components={getCustomMDXComponent()}>
86
- <Content />
87
- </MDXProvider>
88
- </TabDataContext.Provider>
89
- </div>
93
+ <div className="rspress-doc">{docContent}</div>
90
94
  <div className="rspress-doc-footer">
91
95
  {beforeDocFooter}
92
96
  {hasFooter && <DocFooter />}