Skip to content

Commit 43a3394

Browse files
committed
start working on src files
1 parent 7d89412 commit 43a3394

File tree

6 files changed

+33
-28
lines changed

6 files changed

+33
-28
lines changed

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: 13 additions & 12 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
@@ -89,7 +90,7 @@ module BlogCard = {
8990
~author as _: BlogFrontmatter.author,
9091
~category: option<string>=?,
9192
~badge: option<BlogFrontmatter.Badge.t>=?,
92-
~date: Js.Date.t,
93+
~date: Date.t,
9394
~slug: string,
9495
) =>
9596
<section className="h-full">
@@ -137,7 +138,7 @@ module FeatureCard = {
137138
~title: string="Unknown Title",
138139
~author: BlogFrontmatter.author,
139140
~badge: option<BlogFrontmatter.Badge.t>=?,
140-
~date: Js.Date.t,
141+
~date: Date.t,
141142
~category: option<string>=?,
142143
~firstParagraph: string="",
143144
~slug: string,
@@ -219,7 +220,7 @@ let default = (props: props): React.element => {
219220

220221
let (currentSelection, setSelection) = React.useState(() => CategorySelector.All)
221222

222-
let content = if Belt.Array.length(posts) === 0 {
223+
let content = if Array.length(posts) === 0 {
223224
/* <div> {React.string("Currently no posts available")} </div>; */
224225
<div className="mt-8">
225226
<Markdown.H1> {React.string("Blog not yet available")} </Markdown.H1>
@@ -231,20 +232,20 @@ let default = (props: props): React.element => {
231232
| Archived => archived
232233
}
233234

234-
let result = switch Belt.Array.length(filtered) {
235+
let result = switch Array.length(filtered) {
235236
| 0 => <div> {React.string("No posts for this category available...")} </div>
236237
| _ =>
237-
let first = Belt.Array.getExn(filtered, 0)
238-
let rest = Js.Array2.sliceFrom(filtered, 1)
238+
let first = Array.getUnsafe(filtered, 0)
239+
let rest = Array.slice(filtered, ~start=1, ~end=filtered->Array.length)
239240

240241
let featureBox =
241242
<div className="w-full mb-24 lg:px-8 xl:px-0">
242243
<FeatureCard
243-
previewImg=?{first.frontmatter.previewImg->Js.Null.toOption}
244+
previewImg=?{first.frontmatter.previewImg->Null.toOption}
244245
title=first.frontmatter.title
245-
badge=?{first.frontmatter.badge->Js.Null.toOption}
246+
badge=?{first.frontmatter.badge->Null.toOption}
246247
author=first.frontmatter.author
247-
firstParagraph=?{first.frontmatter.description->Js.Null.toOption}
248+
firstParagraph=?{first.frontmatter.description->Null.toOption}
248249
date={first.frontmatter.date->DateStr.toDate}
249250
slug={BlogApi.blogPathToSlug(first.path)}
250251
/>
@@ -256,11 +257,11 @@ let default = (props: props): React.element => {
256257
<div
257258
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">
258259
{Js.Array2.map(rest, post => {
259-
let badge = post.frontmatter.badge->Js.Null.toOption
260+
let badge = post.frontmatter.badge->Null.toOption
260261

261262
<BlogCard
262263
key={post.path}
263-
previewImg=?{post.frontmatter.previewImg->Js.Null.toOption}
264+
previewImg=?{post.frontmatter.previewImg->Null.toOption}
264265
title=post.frontmatter.title
265266
author=post.frontmatter.author
266267
?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)