Skip to content

Commit 5a5904f

Browse files
committed
api is rendering
1 parent c23be9b commit 5a5904f

22 files changed

+193
-36596
lines changed

app/routes.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ let $$default = Belt_Array.concatMany([
1818
Routes.route("docs/manual/api/stdlib", "./routes/ApiRoute.mjs", {
1919
id: "api-stdlib"
2020
}),
21+
Routes.route("docs/manual/api/stdlib/bigint", "./routes/ApiRoute.mjs", {
22+
id: "api-stdlib-bigint"
23+
}),
2124
Routes.route("docs/manual/api/introduction", "./routes/ApiRoute.mjs", {
2225
id: "api-intro"
2326
}),

app/routes.res

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ let default = [
1010
route("syntax-lookup", "./routes/SyntaxLookupRoute.mjs"),
1111
route("blog", "./routes/BlogRoute.mjs"),
1212
route("docs/manual/api/stdlib", "./routes/ApiRoute.mjs", ~options={id: "api-stdlib"}),
13+
route(
14+
"docs/manual/api/stdlib/bigint", // TODO RR7: generate routes for all api docs
15+
"./routes/ApiRoute.mjs",
16+
~options={id: "api-stdlib-bigint"},
17+
),
1318
route("docs/manual/api/introduction", "./routes/ApiRoute.mjs", ~options={id: "api-intro"}),
1419
route("docs/manual/api/belt", "./routes/ApiRoute.mjs", ~options={id: "api-belt"}),
1520
route("docs/manual/api/dom", "./routes/ApiRoute.mjs", ~options={id: "api-dom"}),

app/routes/ApiRoute.res

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
type loaderData = ApiDocs.props
2+
3+
let loader: ReactRouter.Loader.t<loaderData> = async args => {
4+
let pathname =
5+
WebAPI.URL.make(~url=args.request.url).pathname->String.replace("/docs/manual/api/", "")
6+
Console.log(pathname)
7+
8+
let data = {
9+
await ApiDocs.getStaticProps(["stdlib", "bigint"])
10+
}
11+
12+
data["props"]
13+
}
14+
115
let default = () => {
2-
<div />
16+
let loaderData: loaderData = ReactRouter.useLoaderData()
17+
<ApiDocs {...loaderData} />
318
}

app/routes/MdxRoute.res

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,6 @@ let reactTableOfContents = () => {
130130
categories
131131
}
132132

133-
let apiTableOfContents = () => {
134-
let groups =
135-
allMdx
136-
->filterMdxPages("docs/manual/api")
137-
->groupBySection
138-
->Dict.mapValues(values => values->sortSection->convertToNavItems("/docs/manual/api"))
139-
140-
// these are the categories that appear in the sidebar
141-
let categories: array<SidebarLayout.Sidebar.Category.t> = [
142-
{name: "Overview", items: groups->Dict.get("Overview")->Option.getOr([])},
143-
{
144-
name: "Additional Libraries",
145-
items: groups->Dict.get("Additional Libraries")->Option.getOr([]),
146-
},
147-
]
148-
categories
149-
}
150-
151133
let loader: Loader.t<loaderData> = async ({request}) => {
152134
let {pathname} = WebAPI.URL.make(~url=request.url)
153135

@@ -165,8 +147,8 @@ let loader: Loader.t<loaderData> = async ({request}) => {
165147
res
166148
} else {
167149
let categories = {
168-
if pathname->String.includes("docs/manual/api") {
169-
apiTableOfContents()
150+
if pathname == "/docs/manual/api" {
151+
[]
170152
} else if pathname->String.includes("docs/manual") {
171153
manualTableOfContents()
172154
} else if pathname->String.includes("docs/react") {
@@ -226,7 +208,9 @@ let default = () => {
226208
<>
227209
<title> {React.string(attributes.metaTitle->Option.getOr(attributes.title))} </title>
228210
<meta name="description" content={attributes.description->Option.getOr("")} />
229-
{if (
211+
{if (pathname :> string) == "/docs/manual/api" {
212+
<ApiOverviewLayout.Docs> {component()} </ApiOverviewLayout.Docs>
213+
} else if (
230214
(pathname :> string)->String.includes("docs/manual") ||
231215
(pathname :> string)->String.includes("docs/react")
232216
) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)