Skip to content

Commit

Permalink
fix: the resolution of the src directory does not work in english
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Aug 22, 2023
1 parent 39cd519 commit 9e65764
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/client/theme-api/useNavData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
IUserNavItems,
IUserNavMode,
} from './types';
import { getLocaleClearPath } from './useSidebarData';
import {
getLocaleNav,
pickRouteSortMeta,
Expand Down Expand Up @@ -64,7 +65,10 @@ export const useNavData = () => {
.sort(([a], [b]) => a.split('/').length - b.split('/').length)
// convert sidebar data to nav data
.reduce<Record<string, INavItems[0]>>((ret, [link, groups]) => {
const [, parentPath, restPath] = link.match(/^(\/[^/]+)([^]+)?$/)!;
const [, parentPath, restPath] = `/${getLocaleClearPath(
link.replace(/^\//, ''),
locale,
)}`.match(/^(\/[^/]+)([^]+)?$/)!;
const isNestedNav = Boolean(restPath) && is2LevelNav;
const [firstMeta, secondMeta] = Object.values(routes).reduce<
{
Expand Down
5 changes: 4 additions & 1 deletion src/client/theme-api/useSidebarData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {

const DEFAULT_GROUP_STUB_TITLE = '$default-group-title';

const getLocaleClearPath = (routePath: string, locale: ILocalesConfig[0]) => {
export const getLocaleClearPath = (
routePath: string,
locale: ILocalesConfig[0],
) => {
return 'base' in locale
? routePath.replace(locale.base.slice(1), '').replace(/^\//, '')
: routePath;
Expand Down

0 comments on commit 9e65764

Please sign in to comment.