Skip to content

Commit a0cf858

Browse files
authored
Install core and start migrating files (#863)
* install Core * start working on src files * npm i
1 parent 67ecba3 commit a0cf858

9 files changed

+129
-2091
lines changed

package-lock.json

Lines changed: 91 additions & 2061 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@docsearch/react": "^3.5.2",
2121
"@headlessui/react": "^1.2.0",
2222
"@mdx-js/loader": "^2.3.0",
23+
"@rescript/core": "^1.3.0",
2324
"@rescript/react": "^0.12.0-alpha.3",
2425
"@rescript/tools": "^0.5.0",
2526
"codemirror": "^5.54.0",
@@ -47,7 +48,7 @@
4748
"remark-slug": "^5.1.2",
4849
"remark-stringify": "^7.0.3",
4950
"request": "^2.88.0",
50-
"rescript": "^11.0.0",
51+
"rescript": "^11.1.0",
5152
"stringify-object": "^3.3.0",
5253
"unified": "^8.4.0"
5354
},
@@ -70,4 +71,4 @@
7071
"simple-functional-loader": "^1.2.1",
7172
"tailwindcss": "^3.3.3"
7273
}
73-
}
74+
}

rescript.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
},
77
"bs-dependencies": [
88
"@rescript/react",
9-
"@rescript/tools"
9+
"@rescript/tools",
10+
"@rescript/core"
1011
],
1112
"uncurried": true,
1213
"ppx-flags": [],
14+
"bsc-flags": [],
1315
"sources": [
1416
{
1517
"dir": "src",
@@ -22,7 +24,7 @@
2224
}
2325
],
2426
"package-specs": {
25-
"module": "es6",
27+
"module": "esmodule",
2628
"in-source": true
2729
},
2830
"warnings": {
@@ -34,4 +36,4 @@
3436
"shims": [],
3537
"module": "es6"
3638
}
37-
}
39+
}

