@rspress/core 1.7.5 → 1.8.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/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/loader.js +90 -28
- package/dist/loader.js.map +1 -1
- package/dist/runtime/App.d.ts +7 -5
- package/dist/runtime/App.js +16 -3
- package/dist/runtime/clientEntry.d.ts +1 -1
- package/dist/runtime/ssrEntry.d.ts +3 -3
- package/package.json +17 -19
- package/src/runtime/App.tsx +32 -19
package/dist/runtime/App.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PageData } from '@rspress/shared';
|
|
3
3
|
import 'virtual-global-styles';
|
|
4
|
+
export declare enum QueryStatus {
|
|
5
|
+
Show = "1",
|
|
6
|
+
Hide = "0"
|
|
7
|
+
}
|
|
4
8
|
export declare function initPageData(routePath: string): Promise<PageData>;
|
|
5
|
-
export declare function App({
|
|
6
|
-
|
|
7
|
-
}:
|
|
8
|
-
helmetContext?: object;
|
|
9
|
-
}): JSX.Element;
|
|
9
|
+
export declare function App({ helmetContext }: {
|
|
10
|
+
helmetContext?: object;
|
|
11
|
+
}): JSX.Element;
|
package/dist/runtime/App.js
CHANGED
|
@@ -13,6 +13,11 @@ import { cleanUrl, isProduction } from "@rspress/shared";
|
|
|
13
13
|
import globalComponents from "virtual-global-components";
|
|
14
14
|
import "virtual-global-styles";
|
|
15
15
|
const { default: Theme } = require("@theme");
|
|
16
|
+
var QueryStatus = /* @__PURE__ */ ((QueryStatus2) => {
|
|
17
|
+
QueryStatus2["Show"] = "1";
|
|
18
|
+
QueryStatus2["Hide"] = "0";
|
|
19
|
+
return QueryStatus2;
|
|
20
|
+
})(QueryStatus || {});
|
|
16
21
|
async function initPageData(routePath) {
|
|
17
22
|
const { routes } = process.env.__SSR__ ? require("virtual-routes-ssr") : require("virtual-routes");
|
|
18
23
|
const matched = matchRoutes(routes, routePath);
|
|
@@ -69,8 +74,15 @@ async function initPageData(routePath) {
|
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
function App({ helmetContext }) {
|
|
72
|
-
const { setData: setPageData } = useContext(DataContext);
|
|
73
|
-
const
|
|
77
|
+
const { setData: setPageData, data } = useContext(DataContext);
|
|
78
|
+
const frontmatter = data.page.frontmatter || {};
|
|
79
|
+
const { pathname, search } = useLocation();
|
|
80
|
+
const query = new URLSearchParams(search);
|
|
81
|
+
const GLOBAL_COMPONENTS_KEY = "globalUIComponents";
|
|
82
|
+
const hideGlobalUIComponents = (
|
|
83
|
+
// Disable global components in frontmatter or query
|
|
84
|
+
frontmatter[GLOBAL_COMPONENTS_KEY] === false || query.get(GLOBAL_COMPONENTS_KEY) === "0" /* Hide */
|
|
85
|
+
);
|
|
74
86
|
useLayoutEffect(() => {
|
|
75
87
|
async function refetchData() {
|
|
76
88
|
try {
|
|
@@ -85,7 +97,7 @@ function App({ helmetContext }) {
|
|
|
85
97
|
return /* @__PURE__ */ jsxs(HelmetProvider, { context: helmetContext, children: [
|
|
86
98
|
/* @__PURE__ */ jsx(Theme.Layout, {}),
|
|
87
99
|
// Global UI
|
|
88
|
-
globalComponents.map((componentInfo, index) => {
|
|
100
|
+
!hideGlobalUIComponents && globalComponents.map((componentInfo, index) => {
|
|
89
101
|
if (Array.isArray(componentInfo)) {
|
|
90
102
|
const [component, props] = componentInfo;
|
|
91
103
|
return React.createElement(component, {
|
|
@@ -105,5 +117,6 @@ function App({ helmetContext }) {
|
|
|
105
117
|
}
|
|
106
118
|
export {
|
|
107
119
|
App,
|
|
120
|
+
QueryStatus,
|
|
108
121
|
initPageData
|
|
109
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function renderInBrowser(): Promise<void>;
|
|
1
|
+
export declare function renderInBrowser(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PageData } from '@rspress/shared';
|
|
2
2
|
export declare function render(pagePath: string, helmetContext: object): Promise<{
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
appHtml: string;
|
|
4
|
+
pageData: PageData;
|
|
5
5
|
}>;
|
|
6
|
-
export { routes } from 'virtual-routes-ssr';
|
|
6
|
+
export { routes } from 'virtual-routes-ssr';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -40,11 +40,11 @@
|
|
|
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/utils": "2.
|
|
44
|
-
"@rsbuild/core": "0.1.
|
|
45
|
-
"@rsbuild/plugin-react": "0.1.
|
|
46
|
-
"@rsbuild/plugin-svgr": "0.1.
|
|
47
|
-
"@rspress/mdx-rs": "0.4.
|
|
43
|
+
"@modern-js/utils": "2.42.0",
|
|
44
|
+
"@rsbuild/core": "0.1.9",
|
|
45
|
+
"@rsbuild/plugin-react": "0.1.9",
|
|
46
|
+
"@rsbuild/plugin-svgr": "0.1.9",
|
|
47
|
+
"@rspress/mdx-rs": "0.4.3",
|
|
48
48
|
"@types/compression": "^1.7.2",
|
|
49
49
|
"@types/polka": "^0.5.4",
|
|
50
50
|
"autoprefixer": "10.4.13",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"github-slugger": "^2.0.0",
|
|
58
58
|
"globby": "11.1.0",
|
|
59
59
|
"hast-util-from-html": "^1.0.0",
|
|
60
|
+
"hast-util-heading-rank": "^3.0.0",
|
|
60
61
|
"html-to-text": "^9.0.3",
|
|
61
62
|
"htmr": "^1.0.2",
|
|
62
63
|
"is-html": "^3.0.0",
|
|
63
|
-
"jsdom": "20.0.3",
|
|
64
64
|
"lodash-es": "^4.17.21",
|
|
65
65
|
"mdast-util-mdxjs-esm": "^1.3.0",
|
|
66
66
|
"node-fetch": "3.3.0",
|
|
@@ -73,9 +73,7 @@
|
|
|
73
73
|
"react-helmet-async": "^1.3.0",
|
|
74
74
|
"react-lazy-with-preload": "^2.2.1",
|
|
75
75
|
"react-syntax-highlighter": "^15.5.0",
|
|
76
|
-
"rehype-autolink-headings": "6.1.1",
|
|
77
76
|
"rehype-external-links": "^2.0.1",
|
|
78
|
-
"rehype-slug": "^5.1.0",
|
|
79
77
|
"rehype-stringify": "^9.0.3",
|
|
80
78
|
"remark": "^14.0.2",
|
|
81
79
|
"remark-gfm": "3.0.1",
|
|
@@ -91,18 +89,18 @@
|
|
|
91
89
|
"unist-util-visit": "^4.1.1",
|
|
92
90
|
"unist-util-visit-children": "^2.0.1",
|
|
93
91
|
"yaml-front-matter": "^4.1.1",
|
|
94
|
-
"@rspress/theme-default": "1.
|
|
95
|
-
"@rspress/
|
|
96
|
-
"@rspress/plugin-
|
|
97
|
-
"@rspress/plugin-
|
|
98
|
-
"@rspress/plugin-
|
|
99
|
-
"@rspress/
|
|
100
|
-
"@rspress/
|
|
92
|
+
"@rspress/theme-default": "1.8.1",
|
|
93
|
+
"@rspress/runtime": "1.8.1",
|
|
94
|
+
"@rspress/plugin-last-updated": "1.8.1",
|
|
95
|
+
"@rspress/plugin-auto-nav-sidebar": "1.8.1",
|
|
96
|
+
"@rspress/plugin-medium-zoom": "1.8.1",
|
|
97
|
+
"@rspress/shared": "1.8.1",
|
|
98
|
+
"@rspress/plugin-container-syntax": "1.8.1"
|
|
101
99
|
},
|
|
102
100
|
"devDependencies": {
|
|
103
|
-
"@modern-js/plugin-tailwindcss": "2.
|
|
104
|
-
"@modern-js/tsconfig": "2.
|
|
105
|
-
"@modern-js/types": "2.
|
|
101
|
+
"@modern-js/plugin-tailwindcss": "2.42.0",
|
|
102
|
+
"@modern-js/tsconfig": "2.42.0",
|
|
103
|
+
"@modern-js/types": "2.42.0",
|
|
106
104
|
"@types/body-scroll-lock": "^3.1.0",
|
|
107
105
|
"@types/fs-extra": "^9.0.13",
|
|
108
106
|
"@types/hast": "^2.3.4",
|
package/src/runtime/App.tsx
CHANGED
|
@@ -15,6 +15,11 @@ import 'virtual-global-styles';
|
|
|
15
15
|
// eslint-disable-next-line import/no-commonjs
|
|
16
16
|
const { default: Theme } = require('@theme');
|
|
17
17
|
|
|
18
|
+
export enum QueryStatus {
|
|
19
|
+
Show = '1',
|
|
20
|
+
Hide = '0',
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
type RspressPageMeta = Record<
|
|
19
24
|
string,
|
|
20
25
|
{
|
|
@@ -46,7 +51,6 @@ export async function initPageData(routePath: string): Promise<PageData> {
|
|
|
46
51
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
47
52
|
const {
|
|
48
53
|
toc = [],
|
|
49
|
-
|
|
50
54
|
title = '',
|
|
51
55
|
frontmatter,
|
|
52
56
|
} = (mod.default.__RSPRESS_PAGE_META as RspressPageMeta)?.[
|
|
@@ -91,8 +95,15 @@ export async function initPageData(routePath: string): Promise<PageData> {
|
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
export function App({ helmetContext }: { helmetContext?: object }) {
|
|
94
|
-
const { setData: setPageData } = useContext(DataContext);
|
|
95
|
-
const
|
|
98
|
+
const { setData: setPageData, data } = useContext(DataContext);
|
|
99
|
+
const frontmatter = data.page.frontmatter || {};
|
|
100
|
+
const { pathname, search } = useLocation();
|
|
101
|
+
const query = new URLSearchParams(search);
|
|
102
|
+
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
103
|
+
const hideGlobalUIComponents =
|
|
104
|
+
// Disable global components in frontmatter or query
|
|
105
|
+
frontmatter[GLOBAL_COMPONENTS_KEY] === false ||
|
|
106
|
+
query.get(GLOBAL_COMPONENTS_KEY) === QueryStatus.Hide;
|
|
96
107
|
useLayoutEffect(() => {
|
|
97
108
|
async function refetchData() {
|
|
98
109
|
try {
|
|
@@ -104,27 +115,29 @@ export function App({ helmetContext }: { helmetContext?: object }) {
|
|
|
104
115
|
}
|
|
105
116
|
refetchData();
|
|
106
117
|
}, [pathname, setPageData]);
|
|
118
|
+
|
|
107
119
|
return (
|
|
108
120
|
<HelmetProvider context={helmetContext}>
|
|
109
121
|
<Theme.Layout />
|
|
110
122
|
{
|
|
111
123
|
// Global UI
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
!hideGlobalUIComponents &&
|
|
125
|
+
globalComponents.map((componentInfo, index) => {
|
|
126
|
+
if (Array.isArray(componentInfo)) {
|
|
127
|
+
const [component, props] = componentInfo;
|
|
128
|
+
return React.createElement(component, {
|
|
129
|
+
// The component order is stable
|
|
130
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
131
|
+
key: index,
|
|
132
|
+
...props,
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
return React.createElement(componentInfo, {
|
|
136
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
137
|
+
key: index,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
})
|
|
128
141
|
}
|
|
129
142
|
</HelmetProvider>
|
|
130
143
|
);
|