Skip to content

Commit 910c708

Browse files
authored
Scal 237361 (#263)
* SCAL-237361 : fixed tutorial links * SCAL-237361 : update search component
1 parent db12b6a commit 910c708

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

gatsby-config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ module.exports = {
190190
apiKey: process.env.ALGOLIA_ADMIN_KEY,
191191
queries: require(`${__dirname}/src/utils/algolia-queries`)
192192
.queries,
193+
// for testing add dryRun as true,
194+
// dryRun: true,
193195
},
194196
},
195197
{

src/components/DevDocTemplate/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,18 @@ const DevDocTemplate: FC<DevDocTemplateProps> = (props) => {
251251
}
252252
}, [keyword]);
253253

254-
const optionSelected = (pageid: string, sectionId: string) => {
254+
const optionSelected = (link: string, sectionId: string) => {
255255
updateKeyword('');
256-
if (sectionId) navigate(`/${pageid}#${sectionId}`);
257-
else navigate(`/${pageid}`);
256+
257+
let linkToNavigate = `${link}`;
258+
259+
if (linkToNavigate.startsWith('/docs')) {
260+
linkToNavigate = linkToNavigate.replace('/docs', '');
261+
}
262+
if (sectionId) {
263+
linkToNavigate = `${linkToNavigate}#${sectionId}`;
264+
}
265+
navigate(linkToNavigate);
258266
};
259267

260268
const isMaxMobileResolution = !(width < MAX_MOBILE_RESOLUTION);

src/components/Search/index.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ type SearchProps = {
2121
keyword: string;
2222
isMaxMobileResolution: boolean;
2323
isDarkMode: boolean;
24-
optionSelected: (pageid: string, sectionId: string) => void;
24+
optionSelected: (link: string, sectionId: string) => void;
2525
onChange: (e: React.FormEvent<HTMLInputElement>) => void;
2626
updateKeyword: Function;
2727
setDarkMode: Function;
2828
isPublicSiteOpen: boolean;
29-
leftNavWidth: Number;
29+
leftNavWidth: number;
3030
};
3131

3232
const Search: React.FC<SearchProps> = (props) => {
@@ -93,7 +93,7 @@ const Search: React.FC<SearchProps> = (props) => {
9393
}
9494
} else {
9595
props.optionSelected(
96-
props.options[highlightedIndex].pageid,
96+
props.options[highlightedIndex].link,
9797
props.options[highlightedIndex].sectionId,
9898
);
9999
}
@@ -158,10 +158,7 @@ const Search: React.FC<SearchProps> = (props) => {
158158
key={option.pageid}
159159
className="result"
160160
onClick={() => {
161-
props.optionSelected(
162-
option.pageid,
163-
option.sectionId,
164-
);
161+
props.optionSelected(option.link, option.sectionId);
165162
onSearchOptionSelected();
166163
}}
167164
ref={(el: HTMLDivElement) => {
@@ -193,7 +190,7 @@ const Search: React.FC<SearchProps> = (props) => {
193190
<div className="searchInputContainer">
194191
<IconContext.Provider
195192
value={{
196-
className: `icon searchIcon`,
193+
className: 'icon searchIcon',
197194
}}
198195
>
199196
<BiSearch />
@@ -231,14 +228,14 @@ const Search: React.FC<SearchProps> = (props) => {
231228
<span className="search-hint-icon">
232229
<IconContext.Provider
233230
value={{
234-
className: `icon searchIcon`,
231+
className: 'icon searchIcon',
235232
}}
236233
>
237234
<BiUpArrowAlt />
238235
</IconContext.Provider>
239236
<IconContext.Provider
240237
value={{
241-
className: `icon searchIcon`,
238+
className: 'icon searchIcon',
242239
}}
243240
>
244241
<BiDownArrowAlt />

0 commit comments

Comments
 (0)