Skip to content

Commit 515c725

Browse files
committed
Website: add link to official doc on modules
1 parent 909e582 commit 515c725

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

‎website/scripts/Prerender.re‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ let file = (file: FsUtils.t, modulesIndex: array(string)) => {
5959
switch (Js.Dict.get(value, "title")) {
6060
| Some(v) =>
6161
switch (Js.Json.classify(v)) {
62-
| Js.Json.JSONString(v) => Some(v)
62+
| Js.Json.JSONString(v) => v
6363
| _ => failwith("Expected an string for the `title`")
6464
}
65-
| None => None // failwith("Expected an `title` property")
65+
| None => failwith("Expected an `title` property")
6666
};
6767
let wip =
6868
switch (Js.Dict.get(value, "wip")) {

‎website/src/SVGs/ExternalLink.svg‎

Lines changed: 1 addition & 0 deletions
Loading

‎website/src/components/PageContent.re‎

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ open ReactNative;
33

44
type pageData = {
55
id: string,
6-
title: option(string),
6+
title: string,
77
wip: option(bool),
88
body: string,
99
modulesIndex: array(string),
@@ -35,7 +35,18 @@ let styles =
3535
~borderRadius=4.,
3636
(),
3737
),
38-
"editLinkText": style(~color=color(Consts.Colors.accent), ()),
38+
"editLinkText":
39+
style(~color=color(Consts.Colors.accent), ~alignItems=`center, ()),
40+
"officialDocLink":
41+
style(
42+
~display=`flex,
43+
~flexDirection=`row,
44+
~fontSize=14.,
45+
~fontWeight=`_300,
46+
~alignItems=`center,
47+
~color=color(Consts.Colors.accent),
48+
(),
49+
),
3950
"wip":
4051
style(
4152
~borderWidth=1.,
@@ -56,15 +67,40 @@ let make = (~pageData) => {
5667
if (pageData.wip->Option.getWithDefault(false)) {
5768
Js.log3("@todo", pageData.title, "docs is still WIP");
5869
};
70+
let officialDocHref =
71+
if (pageData.id
72+
|> Js.String.startsWith("apis/")
73+
|| pageData.id
74+
|> Js.String.startsWith("components/")) {
75+
Some(
76+
"http://facebook.github.io/react-native/docs/"
77+
++ pageData.title->Js.String.toLocaleLowerCase
78+
++ "/",
79+
);
80+
} else {
81+
None;
82+
};
5983
let editHref =
6084
"https://github.com/reasonml-community/bs-react-native/blob/master/bs-react-native-next/src/"
6185
++ pageData.id
6286
++ ".md";
6387
<SpacedView style=styles##container vertical=SpacedView.L>
6488
<View style=styles##title>
65-
<Text style=styles##titleText>
66-
{pageData.title->Option.getWithDefault(pageData.id)->React.string}
67-
</Text>
89+
<View>
90+
<Text style=styles##titleText> pageData.title->React.string </Text>
91+
{officialDocHref
92+
->Option.map(officialDocHref =>
93+
<TextLink style=styles##officialDocLink href=officialDocHref>
94+
<SVGExternalLink
95+
width={14.->ReactFromSvg.Size.pt}
96+
height={14.->ReactFromSvg.Size.pt}
97+
fill=Consts.Colors.accent
98+
/>
99+
{| Official documentation |}->React.string
100+
</TextLink>
101+
)
102+
->Option.getWithDefault(React.null)}
103+
</View>
68104
<SpacedView
69105
vertical=SpacedView.XS horizontal=SpacedView.XS style=styles##editLink>
70106
<TextLink style=styles##editLinkText href=editHref>

0 commit comments

Comments
 (0)