src/ApiDocs.resi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let getStaticPathsByVersion: (
99
~version: string,
1010
) => promise<{
1111
"fallback": bool,
12-
"paths": Js.Array2.t<{
13-
"params": {"slug": array<Js.String2.t>},
12+
"paths": array<{
13+
"params": {"slug": array<string>},
1414
}>,
1515
}>

src/Blog.res

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
*/
1515

1616
module Link = Next.Link
17+
open RescriptCore
1718

1819
let defaultPreviewImg = "/static/Art-3-rescript-launch.jpg"
1920

2021
// For encoding reasons, see https://shripadk.github.io/react/docs/jsx-gotchas.html
21-
let middleDotSpacer = " " ++ (Js.String.fromCharCode(183) ++ " ")
22+
let middleDotSpacer = " " ++ (String.fromCharCode(183) ++ " ")
2223

2324
module Badge = {
2425
@react.component
@@ -79,7 +80,7 @@ module BlogCard = {
7980
~author as _: BlogFrontmatter.author,
8081
~category: option<string>=?,
8182
~badge: option<BlogFrontmatter.Badge.t>=?,
82-
~date: Js.Date.t,
83+
~date: Date.t,
8384
~slug: string,
8485
) =>
8586
<section className="h-full">
@@ -127,7 +128,7 @@ module FeatureCard = {
127128
~title: string="Unknown Title",
128129
~author: BlogFrontmatter.author,
129130
~badge: option<BlogFrontmatter.Badge.t>=?,
130-
~date: Js.Date.t,
131+
~date: Date.t,
131132
~category: option<string>=?,
132133
~firstParagraph: string="",
133134
~slug: string,
@@ -204,7 +205,7 @@ type props = {posts: array<BlogApi.post>, category: category}
204205
let default = (props: props): React.element => {
205206
let {posts, category} = props
206207

207-
let content = if Belt.Array.length(posts) === 0 {
208+
let content = if Array.length(posts) === 0 {
208209
/* <div> {React.string("Currently no posts available")} </div>; */
209210
<div className="mt-8">
210211
<Markdown.H1> {React.string("Blog not yet available")} </Markdown.H1>
@@ -220,11 +221,11 @@ let default = (props: props): React.element => {
220221
let featureBox =
221222
<div className="w-full mb-24 lg:px-8 xl:px-0">
222223
<FeatureCard
223-
previewImg=?{first.frontmatter.previewImg->Js.Null.toOption}
224+
previewImg=?{first.frontmatter.previewImg->Null.toOption}
224225
title=first.frontmatter.title
225-
badge=?{first.frontmatter.badge->Js.Null.toOption}
226+
badge=?{first.frontmatter.badge->Null.toOption}
226227
author=first.frontmatter.author
227-
firstParagraph=?{first.frontmatter.description->Js.Null.toOption}
228+
firstParagraph=?{first.frontmatter.description->Null.toOption}
228229
date={first.frontmatter.date->DateStr.toDate}
229230
slug={BlogApi.blogPathToSlug(first.path)}
230231
/>
@@ -236,11 +237,11 @@ let default = (props: props): React.element => {
236237
<div
237238
className="px-4 md:px-8 xl:px-0 grid grid-cols-1 xs:grid-cols-2 md:grid-cols-3 gap-20 gap-y-12 md:gap-y-24 w-full">
238239
{Js.Array2.map(rest, post => {
239-
let badge = post.frontmatter.badge->Js.Null.toOption
240+
let badge = post.frontmatter.badge->Null.toOption
240241

241242
<BlogCard
242243
key={post.path}
243-
previewImg=?{post.frontmatter.previewImg->Js.Null.toOption}
244+
previewImg=?{post.frontmatter.previewImg->Null.toOption}
244245
title=post.frontmatter.title
245246
author=post.frontmatter.author
246247
?badge

src/BlogArticle.res

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
builds are taking too long. I think we will be fine for now.
1717
Link to NextJS discussion: https://github.com/zeit/next.js/discussions/11728#discussioncomment-3501
1818
*/
19-
let middleDotSpacer = " " ++ (Js.String.fromCharCode(183) ++ " ")
19+
open RescriptCore
20+
21+
let middleDotSpacer = " " ++ (String.fromCharCode(183) ++ " ")
2022

2123
module Params = {
2224
type t = {slug: string}
@@ -151,17 +153,17 @@ let default = (props: props) => {
151153
<Meta
152154
siteName="ReScript Blog"
153155
title={title ++ " | ReScript Blog"}
154-
description=?{description->Js.Null.toOption}
155-
ogImage={previewImg->Js.Null.toOption->Belt.Option.getWithDefault(Blog.defaultPreviewImg)}
156+
description=?{description->Null.toOption}
157+
ogImage={previewImg->Null.toOption->Option.getOr(Blog.defaultPreviewImg)}
156158
/>
157159
<div className="mb-10 md:mb-20">
158160
<BlogHeader
159161
date
160162
author
161163
co_authors
162164
title
163-
description={description->Js.Null.toOption}
164-
articleImg={articleImg->Js.Null.toOption}
165+
description={description->Null.toOption}
166+
articleImg={articleImg->Null.toOption}
165167
/>
166168
</div>
167169
<div className="flex justify-center">
@@ -206,7 +208,7 @@ let getStaticProps: Next.GetStaticProps.t<props, Params.t> = async ctx => {
206208
open Next.GetStaticProps
207209
let {params} = ctx
208210

209-
let path = switch BlogApi.getAllPosts()->Js.Array2.find(({path}) =>
211+
let path = switch BlogApi.getAllPosts()->Array.find(({path}) =>
210212
BlogApi.blogPathToSlug(path) == params.slug
211213
) {
212214
| None => params.slug
@@ -215,7 +217,7 @@ let getStaticProps: Next.GetStaticProps.t<props, Params.t> = async ctx => {
215217

216218
let filePath = Node.Path.resolve("_blogposts", path)
217219

218-
let isArchived = Js.String2.startsWith(path, "archive/")
220+
let isArchived = String.startsWith(path, "archive/")
219221

220222
let source = filePath->Node.Fs.readFileSync
221223

src/Design.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// NOTE: This file will later be important to document our
22
// design tokens etc.
3-
3+
open RescriptCore
44
module ColorSquare = {
55
@react.component
66
let make = (~className="") => {
@@ -16,7 +16,7 @@ let default = () => {
1616
"bg-fire-50",
1717
"bg-fire-30",
1818
"bg-fire-10",
19-
]->Js.Array2.map(bgColorClass => {
19+
]->Array.map(bgColorClass => {
2020
<ColorSquare className=bgColorClass />
2121
})
2222

src/DocsOverview.res

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
open RescriptCore
12
module Card = {
23
@react.component
34
let make = (~title: string, ~hrefs: array<(string, string)>) => {
45
let style = ReactDOM.Style.make(~maxWidth="21rem", ())
56
<div style className="border border-gray-10 bg-gray-5 px-5 py-8 rounded-lg">
67
<h2 className="font-bold text-24 mb-4"> {React.string(title)} </h2>
78
<ul>
8-
{Belt.Array.map(hrefs, ((text, href)) =>
9+
{Array.map(hrefs, ((text, href)) =>
910
<li key=text className="text-16 mb-1 last:mb-0">
1011
<Markdown.A href> {React.string(text)} </Markdown.A>
1112
</li>
@@ -51,8 +52,8 @@ let default = (~showVersionSelect=true) => {
5152

5253
let targetUrl =
5354
"/" ++
54-
(Js.Array2.joinWith(url.base, "/") ++
55-
("/" ++ (version ++ ("/" ++ Js.Array2.joinWith(url.pagepath, "/")))))
55+
(Array.join(url.base, "/") ++
56+
("/" ++ (version ++ ("/" ++ Array.join(url.pagepath, "/")))))
5657
router->Next.Router.push(targetUrl)
5758
}
5859
<div className="text-fire">

src/components/AnsiPre.res

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file was automatically converted to ReScript from 'AnsiPre.re'
22
// Check the output and make sure to delete the original file
33
open Ansi
4+
open RescriptCore
45

56
type colorTarget =
67
| Fg
@@ -31,15 +32,15 @@ let renderSgrString = (~key: string, sgrStr: SgrString.t): React.element => {
3132

3233
let className =
3334
params
34-
->Js.Array2.map(p =>
35+
->Array.map(p =>
3536
switch p {
3637
| Sgr.Bold => "bold"
3738
| Fg(c) => mapColor(~target=Fg, c)
3839
| Bg(c) => mapColor(~target=Bg, c)
3940
| _ => ""
4041
}
4142
)
42-
->Js.Array2.joinWith(" ")
43+
->Array.join(" ")
4344

4445
<span key className> {React.string(content)} </span>
4546
}

0 commit comments

Comments
 (0)