Skip to content

Commit b1c5bd8

Browse files
committed
Convet ReactDocsLayout to rescript syntax
1 parent 924acc3 commit b1c5bd8

File tree

2 files changed

+65
-69
lines changed

2 files changed

+65
-69
lines changed

layouts/ReactDocsLayout.re

Lines changed: 0 additions & 69 deletions
This file was deleted.

layouts/ReactDocsLayout.res

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module Link = Next.Link
2+
3+
module NavItem = SidebarLayout.Sidebar.NavItem
4+
module Category = SidebarLayout.Sidebar.Category
5+
module Toc = SidebarLayout.Toc
6+
7+
let overviewNavs = [{NavItem.name: "Introduction", href: "/docs/react/latest/introduction"}]
8+
9+
module CategoryDocsLayout = // Structure defined by `scripts/extract-tocs.js`
10+
DocsLayout.Make({
11+
/* let categories = [|Category.{name: "Overview", items: overviewNavs}|]; */
12+
let tocData: SidebarLayout.Toc.raw = %raw("require('../index_data/react_latest_toc.json')")
13+
})
14+
15+
@react.component
16+
let make = (~frontmatter: option<Js.Json.t>=?, ~components=Markdown.default, ~children) => {
17+
let router = Next.Router.useRouter()
18+
let route = router.route
19+
20+
let url = route->Url.parse
21+
22+
let version = switch url.version {
23+
| Version(version) => version
24+
| NoVersion => "latest"
25+
| Latest => "latest"
26+
}
27+
28+
let prefix = list{
29+
{
30+
open Url
31+
{name: "Docs", href: "/docs/latest"}
32+
},
33+
{
34+
open Url
35+
{
36+
name: "ReasonReact",
37+
href: "/docs/react/" ++ (version ++ "/introduction"),
38+
}
39+
},
40+
}
41+
42+
let breadcrumbs = Belt.List.concat(
43+
prefix,
44+
DocsLayout.makeBreadcrumbs(~basePath="/docs/gentype/" ++ version, route),
45+
)
46+
47+
let title = "ReasonReact"
48+
49+
let availableVersions = ["latest"]
50+
let latestVersionLabel = "v0.9"
51+
let version = "latest"
52+
53+
<CategoryDocsLayout
54+
theme=#Reason
55+
components
56+
metaTitleCategory="React"
57+
availableVersions
58+
latestVersionLabel
59+
version
60+
title
61+
breadcrumbs
62+
?frontmatter>
63+
children
64+
</CategoryDocsLayout>
65+
}

0 commit comments

Comments
 (0)