This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
src/features/Apiexplorer/Schema/HighlightCode Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import clsx from 'clsx' ;
3
- import styles from './HighlightCode.module.scss ' ;
3
+ import { useHistory , useLocation } from '@docusaurus/router ' ;
4
4
import { playground_requests } from '@site/src/utils/playground_requests' ;
5
5
import { SchemaDescriptionTypes } from '../RecursiveContent/SchemaDescription' ;
6
- import { useHistory , useLocation } from '@docusaurus/router ' ;
6
+ import styles from './HighlightCode.module.scss ' ;
7
7
8
8
export const HighlightCode = ( { description } : SchemaDescriptionTypes ) => {
9
9
const { pathname } = useLocation ( ) ;
@@ -13,19 +13,19 @@ export const HighlightCode = ({ description }: SchemaDescriptionTypes) => {
13
13
14
14
const [ first , code , ...rest ] = description . split ( '`' ) ;
15
15
16
- const api_call_object = playground_requests . find ( ( el ) => el . name === code ) ;
17
- const link_api_call = ( obj ) => {
16
+ const has_api_call = playground_requests . some ( ( el ) => el . name === code ) ;
17
+ const link_api_call = ( api_call_name ) => {
18
18
window . scrollTo ( 0 , 0 ) ;
19
- history . push ( `${ pathname } #${ obj ?. name } ` ) ;
19
+ history . push ( `${ pathname } #${ api_call_name } ` ) ;
20
20
} ;
21
21
22
22
return (
23
23
< React . Fragment >
24
24
{ first }
25
25
{ code && (
26
26
< span className = { clsx ( styles . schemaRole , styles . schemaCode ) } >
27
- { api_call_object ? (
28
- < button onClick = { ( ) => link_api_call ( api_call_object ) } className = { styles . schemaLink } >
27
+ { has_api_call ? (
28
+ < button onClick = { ( ) => link_api_call ( code ) } className = { styles . schemaLink } >
29
29
{ code }
30
30
</ button >
31
31
) : (
You can’t perform that action at this time.
0 commit comments