@@ -9,68 +9,12 @@ type loaderData = {
99 filePath : option <string >,
1010}
1111
12- let convertToNavItems = (items , rootPath ) =>
13- Array .map (items , (item ): SidebarLayout .Sidebar .NavItem .t => {
14- let href = switch item .slug {
15- | Some (slug ) => ` ${rootPath}/${slug}`
16- | None => rootPath
17- }
18- {
19- name : item .title ,
20- href ,
21- }
22- })
23-
24- let getGroup = (groups , groupName ): SidebarLayout .Sidebar .Category .t => {
25- {
26- name : groupName ,
27- items : groups
28- -> Dict .get (groupName )
29- -> Option .getOr ([]),
30- }
31- }
32-
33- let getAllGroups = (groups , groupNames ): array <SidebarLayout .Sidebar .Category .t > =>
34- groupNames -> Array .map (item => getGroup (groups , item ))
35-
36- // These are the pages for the language manual, sorted by their "order" field in the frontmatter
37- let manualTableOfContents = async () => {
38- let groups =
39- (await allMdx (~filterByPaths = ["markdown-pages/docs" ]))
40- -> filterMdxPages ("docs/manual" )
41- -> groupBySection
42- -> Dict .mapValues (values => values -> sortSection -> convertToNavItems ("/docs/manual" ))
43-
44- // these are the categories that appear in the sidebar
45- let categories : array <SidebarLayout .Sidebar .Category .t > = getAllGroups (
46- groups ,
47- [
48- "Overview" ,
49- "Guides" ,
50- "Language Features" ,
51- "JavaScript Interop" ,
52- "Build System" ,
53- "Advanced Features" ,
54- ],
55- )
56-
57- categories
58- }
59-
6012let loader : ReactRouter .Loader .t <loaderData > = async ({request }) => {
6113 let {pathname } = WebAPI .URL .make (~url = request .url )
6214
6315 let mdx = await loadMdx (request , ~options = {remarkPlugins : Mdx .plugins })
6416
65- let categories = {
66- if pathname == "/docs/manual/api" {
67- []
68- } else if pathname -> String .includes ("docs/manual" ) {
69- await manualTableOfContents ()
70- } else {
71- []
72- }
73- }
17+ let categories = []
7418
7519 let filePath = ref (None )
7620
@@ -126,22 +70,14 @@ let loader: ReactRouter.Loader.t<loaderData> = async ({request}) => {
12670
12771 let metaTitleCategory = {
12872 let path = (pathname :> string )
129- let title = if path -> String .includes ("docs/manual/api" ) {
130- "ReScript API"
131- } else if path -> String .includes ("docs/manual" ) {
73+ if path -> String .includes ("docs/manual" ) {
13274 "ReScript Language Manual"
13375 } else {
13476 "ReScript"
13577 }
136-
137- title
13878 }
13979
140- let title = if pathname == "/docs/manual/api" {
141- "API"
142- } else {
143- mdx .attributes .title
144- }
80+ let title = mdx .attributes .title
14581
14682 let res : loaderData = {
14783 __raw : mdx .__raw ,
@@ -165,49 +101,7 @@ let default = () => {
165101 let {entries , categories , title } = loaderData
166102
167103 <>
168- {if (pathname :> string ) == "/docs/manual/api" {
169- let breadcrumbs = list {
170- {Url .name : "Docs" , href : ` /docs/manual/api` },
171- {name : "API" , href : ` /docs/manual/api` },
172- }
173- let sidebarContent =
174- <aside className = "px-4 w-full block" >
175- <div className = "flex justify-between items-baseline" >
176- <div className = "flex flex-col text-fire font-medium" >
177- <VersionSelect />
178- </div >
179- <button
180- className = "flex items-center" onClick = {_ => NavbarUtils .closeMobileTertiaryDrawer ()}
181- >
182- <Icon .Close />
183- </button >
184- </div >
185- <div className = "mb-56" >
186- {ApiOverviewLayout .categories
187- -> Array .map (category => {
188- let isItemActive = (navItem : SidebarLayout .Sidebar .NavItem .t ) =>
189- navItem .href === (pathname :> string )
190- <div key = category .name >
191- <SidebarLayout .Sidebar .Category
192- isItemActive category onClick = {_ => NavbarUtils .closeMobileTertiaryDrawer ()}
193- />
194- </div >
195- })
196- -> React .array }
197- </div >
198- </aside >
199-
200- <>
201- <Meta title = title description = {attributes .description -> Nullable .getOr ("ReScript API" )} />
202- <NavbarSecondary />
203- <NavbarTertiary sidebar = sidebarContent >
204- <SidebarLayout .BreadCrumbs crumbs = breadcrumbs />
205- </NavbarTertiary >
206- <ApiOverviewLayout .Docs >
207- <div className = "markdown-body" > {component ()} </div >
208- </ApiOverviewLayout .Docs >
209- </>
210- } else if (
104+ {if (
211105 (pathname :> string )-> String .includes ("docs/manual" ) ||
212106 (pathname :> string )-> String .includes ("docs/react" )
213107 ) {
0 commit comments