@@ -100,6 +100,25 @@ let manualTableOfContents = () => {
100100 categories
101101}
102102
103+ let reactTableOfContents = () => {
104+ let groups =
105+ allMdx
106+ -> filterMdxPages ("docs/react" )
107+ -> groupBySection
108+ -> Dict .mapValues (values => values -> sortSection -> convertToNavItems )
109+
110+ // Console.log(groups)
111+
112+ // these are the categories that appear in the sidebar
113+ let categories : array <SidebarLayout .Sidebar .Category .t > = [
114+ {name : "Overview" , items : groups -> Dict .getUnsafe ("Overview" )},
115+ ]
116+
117+ Console .log (categories )
118+
119+ categories
120+ }
121+
103122let apiTableOfContents = () => {
104123 let groups =
105124 allMdx
@@ -139,10 +158,13 @@ let loader: Loader.t<loaderData> = async ({request}) => {
139158 let categories = {
140159 if pathname -> String .includes ("docs/manual/api" ) {
141160 Console .log (apiTableOfContents ())
142- []
161+ apiTableOfContents ()
143162 } else if pathname -> String .includes ("docs/manual" ) {
144163 manualTableOfContents ()
164+ } else if pathname -> String .includes ("docs/react" ) {
165+ reactTableOfContents ()
145166 } else {
167+ // TODO RR7 add react docs
146168 []
147169 }
148170 }
@@ -194,18 +216,21 @@ let default = () => {
194216 (pathname :> string )-> String .includes ("docs/manual" )
195217 ? "ReScript Language Manual"
196218 : "Some other page"
197-
198- if (
199- (pathname :> string )-> String .includes ("docs/manual" ) ||
200- (pathname :> string )-> String .includes ("docs/react" )
201- ) {
202- <DocsLayout metaTitleCategory categories activeToc = {title : "Introduction" , entries }>
203- <div className = "markdown-body" > {component ()} </div >
204- </DocsLayout >
205- } else {
206- // TODO Handle blog pages
207- React .null
208- }
219+ <>
220+ <title > {React .string (attributes .metaTitle -> Option .getOr (attributes .title ))} </title >
221+ <meta name = "description" content = {attributes .description -> Option .getOr ("" )} />
222+ {if (
223+ (pathname :> string )-> String .includes ("docs/manual" ) ||
224+ (pathname :> string )-> String .includes ("docs/react" )
225+ ) {
226+ <DocsLayout metaTitleCategory categories activeToc = {title : "Introduction" , entries }>
227+ <div className = "markdown-body" > {component ()} </div >
228+ </DocsLayout >
229+ } else {
230+ // TODO Handle blog pages
231+ React .null
232+ }}
233+ </>
209234
210235 // </ManualDocsLayout.V1200Layout>
211236}
0 commit comments