File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 11import React from 'react'
22
33import Head from '@docusaurus/Head'
4+ import Link from '@docusaurus/Link'
45import Layout from '@theme/Layout'
56
7+ import sidebars from '../../sidebars'
8+
69export default function Home ( ) {
10+ console . log ( 'main sidebar' , sidebars . main )
11+
712 return (
813 < Layout
914 description = {
@@ -95,8 +100,32 @@ export default function Home() {
95100
96101 < h1 > Documentation</ h1 >
97102
98- < a href = "https://cedarjs.com/docs" > https://cedarjs.com/docs</ a >
103+ < ul >
104+ { sidebars . main . map ( ( section : string | Record < string , any > ) => {
105+ const linkText =
106+ typeof section === 'string' ? toTitleCase ( section ) : section . label
107+ const linkTarget =
108+ typeof section === 'string'
109+ ? section
110+ : section . link ?. slug ?. replace ( / ^ \/ / , '' ) ||
111+ section . items ?. at ( 0 ) ?. id
112+
113+ return (
114+ < li key = { linkTarget } >
115+ < Link to = { 'docs/' + linkTarget } > { linkText } </ Link >
116+ </ li >
117+ )
118+ } ) }
119+ </ ul >
99120 </ div >
100121 </ Layout >
101122 )
102123}
124+
125+ function toTitleCase ( str : string ) {
126+ return str
127+ . replaceAll ( '-' , ' ' )
128+ . split ( ' ' )
129+ . map ( ( w ) => w [ 0 ] . toUpperCase ( ) + w . substring ( 1 ) )
130+ . join ( ' ' )
131+ }
You can’t perform that action at this time.
0 commit comments