1- /* eslint-disable react/no-danger */
21import React , { useState } from 'react' ;
32import { Link } from 'gatsby' ;
43import { useApiData , useReleaseHistory } from '../hooks' ;
5- import {
6- ApiDocsObj ,
7- APIResponse ,
8- } from '../hooks/useApiDocs' ;
4+ import { ApiDocsObj , APIResponse } from '../hooks/useApiDocs' ;
95
106import downloadUrlByOs from '../util/downloadUrlByOS' ;
117import { detectOS , UserOS } from '../util/detectOS' ;
@@ -24,7 +20,7 @@ function capitalizeFirstLetter(text: string) {
2420 return text . charAt ( 0 ) . toUpperCase ( ) + text . slice ( 1 ) ;
2521}
2622
27- function getHeadingForPage ( page : ApiDocsObj , depth : number = 0 ) {
23+ function getHeadingForPage ( page : ApiDocsObj , depth = 0 ) {
2824 const HeaderName = `h${ Math . min ( depth + 2 , 6 ) } ` ;
2925 return React . createElement (
3026 HeaderName ,
@@ -89,11 +85,11 @@ function renderArticleSections(
8985 sections : JSX . Element [ ] = [ ] ,
9086 depth = 0
9187) : JSX . Element [ ] {
92- for ( const page of pages ) {
88+ pages . forEach ( page => {
9389 const children : JSX . Element [ ] = [ ] ;
9490
95- const prepareArticleSectionsForPage = ( page : ApiDocsObj , depth : number ) => {
96- API_DOCS_OBJ_KEYS . map ( ( key : string ) => {
91+ const prepareArticleSections : Function = ( ) => {
92+ API_DOCS_OBJ_KEYS . forEach ( ( key : string ) => {
9793 if ( page [ key ] ) {
9894 renderArticleSections ( page [ key ] , children , depth + 1 ) ;
9995 }
@@ -108,10 +104,10 @@ function renderArticleSections(
108104
109105 children . push ( getListItemForPage ( page ) ) ;
110106
111- prepareArticleSectionsForPage ( page , depth ) ;
107+ prepareArticleSections ( ) ;
112108
113109 sections . push ( < section className = "api-docs__section" > { children } </ section > ) ;
114- }
110+ } ) ;
115111
116112 return sections ;
117113}
0 commit comments