File tree Expand file tree Collapse file tree 3 files changed +35
-8
lines changed
Expand file tree Collapse file tree 3 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ Path.join([|sourcePath, "**/*.md"|])
2323 |> Js . String . replace(".md" , "" );
2424 let mdJson = mdToJson(file. content);
2525 let content =
26- {"id" : mdJson## id, "title" : mdJson## title, "body" : mdJson## body}
26+ {
27+ "filename" : file. name |> Js . String . replace(root, "website" ),
28+ "id" : mdJson## id,
29+ "title" : mdJson## title,
30+ "body" : mdJson## body,
31+ }
2732 -> Js . Json . stringifyAny;
2833 if (content-> Option . isNone) {
2934 Js . log2(file. name, "can't be transformed" );
@@ -74,6 +79,12 @@ Path.join([|sourcePath, "**/*.md"|])
7479 let mdJson = mdToJson(file. content);
7580 let content =
7681 {
82+ "filename" :
83+ file. name
84+ |> Js . String . replace(
85+ Node . Path . resolve(root, ".." ) ++ "/" ,
86+ "" ,
87+ ),
7788 "id" : mdJson## id,
7889 "title" : mdJson## title,
7990 "wip" : mdJson## wip,
@@ -139,6 +150,7 @@ Path.join([|sourcePath, "**/*.md"|])
139150 let mdJson = mdToJson(file. content);
140151 let content =
141152 {
153+ "filename" : file. name |> Js . String . replace(root, "website" ),
142154 "id" : mdJson## id,
143155 "title" : mdJson## title,
144156 "author" : mdJson## author,
Original file line number Diff line number Diff line change @@ -70,6 +70,15 @@ let file =
7070 let pageData =
7171 switch (Js . Json . classify(json)) {
7272 | Js . Json . JSONObject (value ) =>
73+ let filename =
74+ switch (Js . Dict . get(value, "filename" )) {
75+ | Some (v ) =>
76+ switch (Js . Json . classify(v)) {
77+ | Js . Json . JSONString (v ) => v
78+ | _ => failwith (file. name ++ ": Expected an string for `filename`" )
79+ }
80+ | None => failwith (file. name ++ ": Expected an `filename` property" )
81+ };
7382 let id =
7483 switch (Js . Dict . get(value, "id" )) {
7584 | Some (v ) =>
@@ -149,6 +158,7 @@ let file =
149158 | None => failwith (file. name ++ ": Expected an `body` property" )
150159 };
151160 let p : PageContent . pageData = {
161+ filename,
152162 id,
153163 title,
154164 date,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ open ReactMultiversal;
44
55// ⚠️ if you update this, also update PrepareMdToJson if needed
66type pageData = {
7+ filename: string ,
78 id: string ,
89 title: string ,
910 date: option (string ),
@@ -31,12 +32,17 @@ let styles =
3132 ~marginLeft= auto,
3233 ~borderWidth= 1 .,
3334 ~borderStyle= ` solid ,
34- ~borderColor= Predefined . Colors . tealBlue ,
35+ ~borderColor= Predefined . Colors . grey ,
3536 ~borderRadius= 4 .,
3637 () ,
3738 ),
3839 "editLinkText" :
39- style(~color= Predefined . Colors . tealBlue, ~alignItems= ` center , () ),
40+ style(
41+ ~fontSize= 10 .,
42+ ~color= Predefined . Colors . grey,
43+ ~alignItems= ` center ,
44+ () ,
45+ ),
4046 "officialDocLink" :
4147 style(
4248 ~display= ` flex ,
@@ -84,9 +90,8 @@ let make = (~pageData) => {
8490 None ;
8591 };
8692 let editHref =
87- "https://github.com/reasonml-community/reason-react-native/blob/master/reason-react-native/src/"
88- ++ pageData. id
89- ++ ".md" ;
93+ "https://github.com/reasonml-community/reason-react-native/blob/master/"
94+ ++ pageData. filename;
9095 <SpacedView style= styles##container vertical= SpacedView . L >
9196 <main >
9297 <header >
@@ -120,8 +125,8 @@ let make = (~pageData) => {
120125 -> Option . getWithDefault(React . null)}
121126 </TextLight >
122127 <TextLink href= editHref style= styles##editLink>
123- <SpacedView vertical= SpacedView . XS horizontal= SpacedView . XS >
124- <Text style= styles##editLinkText> {| Edit |} -> React . string </Text >
128+ <SpacedView vertical= SpacedView . XXS horizontal= SpacedView . XS >
129+ <Text style= styles##editLinkText> {| EDIT |} -> React . string </Text >
125130 </SpacedView >
126131 </TextLink >
127132 </Row . SpaceBetween >
You can’t perform that action at this time.
0 commit comments