@rspress/core 1.41.3 → 1.42.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/dist/193.js +1 -1
- package/dist/index.js +2 -3
- package/dist/runtime/App.js +5 -7
- package/dist/runtime/clientEntry.js +1 -1
- package/package.json +8 -8
- package/src/runtime/App.tsx +17 -16
- package/src/runtime/clientEntry.tsx +3 -9
package/dist/193.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1406,11 +1406,10 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1406
1406
|
CUSTOM_THEME_DIR,
|
|
1407
1407
|
DEFAULT_THEME
|
|
1408
1408
|
],
|
|
1409
|
-
'
|
|
1409
|
+
'@theme-assets': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(DEFAULT_THEME, '../assets'),
|
|
1410
1410
|
'@rspress/core': PACKAGE_ROOT,
|
|
1411
1411
|
'react-lazy-with-preload': require.resolve('react-lazy-with-preload'),
|
|
1412
|
-
'react-syntax-highlighter': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(require.resolve('react-syntax-highlighter/package.json'))
|
|
1413
|
-
'@theme-assets': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(DEFAULT_THEME, '../assets')
|
|
1412
|
+
'react-syntax-highlighter': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(require.resolve('react-syntax-highlighter/package.json'))
|
|
1414
1413
|
}
|
|
1415
1414
|
},
|
|
1416
1415
|
source: {
|
package/dist/runtime/App.js
CHANGED
|
@@ -14,16 +14,14 @@ var App_rslib_entry_QueryStatus = /*#__PURE__*/ function(QueryStatus) {
|
|
|
14
14
|
}({});
|
|
15
15
|
async function initPageData(routePath) {
|
|
16
16
|
var _siteData_multiVersion;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
if (matched) {
|
|
17
|
+
const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
|
|
18
|
+
if (matchedRoute) {
|
|
20
19
|
var _mod_default___RSPRESS_PAGE_META;
|
|
21
|
-
const matchedRoute = matched[0].route;
|
|
22
20
|
const mod = await matchedRoute.preload();
|
|
23
|
-
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(
|
|
21
|
+
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matchedRoute.filePath);
|
|
24
22
|
const extractPageInfo = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].pages.find((page)=>{
|
|
25
23
|
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
26
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(
|
|
24
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(matchedRoute.path));
|
|
27
25
|
});
|
|
28
26
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
29
27
|
const meta = (null === (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) || void 0 === _mod_default___RSPRESS_PAGE_META ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
|
|
@@ -80,7 +78,7 @@ function App({ helmetContext }) {
|
|
|
80
78
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
81
79
|
async function refetchData() {
|
|
82
80
|
try {
|
|
83
|
-
const pageData = await initPageData(
|
|
81
|
+
const pageData = await initPageData(pathname);
|
|
84
82
|
setPageData(pageData);
|
|
85
83
|
} catch (e) {
|
|
86
84
|
console.log(e);
|
|
@@ -33,7 +33,7 @@ const { default: Theme, useThemeState } = __webpack_require__("@theme");
|
|
|
33
33
|
async function renderInBrowser() {
|
|
34
34
|
const container = document.getElementById('root');
|
|
35
35
|
const enhancedApp = async ()=>{
|
|
36
|
-
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)(
|
|
36
|
+
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)(window.location.pathname);
|
|
37
37
|
return function() {
|
|
38
38
|
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
39
39
|
const [theme, setTheme] = useThemeState();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"unified": "^10.1.2",
|
|
79
79
|
"unist-util-visit": "^4.1.2",
|
|
80
80
|
"unist-util-visit-children": "^3.0.0",
|
|
81
|
-
"@rspress/plugin-auto-nav-sidebar": "1.
|
|
82
|
-
"@rspress/plugin-container-syntax": "1.
|
|
83
|
-
"@rspress/plugin-
|
|
84
|
-
"@rspress/
|
|
85
|
-
"@rspress/
|
|
86
|
-
"@rspress/shared": "1.
|
|
87
|
-
"@rspress/theme-default": "1.
|
|
81
|
+
"@rspress/plugin-auto-nav-sidebar": "1.42.0",
|
|
82
|
+
"@rspress/plugin-container-syntax": "1.42.0",
|
|
83
|
+
"@rspress/plugin-last-updated": "1.42.0",
|
|
84
|
+
"@rspress/plugin-medium-zoom": "1.42.0",
|
|
85
|
+
"@rspress/runtime": "1.42.0",
|
|
86
|
+
"@rspress/shared": "1.42.0",
|
|
87
|
+
"@rspress/theme-default": "1.42.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@microsoft/api-extractor": "^7.49.2",
|
package/src/runtime/App.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataContext,
|
|
3
3
|
isEqualPath,
|
|
4
|
-
|
|
5
|
-
normalizeRoutePath,
|
|
4
|
+
pathnameToRouteService,
|
|
6
5
|
useLocation,
|
|
7
6
|
} from '@rspress/runtime';
|
|
8
7
|
import {
|
|
@@ -31,32 +30,32 @@ type PageMeta = {
|
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
export async function initPageData(routePath: string): Promise<PageData> {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
((await import('virtual-routes-ssr')) as typeof import(
|
|
37
|
-
'virtual-routes-ssr'
|
|
38
|
-
))
|
|
39
|
-
: ((await import('virtual-routes')) as typeof import('virtual-routes'));
|
|
40
|
-
const matched = matchRoutes(routes, routePath)!;
|
|
41
|
-
if (matched) {
|
|
33
|
+
const matchedRoute = pathnameToRouteService(routePath)!;
|
|
34
|
+
if (matchedRoute) {
|
|
42
35
|
// Preload route component
|
|
43
|
-
const matchedRoute = matched[0].route;
|
|
44
36
|
const mod = await matchedRoute.preload();
|
|
45
|
-
const pagePath = cleanUrl(
|
|
37
|
+
const pagePath = cleanUrl(matchedRoute.filePath);
|
|
46
38
|
const extractPageInfo = siteData.pages.find(page => {
|
|
47
39
|
const normalize = (p: string) =>
|
|
48
40
|
// compat the path that has no / suffix and ignore case
|
|
49
41
|
p
|
|
50
42
|
.replace(/\/$/, '')
|
|
51
43
|
.toLowerCase();
|
|
52
|
-
return isEqualPath(
|
|
44
|
+
return isEqualPath(
|
|
45
|
+
normalize(page.routePath),
|
|
46
|
+
normalize(matchedRoute.path),
|
|
47
|
+
);
|
|
53
48
|
});
|
|
54
49
|
|
|
55
50
|
// FIXME: when sidebar item is configured as link string, the sidebar text won't updated when page title changed
|
|
56
51
|
// Reason: The sidebar item text depends on pageData, which is not updated when page title changed, because the pageData is computed once when build
|
|
57
52
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
58
53
|
const meta: PageMeta =
|
|
59
|
-
|
|
54
|
+
(
|
|
55
|
+
mod.default as unknown as {
|
|
56
|
+
__RSPRESS_PAGE_META: Record<string, PageMeta>;
|
|
57
|
+
}
|
|
58
|
+
).__RSPRESS_PAGE_META?.[encodedPagePath] || ({} as PageMeta);
|
|
60
59
|
// mdx loader will generate __RSPRESS_PAGE_META,
|
|
61
60
|
// if the filePath don't match it, we can get meta from j(t)sx if we customize it
|
|
62
61
|
const {
|
|
@@ -64,7 +63,9 @@ export async function initPageData(routePath: string): Promise<PageData> {
|
|
|
64
63
|
title = '',
|
|
65
64
|
frontmatter = {},
|
|
66
65
|
...rest
|
|
67
|
-
} = MDX_REGEXP.test(matchedRoute.filePath)
|
|
66
|
+
} = MDX_REGEXP.test(matchedRoute.filePath)
|
|
67
|
+
? meta
|
|
68
|
+
: (mod as unknown as PageMeta);
|
|
68
69
|
return {
|
|
69
70
|
siteData,
|
|
70
71
|
page: {
|
|
@@ -138,7 +139,7 @@ export function App({ helmetContext }: { helmetContext?: object }) {
|
|
|
138
139
|
useLayoutEffect(() => {
|
|
139
140
|
async function refetchData() {
|
|
140
141
|
try {
|
|
141
|
-
const pageData = await initPageData(
|
|
142
|
+
const pageData = await initPageData(pathname);
|
|
142
143
|
setPageData(pageData);
|
|
143
144
|
} catch (e) {
|
|
144
145
|
console.log(e);
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BrowserRouter,
|
|
3
|
-
DataContext,
|
|
4
|
-
ThemeContext,
|
|
5
|
-
normalizeRoutePath,
|
|
6
|
-
} from '@rspress/runtime';
|
|
1
|
+
import { BrowserRouter, DataContext, ThemeContext } from '@rspress/runtime';
|
|
7
2
|
import { isProduction } from '@rspress/shared';
|
|
8
3
|
import { useMemo, useState } from 'react';
|
|
9
4
|
import siteData from 'virtual-site-data';
|
|
@@ -18,9 +13,8 @@ export async function renderInBrowser() {
|
|
|
18
13
|
const container = document.getElementById('root')!;
|
|
19
14
|
|
|
20
15
|
const enhancedApp = async () => {
|
|
21
|
-
const initialPageData = await initPageData(
|
|
22
|
-
|
|
23
|
-
);
|
|
16
|
+
const initialPageData = await initPageData(window.location.pathname);
|
|
17
|
+
|
|
24
18
|
return function RootApp() {
|
|
25
19
|
const [data, setData] = useState(initialPageData);
|
|
26
20
|
const [theme, setTheme] = useThemeState();
|