File tree Expand file tree Collapse file tree 6 files changed +15
-11
lines changed
docs/platforms/javascript/common Expand file tree Collapse file tree 6 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ sidebar_order: 2
99
1010## Available Options
1111
12- <SdkOptionsOverview />
12+ <TableOfContents ignoreIds = { [ ' available-options ' ] } />
1313
1414## Core Options
1515
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import Mermaid from '../mermaid';
1919import { PaginationNav } from '../paginationNav' ;
2020import { PlatformSdkDetail } from '../platformSdkDetail' ;
2121import { Sidebar } from '../sidebar' ;
22- import { TableOfContents } from '../tableOfContents ' ;
22+ import { SidebarTableOfContents } from '../sidebarTableOfContents ' ;
2323import { ReaderDepthTracker } from '../track-reader-depth' ;
2424
2525type Props = {
@@ -110,7 +110,7 @@ export function DocPage({
110110 { hasToc && (
111111 < aside className = "sticky h-[calc(100vh-var(--header-height))] top-[var(--header-height)] overflow-y-auto hidden xl:block w-[250px]" >
112112 < div className = "sidebar" >
113- < TableOfContents />
113+ < SidebarTableOfContents />
114114 < PlatformSdkDetail />
115115 </ div >
116116 </ aside >
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ function buildTocTree(toc: TocItem[]): TocItem[] {
7878// https://github.com/vercel/next.js/discussions/57631
7979//
8080// For now, calculate the table of contents on the client.
81- export function TableOfContents ( ) {
81+ export function SidebarTableOfContents ( ) {
8282 const [ tocItems , setTocItems ] = useState < TocItem [ ] > ( [ ] ) ;
8383
8484 // gather the toc items on mount
File renamed without changes.
Original file line number Diff line number Diff line change @@ -15,7 +15,11 @@ type TreeNode = {
1515 name : string ;
1616} ;
1717
18- export function SdkOptionsOverview ( ) {
18+ interface Props {
19+ ignoreIds ?: string [ ] ;
20+ }
21+
22+ export function TableOfContents ( { ignoreIds = [ ] } : Props ) {
1923 const [ treeItems , setTreeItems ] = useState < TreeItem [ ] > ( [ ] ) ;
2024
2125 // gather the sdk option items on mount
@@ -25,13 +29,13 @@ export function SdkOptionsOverview() {
2529 }
2630 const main = document . getElementById ( 'main' ) ;
2731 if ( ! main ) {
28- throw new Error ( '#main element not found' ) ;
32+ return ;
2933 }
3034 const nodes = Array . from ( main . querySelectorAll ( 'h2, h3' ) )
3135 . map ( el => {
3236 const name = el . textContent ?. trim ( ) ?? '' ;
3337 const id = el . id ;
34- if ( ! id || ! name ) {
38+ if ( ! id || ! name || ignoreIds . includes ( id ) ) {
3539 return null ;
3640 }
3741 return {
@@ -56,7 +60,7 @@ export function SdkOptionsOverview() {
5660 children : [ ] ,
5761 } ;
5862 _tocItems . push ( currentItem ) ;
59- } else if ( node . element . hasAttribute ( 'data-sdk-option' ) ) {
63+ } else {
6064 currentItem . children . push ( {
6165 id : node . id ,
6266 name : node . name ,
@@ -67,7 +71,7 @@ export function SdkOptionsOverview() {
6771
6872 // Remove groups without children
6973 setTreeItems ( _tocItems . filter ( item => item . children . length > 0 ) ) ;
70- } , [ ] ) ;
74+ } , [ ignoreIds ] ) ;
7175
7276 return (
7377 < ul >
Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ import {PlatformSection} from './components/platformSection';
3232import { RelayMetrics } from './components/relayMetrics' ;
3333import { SandboxLink } from './components/sandboxLink' ;
3434import { SdkOption } from './components/sdkOption' ;
35- import { SdkOptionsOverview } from './components/sdkOptionOverview' ;
3635import { SignInNote } from './components/signInNote' ;
3736import { SmartLink } from './components/smartLink' ;
37+ import { TableOfContents } from './components/tableOfContents' ;
3838import { VimeoEmbed } from './components/video' ;
3939
4040export function mdxComponents (
@@ -52,7 +52,7 @@ export function mdxComponents(
5252 CodeTabs,
5353 ConfigKey,
5454 SdkOption,
55- SdkOptionsOverview ,
55+ TableOfContents ,
5656 CreateGitHubAppForm,
5757 ConfigValue,
5858 DefinitionList,
You can’t perform that action at this time.
0 commit comments