@@ -46,9 +46,13 @@ let components = {
4646
4747let convertToNavItems = (items , rootPath ) =>
4848 Array .map (items , (item ): SidebarLayout .Sidebar .NavItem .t => {
49+ let href = switch item .slug {
50+ | Some (slug ) => ` ${rootPath}/${slug}`
51+ | None => rootPath
52+ }
4953 {
5054 name : item .title ,
51- href : ` ${rootPath}/${item.slug}` ,
55+ href ,
5256 }
5357 })
5458
@@ -64,14 +68,14 @@ let getGroup = (groups, groupName): SidebarLayout.Sidebar.Category.t => {
6468let getAllGroups = (groups , groupNames ): array <SidebarLayout .Sidebar .Category .t > =>
6569 groupNames -> Array .map (item => getGroup (groups , item ))
6670
67- let blogPosts = () => {
68- allMdx -> filterMdxPages ("blog" )
71+ let blogPosts = async () => {
72+ ( await allMdx ()) -> filterMdxPages ("blog" )
6973}
7074
7175// These are the pages for the language manual, sorted by their "order" field in the frontmatter
72- let manualTableOfContents = () => {
76+ let manualTableOfContents = async () => {
7377 let groups =
74- allMdx
78+ ( await allMdx ())
7579 -> filterMdxPages ("docs/manual" )
7680 -> groupBySection
7781 -> Dict .mapValues (values => values -> sortSection -> convertToNavItems ("/docs/manual" ))
@@ -92,9 +96,9 @@ let manualTableOfContents = () => {
9296 categories
9397}
9498
95- let reactTableOfContents = () => {
99+ let reactTableOfContents = async () => {
96100 let groups =
97- allMdx
101+ ( await allMdx ())
98102 -> filterMdxPages ("docs/react" )
99103 -> groupBySection
100104 -> Dict .mapValues (values => values -> sortSection -> convertToNavItems ("/docs/react" ))
@@ -108,8 +112,6 @@ let reactTableOfContents = () => {
108112 categories
109113}
110114
111- let posts = () => allMdx -> filterMdxPages ("blog" )-> Array .map (BlogLoader .transform )
112-
113115let loader : Loader .t <loaderData > = async ({request }) => {
114116 let {pathname } = WebAPI .URL .make (~url = request .url )
115117
@@ -133,17 +135,17 @@ let loader: Loader.t<loaderData> = async ({request}) => {
133135 if pathname == "/docs/manual/api" {
134136 []
135137 } else if pathname -> String .includes ("docs/manual" ) {
136- manualTableOfContents ()
138+ await manualTableOfContents ()
137139 } else if pathname -> String .includes ("docs/react" ) {
138- reactTableOfContents ()
140+ await reactTableOfContents ()
139141 } else {
140142 []
141143 }
142144 }
143145
144146 // TODO: this can be optionally called if we need markdown
145147 // TODO: extract this out into a separate function
146- let fileContents = await allMdx
148+ let fileContents = await ( await allMdx ())
147149 -> Array .filter (mdx => (mdx .path :> string )-> String .includes (pathname ))
148150 -> Array .get (0 )
149151 -> Option .map (mdx => mdx .path )
@@ -205,10 +207,9 @@ let default = () => {
205207 </DocsLayout >
206208 } else {
207209 switch loaderData .blogPost {
208- | Some ({frontmatter , archived , path }) => {
209- Console .log (frontmatter )
210- <BlogArticle frontmatter isArchived = archived path > {component ()} </BlogArticle >
211- }
210+ | Some ({frontmatter , archived , path }) => <BlogArticle frontmatter isArchived = archived path >
211+ {component ()}
212+ </BlogArticle >
212213 | None => React .null // TODO: RR7 show an error
213214 }
214215 }}
0 commit comments