Skip to content

Commit 147a82a

Browse files
authored
[refactor]: unify api docs layout (#1062)
* [refactor]: unify api docs layout * version as string * reduce diff * remove versionStr
1 parent f866597 commit 147a82a

26 files changed

+424
-1605
lines changed

src/common/App.res

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,36 +64,8 @@ let make = (props: props): React.element => {
6464
| (1, _) => <ApiOverviewLayout.Docs version> content </ApiOverviewLayout.Docs>
6565
| _ => content
6666
}
67-
| "v8.0.0" =>
68-
switch (Array.length(pagepath), pagepath[1]) {
69-
| (1, _) => <ApiOverviewLayout8_0_0.Docs> content </ApiOverviewLayout8_0_0.Docs>
70-
| (2, Some("js")) => <JsDocsLayout8_0_0.Prose> content </JsDocsLayout8_0_0.Prose>
71-
| (2, Some("belt")) => <BeltDocsLayout8_0_0.Prose> content </BeltDocsLayout8_0_0.Prose>
72-
| (_, Some("js")) => <JsDocsLayout8_0_0.Docs> content </JsDocsLayout8_0_0.Docs>
73-
| (_, Some("belt")) => <BeltDocsLayout8_0_0.Docs> content </BeltDocsLayout8_0_0.Docs>
74-
| (_, Some("dom")) => <DomDocsLayout8_0_0.Docs> content </DomDocsLayout8_0_0.Docs>
75-
| _ => React.null
76-
}
77-
| "v9.0.0" =>
78-
switch (Array.length(pagepath), pagepath[1]) {
79-
| (1, _) => <ApiOverviewLayout9_0_0.Docs> content </ApiOverviewLayout9_0_0.Docs>
80-
| (2, Some("js")) => <JsDocsLayout9_0_0.Prose> content </JsDocsLayout9_0_0.Prose>
81-
| (2, Some("belt")) => <BeltDocsLayout9_0_0.Prose> content </BeltDocsLayout9_0_0.Prose>
82-
| (_, Some("js")) => <JsDocsLayout9_0_0.Docs> content </JsDocsLayout9_0_0.Docs>
83-
| (_, Some("belt")) => <BeltDocsLayout9_0_0.Docs> content </BeltDocsLayout9_0_0.Docs>
84-
| (_, Some("dom")) => <DomDocsLayout9_0_0.Docs> content </DomDocsLayout9_0_0.Docs>
85-
| _ => React.null
86-
}
87-
| "v10.0.0" =>
88-
switch (Array.length(pagepath), pagepath[1]) {
89-
| (1, _) => <ApiOverviewLayout10_0_0.Docs> content </ApiOverviewLayout10_0_0.Docs>
90-
| (2, Some("js")) => <JsDocsLayout10_0_0.Prose> content </JsDocsLayout10_0_0.Prose>
91-
| (2, Some("belt")) => <BeltDocsLayout10_0_0.Prose> content </BeltDocsLayout10_0_0.Prose>
92-
| (_, Some("js")) => <JsDocsLayout10_0_0.Docs> content </JsDocsLayout10_0_0.Docs>
93-
| (_, Some("belt")) => <BeltDocsLayout10_0_0.Docs> content </BeltDocsLayout10_0_0.Docs>
94-
| (_, Some("dom")) => <DomDocsLayout10_0_0.Docs> content </DomDocsLayout10_0_0.Docs>
95-
| _ => React.null
96-
}
67+
| ("v8.0.0" | "v9.0.0" | "v10.0.0") as version =>
68+
<ApiOverviewLayoutLegacy version> content </ApiOverviewLayoutLegacy>
9769
| _ => content
9870
}
9971
| _ =>

src/layouts/ApiOverviewLayout.res

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ let makeCategories: string => array<Sidebar.Category.t> = version => [
2525
module Docs = {
2626
@react.component
2727
let make = (~version, ~components=ApiMarkdown.default, ~children) => {
28+
let router = Next.Router.useRouter()
29+
let route = router.route
30+
2831
let categories = makeCategories(version)
2932

30-
<ApiLayout categories version components> children </ApiLayout>
33+
<ApiLayout categories version components>
34+
{switch version {
35+
| "v9.0.0" | "v8.0.0" => <ApiLayout.OldDocsWarning route version />
36+
| _ => React.null
37+
}}
38+
children
39+
</ApiLayout>
3140
}
3241
}

src/layouts/ApiOverviewLayout10_0_0.res

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

src/layouts/ApiOverviewLayout10_0_0.resi

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

src/layouts/ApiOverviewLayout8_0_0.res

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

src/layouts/ApiOverviewLayout8_0_0.resi

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

src/layouts/ApiOverviewLayout9_0_0.res

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

src/layouts/ApiOverviewLayout9_0_0.resi

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

0 commit comments

Comments
 (0)