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 11import React from 'react' ;
22import clsx from 'clsx' ;
3- import styles from './HighlightCode.module.scss ' ;
3+ import { useHistory , useLocation } from '@docusaurus/router ' ;
44import { playground_requests } from '@site/src/utils/playground_requests' ;
55import { SchemaDescriptionTypes } from '../RecursiveContent/SchemaDescription' ;
6- import { useHistory , useLocation } from '@docusaurus/router ' ;
6+ import styles from './HighlightCode.module.scss ' ;
77
88export const HighlightCode = ( { description } : SchemaDescriptionTypes ) => {
99 const { pathname } = useLocation ( ) ;
@@ -13,19 +13,19 @@ export const HighlightCode = ({ description }: SchemaDescriptionTypes) => {
1313
1414 const [ first , code , ...rest ] = description . split ( '`' ) ;
1515
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 ) => {
1818 window . scrollTo ( 0 , 0 ) ;
19- history . push ( `${ pathname } #${ obj ?. name } ` ) ;
19+ history . push ( `${ pathname } #${ api_call_name } ` ) ;
2020 } ;
2121
2222 return (
2323 < React . Fragment >
2424 { first }
2525 { code && (
2626 < 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 } >
2929 { code }
3030 </ button >
3131 ) : (
You can’t perform that action at this time.
0 commit comments