Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions packages/core/src/node/auto-nav-sidebar/locales.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('walk', () => {
const mockNormalizeRoutePath = (link: string) => {
return normalizeRoutePath(
link,
'/base',
'en',
'',
['zh', 'en'],
Expand All @@ -23,7 +22,6 @@ describe('walk', () => {
const mockGetRoutePathParts = (link: string) => {
return getRoutePathParts(
link,
'/base',
'en',
'',
['zh', 'en'],
Expand All @@ -46,13 +44,13 @@ describe('walk', () => {
"default": [
{
"activeMatch": "^/guide/",
"link": "/base/zh/guide/",
"link": "/zh/guide/",
"text": "Guide",
},
],
},
"sidebar": {
"/base/zh/guide": [
"/zh/guide": [
{
"_fileKey": "zh/guide/test-dir/index",
"collapsed": undefined,
Expand All @@ -62,13 +60,13 @@ describe('walk', () => {
{
"_fileKey": "zh/guide/test-dir/getting-started",
"context": undefined,
"link": "/base/zh/guide/test-dir/getting-started",
"link": "/zh/guide/test-dir/getting-started",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Getting started 页面",
},
],
"link": "/base/zh/guide/test-dir/",
"link": "/zh/guide/test-dir/",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Test dir 页面",
Expand All @@ -82,44 +80,44 @@ describe('walk', () => {
{
"_fileKey": "zh/guide/test-same-name-dir/index",
"context": undefined,
"link": "/base/zh/guide/test-same-name-dir/",
"link": "/zh/guide/test-same-name-dir/",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Test same name dir 页面",
},
],
"link": "/base/zh/guide/test-same-name-dir",
"link": "/zh/guide/test-same-name-dir",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Test same name dir in file 页面",
},
{
"_fileKey": "zh/guide/a",
"context": undefined,
"link": "/base/zh/guide/a",
"link": "/zh/guide/a",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Page a 页面",
},
{
"_fileKey": "zh/guide/b",
"context": undefined,
"link": "/base/zh/guide/b",
"link": "/zh/guide/b",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Page b 页面",
},
{
"_fileKey": "zh/guide/c",
"context": undefined,
"link": "/base/zh/guide/c",
"link": "/zh/guide/c",
"overviewHeaders": undefined,
"tag": undefined,
"text": "c",
},
{
"context": undefined,
"link": "/base/zh/guide/test-dir",
"link": "/zh/guide/test-dir",
"tag": undefined,
"text": "My Link",
},
Expand All @@ -131,13 +129,13 @@ describe('walk', () => {
"default": [
{
"activeMatch": "^/guide/",
"link": "/base/guide/",
"link": "/guide/",
"text": "Guide",
},
],
},
"sidebar": {
"/base/guide": [
"/guide": [
{
"_fileKey": "en/guide/test-dir/index",
"collapsed": undefined,
Expand All @@ -147,13 +145,13 @@ describe('walk', () => {
{
"_fileKey": "en/guide/test-dir/getting-started",
"context": undefined,
"link": "/base/guide/test-dir/getting-started",
"link": "/guide/test-dir/getting-started",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Getting started",
},
],
"link": "/base/guide/test-dir/",
"link": "/guide/test-dir/",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Test dir",
Expand All @@ -167,44 +165,44 @@ describe('walk', () => {
{
"_fileKey": "en/guide/test-same-name-dir/index",
"context": undefined,
"link": "/base/guide/test-same-name-dir/",
"link": "/guide/test-same-name-dir/",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Test same name dir",
},
],
"link": "/base/guide/test-same-name-dir",
"link": "/guide/test-same-name-dir",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Test same name dir in file",
},
{
"_fileKey": "en/guide/a",
"context": undefined,
"link": "/base/guide/a",
"link": "/guide/a",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Page a",
},
{
"_fileKey": "en/guide/b",
"context": undefined,
"link": "/base/guide/b",
"link": "/guide/b",
"overviewHeaders": undefined,
"tag": undefined,
"text": "Page b",
},
{
"_fileKey": "en/guide/c",
"context": undefined,
"link": "/base/guide/c",
"link": "/guide/c",
"overviewHeaders": undefined,
"tag": undefined,
"text": "c",
},
{
"context": undefined,
"link": "/base/guide/test-dir",
"link": "/guide/test-dir",
"tag": undefined,
"text": "My Link",
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/node/auto-nav-sidebar/walk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
import { walk } from './walk';

const mockNormalizeRoutePath = (link: string) => {
return normalizeRoutePath(link, '/', '', '', [], [], ['.md', '.mdx', '.tsx']);
return normalizeRoutePath(link, '', '', [], [], ['.md', '.mdx', '.tsx']);
};

const mockGetRoutePathParts = (link: string) => {
return getRoutePathParts(link, '/', '', '', [], []);
return getRoutePathParts(link, '', '', [], []);
};

RouteService.__instance__ = {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/node/initRsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { globalStylesVMPlugin } from './runtimeModule/globalStyles';
import { globalUIComponentsVMPlugin } from './runtimeModule/globalUIComponents';
import { i18nVMPlugin } from './runtimeModule/i18n';
import { routeListVMPlugin } from './runtimeModule/routeList';
import { runtimeConfigVMPlugin } from './runtimeModule/runtimeConfig';
import { searchHookVMPlugin } from './runtimeModule/searchHooks';
import type { FactoryContext } from './runtimeModule/types';
import { serveSearchIndexMiddleware } from './searchIndex';
Expand Down Expand Up @@ -149,6 +150,11 @@ async function createInternalBuildConfig(
* Get virtual modules from plugins
*/
...(await getVirtualModulesFromPlugins(pluginDriver)),

/**
* Serialize rspress.config.ts to runtime
*/
...runtimeConfigVMPlugin(context),
},
}),
...(enableSSG
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/node/mdx/remarkPlugins/normalizeLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ function normalizeLink(
if (url.startsWith('.')) {
url = path.posix.join(slash(path.dirname(relativePath)), url);
} else if (routeService) {
const [_, pathVersion, pathLang] = routeService.getRoutePathParts(
const [pathVersion, pathLang] = routeService.getRoutePathParts(
slash(relativePath),
);
const [__, urlVersion, urlLang, urlPath] =
routeService.getRoutePathParts(url);
const [urlVersion, urlLang, urlPath] = routeService.getRoutePathParts(url);

url = addLeadingSlash(urlPath);

Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/node/route/RouteService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export class RouteService {

#exclude: string[] = [];

#base: string = '';

#tempDir: string = '';

#pluginDriver: PluginDriver;
Expand Down Expand Up @@ -94,7 +92,6 @@ export class RouteService {
userConfig?.themeConfig?.locales ??
[]
).map(item => item.lang);
this.#base = userConfig?.base || '';
this.#tempDir = tempDir;
this.#pluginDriver = pluginDriver;

Expand Down Expand Up @@ -239,7 +236,6 @@ ${routeMeta
getRoutePathParts(routePath: string) {
return getRoutePathParts(
routePath,
this.#base,
this.#defaultLang,
this.#defaultVersion,
this.#langs,
Expand All @@ -250,7 +246,6 @@ ${routeMeta
normalizeRoutePath(routePath: string) {
return normalizeRoutePath(
routePath,
this.#base,
this.#defaultLang,
this.#defaultVersion,
this.#langs,
Expand Down
Loading