Skip to content

Commit dafb8df

Browse files
committed
chore: update
1 parent 19ab890 commit dafb8df

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

packages/theme-default/src/components/Search/SearchPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
88
import { createPortal } from 'react-dom';
99
import * as userSearchHooks from 'virtual-search-hooks';
1010
import { useLocaleSiteData } from '../../logic/useLocaleSiteData';
11-
import { getSidebarGroupData } from '../../logic/useSidebarData';
11+
import { getSidebarData } from '../../logic/useSidebarData';
1212
import { SvgWrapper } from '../SvgWrapper';
1313
import { Tab, Tabs } from '../Tabs';
1414
import { NoSearchResult } from './NoSearchResult';
@@ -123,7 +123,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
123123

124124
// We need to extract the group name by the link so that we can divide the search result into different groups.
125125
const extractGroupName = (link: string) =>
126-
getSidebarGroupData(sidebar, link).group;
126+
getSidebarData(sidebar, link).group;
127127

128128
async function initPageSearcher() {
129129
if (search === false) {

packages/theme-default/src/logic/useFullTextSearch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react';
33
import type { MatchResult } from '..';
44
import { PageSearcher } from '../components/Search/logic/search';
55
import { useLocaleSiteData } from './useLocaleSiteData';
6-
import { getSidebarGroupData } from './useSidebarData';
6+
import { getSidebarData } from './useSidebarData';
77

88
export function useFullTextSearch(): {
99
initialized: boolean;
@@ -13,7 +13,7 @@ export function useFullTextSearch(): {
1313
const [initialized, setInitialized] = useState(false);
1414
const { sidebar } = useLocaleSiteData();
1515
const extractGroupName = (link: string) =>
16-
getSidebarGroupData(sidebar, link).group;
16+
getSidebarData(sidebar, link).group;
1717
const searchRef = useRef<PageSearcher | null>(null);
1818

1919
useEffect(() => {

packages/theme-default/src/logic/useSidebarData.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,12 @@ const match = (
7777
return undefined;
7878
};
7979

80-
export const getSidebarGroupData = (
80+
export const getSidebarData = (
8181
sidebar: NormalizedSidebar,
8282
currentPathname: string,
83-
) => {
84-
console.log(sidebar, 111111);
83+
): SidebarData => {
8584
for (const name of Object.keys(sidebar)) {
86-
const isMatch = matchPath(name, currentPathname);
87-
console.log(isMatch, name, currentPathname);
88-
if (isMatch) {
85+
if (matchPath(name, currentPathname)) {
8986
const sidebarGroup = sidebar[name];
9087
const group = sidebarGroup.find(item => match(item, currentPathname));
9188
return {
@@ -105,7 +102,7 @@ export function useSidebarData(): SidebarData {
105102
const pathname = decodeURIComponent(rawPathname);
106103

107104
const sidebarData = useMemo(() => {
108-
return getSidebarGroupData(sidebar, pathname);
105+
return getSidebarData(sidebar, pathname);
109106
}, [sidebar, pathname]);
110107

111108
return sidebarData;

0 commit comments

Comments
 (0)