Skip to content

Install core and start migrating files #863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,152 changes: 91 additions & 2,061 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@docsearch/react": "^3.5.2",
"@headlessui/react": "^1.2.0",
"@mdx-js/loader": "^2.3.0",
"@rescript/core": "^1.3.0",
"@rescript/react": "^0.12.0-alpha.3",
"@rescript/tools": "^0.5.0",
"codemirror": "^5.54.0",
Expand Down Expand Up @@ -47,7 +48,7 @@
"remark-slug": "^5.1.2",
"remark-stringify": "^7.0.3",
"request": "^2.88.0",
"rescript": "^11.0.0",
"rescript": "^11.1.0",
"stringify-object": "^3.3.0",
"unified": "^8.4.0"
},
Expand All @@ -70,4 +71,4 @@
"simple-functional-loader": "^1.2.1",
"tailwindcss": "^3.3.3"
}
}
}
8 changes: 5 additions & 3 deletions rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
},
"bs-dependencies": [
"@rescript/react",
"@rescript/tools"
"@rescript/tools",
"@rescript/core"
],
"uncurried": true,
"ppx-flags": [],
"bsc-flags": [],
"sources": [
{
"dir": "src",
Expand All @@ -22,7 +24,7 @@
}
],
"package-specs": {
"module": "es6",
"module": "esmodule",
"in-source": true
},
"warnings": {
Expand All @@ -34,4 +36,4 @@
"shims": [],
"module": "es6"
}
}
}
4 changes: 2 additions & 2 deletions src/ApiDocs.resi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let getStaticPathsByVersion: (
~version: string,
) => promise<{
"fallback": bool,
"paths": Js.Array2.t<{
"params": {"slug": array<Js.String2.t>},
"paths": array<{
"params": {"slug": array<string>},
}>,
}>
19 changes: 10 additions & 9 deletions src/Blog.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
*/

module Link = Next.Link
open RescriptCore

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

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

module Badge = {
@react.component
Expand Down Expand Up @@ -79,7 +80,7 @@ module BlogCard = {
~author as _: BlogFrontmatter.author,
~category: option<string>=?,
~badge: option<BlogFrontmatter.Badge.t>=?,
~date: Js.Date.t,
~date: Date.t,
~slug: string,
) =>
<section className="h-full">
Expand Down Expand Up @@ -127,7 +128,7 @@ module FeatureCard = {
~title: string="Unknown Title",
~author: BlogFrontmatter.author,
~badge: option<BlogFrontmatter.Badge.t>=?,
~date: Js.Date.t,
~date: Date.t,
~category: option<string>=?,
~firstParagraph: string="",
~slug: string,
Expand Down Expand Up @@ -204,7 +205,7 @@ type props = {posts: array<BlogApi.post>, category: category}
let default = (props: props): React.element => {
let {posts, category} = props

let content = if Belt.Array.length(posts) === 0 {
let content = if Array.length(posts) === 0 {
/* <div> {React.string("Currently no posts available")} </div>; */
<div className="mt-8">
<Markdown.H1> {React.string("Blog not yet available")} </Markdown.H1>
Expand All @@ -220,11 +221,11 @@ let default = (props: props): React.element => {
let featureBox =
<div className="w-full mb-24 lg:px-8 xl:px-0">
<FeatureCard
previewImg=?{first.frontmatter.previewImg->Js.Null.toOption}
previewImg=?{first.frontmatter.previewImg->Null.toOption}
title=first.frontmatter.title
badge=?{first.frontmatter.badge->Js.Null.toOption}
badge=?{first.frontmatter.badge->Null.toOption}
author=first.frontmatter.author
firstParagraph=?{first.frontmatter.description->Js.Null.toOption}
firstParagraph=?{first.frontmatter.description->Null.toOption}
date={first.frontmatter.date->DateStr.toDate}
slug={BlogApi.blogPathToSlug(first.path)}
/>
Expand All @@ -236,11 +237,11 @@ let default = (props: props): React.element => {
<div
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">
{Js.Array2.map(rest, post => {
let badge = post.frontmatter.badge->Js.Null.toOption
let badge = post.frontmatter.badge->Null.toOption

<BlogCard
key={post.path}
previewImg=?{post.frontmatter.previewImg->Js.Null.toOption}
previewImg=?{post.frontmatter.previewImg->Null.toOption}
title=post.frontmatter.title
author=post.frontmatter.author
?badge
Expand Down
16 changes: 9 additions & 7 deletions src/BlogArticle.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
builds are taking too long. I think we will be fine for now.
Link to NextJS discussion: https://github.com/zeit/next.js/discussions/11728#discussioncomment-3501
*/
let middleDotSpacer = " " ++ (Js.String.fromCharCode(183) ++ " ")
open RescriptCore

let middleDotSpacer = " " ++ (String.fromCharCode(183) ++ " ")

module Params = {
type t = {slug: string}
Expand Down Expand Up @@ -151,17 +153,17 @@ let default = (props: props) => {
<Meta
siteName="ReScript Blog"
title={title ++ " | ReScript Blog"}
description=?{description->Js.Null.toOption}
ogImage={previewImg->Js.Null.toOption->Belt.Option.getWithDefault(Blog.defaultPreviewImg)}
description=?{description->Null.toOption}
ogImage={previewImg->Null.toOption->Option.getOr(Blog.defaultPreviewImg)}
/>
<div className="mb-10 md:mb-20">
<BlogHeader
date
author
co_authors
title
description={description->Js.Null.toOption}
articleImg={articleImg->Js.Null.toOption}
description={description->Null.toOption}
articleImg={articleImg->Null.toOption}
/>
</div>
<div className="flex justify-center">
Expand Down Expand Up @@ -206,7 +208,7 @@ let getStaticProps: Next.GetStaticProps.t<props, Params.t> = async ctx => {
open Next.GetStaticProps
let {params} = ctx

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

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

let isArchived = Js.String2.startsWith(path, "archive/")
let isArchived = String.startsWith(path, "archive/")

let source = filePath->Node.Fs.readFileSync

Expand Down
4 changes: 2 additions & 2 deletions src/Design.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NOTE: This file will later be important to document our
// design tokens etc.

open RescriptCore
module ColorSquare = {
@react.component
let make = (~className="") => {
Expand All @@ -16,7 +16,7 @@ let default = () => {
"bg-fire-50",
"bg-fire-30",
"bg-fire-10",
]->Js.Array2.map(bgColorClass => {
]->Array.map(bgColorClass => {
<ColorSquare className=bgColorClass />
})

Expand Down
7 changes: 4 additions & 3 deletions src/DocsOverview.res
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
open RescriptCore
module Card = {
@react.component
let make = (~title: string, ~hrefs: array<(string, string)>) => {
let style = ReactDOM.Style.make(~maxWidth="21rem", ())
<div style className="border border-gray-10 bg-gray-5 px-5 py-8 rounded-lg">
<h2 className="font-bold text-24 mb-4"> {React.string(title)} </h2>
<ul>
{Belt.Array.map(hrefs, ((text, href)) =>
{Array.map(hrefs, ((text, href)) =>
<li key=text className="text-16 mb-1 last:mb-0">
<Markdown.A href> {React.string(text)} </Markdown.A>
</li>
Expand Down Expand Up @@ -51,8 +52,8 @@ let default = (~showVersionSelect=true) => {

let targetUrl =
"/" ++
(Js.Array2.joinWith(url.base, "/") ++
("/" ++ (version ++ ("/" ++ Js.Array2.joinWith(url.pagepath, "/")))))
(Array.join(url.base, "/") ++
("/" ++ (version ++ ("/" ++ Array.join(url.pagepath, "/")))))
router->Next.Router.push(targetUrl)
}
<div className="text-fire">
Expand Down
5 changes: 3 additions & 2 deletions src/components/AnsiPre.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file was automatically converted to ReScript from 'AnsiPre.re'
// Check the output and make sure to delete the original file
open Ansi
open RescriptCore

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

let className =
params
->Js.Array2.map(p =>
->Array.map(p =>
switch p {
| Sgr.Bold => "bold"
| Fg(c) => mapColor(~target=Fg, c)
| Bg(c) => mapColor(~target=Bg, c)
| _ => ""
}
)
->Js.Array2.joinWith(" ")
->Array.join(" ")

<span key className> {React.string(content)} </span>
}
Expand Down
Loading