Skip to content

Commit 585e0df

Browse files
committed
resources json
1 parent c008c2b commit 585e0df

File tree

4 files changed

+102
-47
lines changed

4 files changed

+102
-47
lines changed

data/resources.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[
2+
{
3+
"title": "Getting rid of your dead code in ReScript",
4+
"description": "Exploring ReScript's tools for eliminating dead code, keeping your repository clean and without... Tagged with rescript.",
5+
"image": "https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F12lsasc06v1a355i6rfk.jpeg",
6+
"url": "https://dev.to/zth/getting-rid-of-your-dead-code-in-rescript-3mba"
7+
},
8+
{
9+
"title": "Belt.Array vs Js.Array in Rescript",
10+
"description": "You might have noticed that there are several ways in Rescript for iterating through elements of an array. It’s not at all obvious which one you should be using…",
11+
"image": "https://www.daggala.com/static/30b47dd2b0682e7eb0279b85bc9ebb53/f3583/toolbelt.png",
12+
"url": "https://www.daggala.com/belt_vs_js_array_in_rescript/"
13+
},
14+
{
15+
"title": "From TypeScript To ReScript | Serhii Potapov (greyblake)",
16+
"description": "A blog about software development.",
17+
"image": "https://www.greyblake.com/greyblake.jpeg",
18+
"url": "https://www.greyblake.com/blog/from-typescript-to-rescript/"
19+
},
20+
{
21+
"title": "Full-stack ReScript. Architecture Overview",
22+
"description": "Can ReScript be used to create a full-featured back-end? In this article, I’d try to prove it can and does it with success.\n",
23+
"image": "",
24+
"url": "https://fullsteak.dev/posts/fullstack-rescript-architecture-overview"
25+
},
26+
{
27+
"title": "ReScript for React Development",
28+
"description": "Looking for ReScript for React Development information? In this article, I highlight the development & business advantages of ReScript.",
29+
"image": "https://scalac.io/wp-content/uploads/2021/08/ReScript-for-React-Development-FB.png",
30+
"url": "https://scalac.io/blog/rescript-for-react-development/"
31+
},
32+
{
33+
"title": "Rewriting a Project in ReScript",
34+
"description": "My experience reimplementing a small project in ReScript",
35+
"image": "",
36+
"url": "https://yangdanny97.github.io/blog/2021/07/09/Migrating-to-Rescript"
37+
},
38+
{
39+
"title": "Responsive Images and Cumulative Layout Shift",
40+
"description": "Solving cumulative layout shift issue caused by responsive images in layouts.",
41+
"image": "https://d20bjcorj7xdk.cloudfront.net/eyJidWNrZXQiOiJpbWFnZXMuYWxleGZlZG9zZWV2LmNvbSIsImtleSI6Im1ldGEtYmxvZy5wbmciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjEyMDAsImhlaWdodCI6NjMwLCJmaXQiOiJjb3ZlciJ9LCJqcGVnIjp7InF1YWxpdHkiOjkwfX19?signature=d8e6c0ac1ff03d0f5ee04d128b96a7701b998952a38ba96e9a16e4414cd05ed0&version=58cfd6f8abdefeca2195a6a1f1108596",
42+
"url": "https://alexfedoseev.com/blog/post/responsive-images-and-cumulative-layout-shift"
43+
}
44+
]

scripts/generate_resources.res

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
We're doing this as a separate script because we want to be able to run it as needed.
3+
We don't want to do this as part of every build since we're scraping data and we don't want
4+
to get blocked.
5+
6+
Eventually we want to set a service that will allow us to do this as part of
7+
*/
8+
/** this is the list of community resources we want to generate */
9+
let sites = [
10+
"https://dev.to/zth/getting-rid-of-your-dead-code-in-rescript-3mba",
11+
"https://www.daggala.com/belt_vs_js_array_in_rescript/",
12+
"https://www.greyblake.com/blog/from-typescript-to-rescript/",
13+
"https://fullsteak.dev/posts/fullstack-rescript-architecture-overview",
14+
"https://scalac.io/blog/rescript-for-react-development/",
15+
"https://yangdanny97.github.io/blog/2021/07/09/Migrating-to-Rescript",
16+
"https://alexfedoseev.com/blog/post/responsive-images-and-cumulative-layout-shift",
17+
]
18+
19+
let generate = async () => {
20+
let filePath = "data/resources.json"
21+
let metaData = await MetaTagsApi.getMetaTags(sites)
22+
23+
Console.log(metaData)
24+
25+
let fileContent = `${metaData
26+
->Array.map(i =>
27+
{
28+
"title": `${i.title->Option.getOr("")}`,
29+
"description": `${i.description->Option.getOr("")}`,
30+
"image": `${i.image->Option.getOr("")}`,
31+
"url": `${i.url}`,
32+
}
33+
)
34+
->JSON.stringifyAny
35+
->Option.getOr("[]")}
36+
`
37+
38+
Node.Fs.writeFileSync(filePath, fileContent)
39+
}
40+
41+
await generate()

