Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
refactor: search context
Browse files Browse the repository at this point in the history
  • Loading branch information
eyworldwide committed Mar 22, 2024
1 parent 414a8d7 commit e6ebdfb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/header/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useIntl } from 'react-intl';
import { AppContext } from '../../contextProvider';
import { APISearchResponse, searchAPI, searchDoc } from '../headerUtils';
import DocSearchRes from './SearchResult';
import { useLocation } from 'react-router-dom';

interface ISearchResProps {
searchText: string;
Expand Down Expand Up @@ -33,8 +34,18 @@ const SearchResult = (props: ISearchResProps) => {

const PAGE_SIZE = '20';

const {pathname} = useLocation();
let searchContext = 'docs';

if (pathname.indexOf('/api/') > -1) {
searchContext = 'api';
}
else if (pathname.indexOf('/examples/') > -1) {
searchContext = 'examples';
}

const searchResultTab = (
<Tabs defaultValue='docs' closable>
<Tabs defaultValue={searchContext} closable>
<StyledTabList
tabs={[
{
Expand Down

0 comments on commit e6ebdfb

Please sign in to comment.