src/common/MetaTagsApi.res

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,29 @@ let extractMetaTags = async (url: string) => {
7575
}
7676
}
7777

78+
type tags = {
79+
...t,
80+
url: string,
81+
}
82+
7883
/*
7984
Pass an array of URLs and get back an array of meta tags for each URL.
8085
*/
8186
let getMetaTags = async (urls: array<string>) => {
82-
let metaTags = []
87+
let metaTags: array<tags> = []
8388
for i in 0 to Array.length(urls) - 1 {
8489
let url = urls[i]
8590
switch url {
8691
| Some(url) => {
8792
let tags = await extractMetaTags(url)
8893
switch tags {
89-
| Some(tags) => metaTags->Array.push(tags)
94+
| Some(tags) =>
95+
metaTags->Array.push({
96+
title: tags.title,
97+
description: tags.description,
98+
image: tags.image,
99+
url,
100+
})
90101
| None => ()
91102
}
92103
}

src/components/CommunityResources.res

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,8 @@ type link = {
55
image: string,
66
}
77

8-
let links: array<link> = [
9-
{
10-
url: "https://dev.to/zth/getting-rid-of-your-dead-code-in-rescript-3mba",
11-
title: "Getting rid of your dead code in ReScript - DEV Community",
12-
description: "Exploring ReScript's tools for eliminating dead code, keeping your repository clean and without... Tagged with rescript.",
13-
image: "https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F12lsasc06v1a355i6rfk.jpeg",
14-
},
15-
{
16-
url: "https://www.daggala.com/belt_vs_js_array_in_rescript/",
17-
title: "Belt.Array vs Js.Array in Rescript",
18-
description: "You might have noticed that there are several ways in Rescript for iterating through elements of an array. It’s not at all obvious which one you should be using…",
19-
image: "https://www.daggala.com/static/30b47dd2b0682e7eb0279b85bc9ebb53/f3583/toolbelt.png",
20-
},
21-
{
22-
url: "https://www.greyblake.com/blog/from-typescript-to-rescript/",
23-
title: "From TypeScript To ReScript | Serhii Potapov (greyblake)",
24-
description: "A blog about software development.",
25-
image: "https://www.greyblake.com/greyblake.jpeg",
26-
},
27-
{
28-
url: "https://fullsteak.dev/posts/fullstack-rescript-architecture-overview",
29-
title: "Full-stack ReScript. Architecture Overview | Full Steak Dev",
30-
description: "Can ReScript be used to create a full-featured back-end? In this article, I’d try to prove it can and does it with success.\n",
31-
image: "",
32-
},
33-
{
34-
url: "https://scalac.io/blog/rescript-for-react-development/",
35-
title: "ReScript for React - Development & Business Pros of ReScript",
36-
description: "Looking for ReScript for React Development information? In this article, I highlight the development & business advantages of ReScript.",
37-
image: "https://scalac.io/wp-content/uploads/2021/08/ReScript-for-React-Development-FB.png",
38-
},
39-
{
40-
url: "https://yangdanny97.github.io/blog/2021/07/09/Migrating-to-Rescript",
41-
title: "Rewriting a Project in ReScript",
42-
description: "My experience reimplementing a small project in ReScript",
43-
image: "",
44-
},
45-
{
46-
url: "https://alexfedoseev.com/blog/post/responsive-images-and-cumulative-layout-shift",
47-
title: "Responsive Images and Cumulative Layout Shift | Alex Fedoseev",
48-
description: "Solving cumulative layout shift issue caused by responsive images in layouts.",
49-
image: "https://d20bjcorj7xdk.cloudfront.net/eyJidWNrZXQiOiJpbWFnZXMuYWxleGZlZG9zZWV2LmNvbSIsImtleSI6Im1ldGEtYmxvZy5wbmciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjEyMDAsImhlaWdodCI6NjMwLCJmaXQiOiJjb3ZlciJ9LCJqcGVnIjp7InF1YWxpdHkiOjkwfX19?signature=d8e6c0ac1ff03d0f5ee04d128b96a7701b998952a38ba96e9a16e4414cd05ed0&version=58cfd6f8abdefeca2195a6a1f1108596",
50-
},
51-
]
8+
@module("../../data/resources.json")
9+
external resources: array<link> = "default"
5210

5311
let simplifyUrl = url =>
5412
url
@@ -58,6 +16,7 @@ let simplifyUrl = url =>
5816
->Array.at(0)
5917

6018
module LinkCard = {
19+
Console.log(resources)
6120
@react.component
6221
let make = (~link) => {
6322
<div
@@ -80,7 +39,7 @@ module LinkCards = {
8039
@react.component
8140
let make = () =>
8241
<div className="grid md:grid-cols-2 gap-6">
83-
{links
42+
{resources
8443
->Array.map(link =>
8544
switch link.image {
8645
| "" => {...link, image: "/static/Art-3-rescript-launch.jpg"}

0 commit comments

Comments
 (0)