Skip to content

Revert "Add community blog and first blog post" #976

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 1 commit into from
Mar 4, 2025
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
142 changes: 0 additions & 142 deletions _blogposts/community/2025-03-03-what-can-i-do-with-rescript.mdx

This file was deleted.

7 changes: 0 additions & 7 deletions pages/blog/community.js

This file was deleted.

3 changes: 1 addition & 2 deletions pages/community/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ News are broadcasted on this site's blog, on Bluesky and X. Some extra, less imp

## Articles

- [Community Blog](/blog/community)
- [Getting rid of your dead code in ReScript](https://dev.to/zth/getting-rid-of-your-dead-code-in-rescript-3mba)
- [Getting rid of your dead code in ReScript](https://dev.to/zth/getting-rid-of-your-dead-code-in-rescript-3mba)
- [Speeding up ReScript compilation using interface files](https://dev.to/zth/speeding-up-rescript-compilation-using-interface-files-4fgn)
- Articles in [awesome-rescript](https://github.com/fhammerschmidt/awesome-rescript#readme)

Expand Down
26 changes: 6 additions & 20 deletions src/Blog.res
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ module Badge = {
}

type category =
| Official
| Community
| /** Actually only unarchived */ All
| Archived

module CategorySelector = {
@react.component
let make = (~selected: category) => {
let tabs = [Official, Community, Archived]
let tabs = [All, Archived]

<div className="text-16 w-full flex items-center justify-between text-gray-60">
{tabs
Expand All @@ -57,8 +56,7 @@ module CategorySelector = {
let isActive = selected == tab
let text = (tab :> string)
let href = switch tab {
| Official => "/blog"
| Community => "/blog/community"
| All => "/blog"
| Archived => "/blog/archived"
}
let className =
Expand Down Expand Up @@ -172,10 +170,7 @@ module FeatureCard = {
<div>
<a
className="hover:text-gray-60"
href={switch author.social {
| X(handle) => "https://x.com/" ++ handle
| Bluesky(handle) => "https://bsky.app/profile/" ++ handle
}}
href={"https://x.com/" ++ author.xHandle}
rel="noopener noreferrer">
{React.string(author.fullname)}
</a>
Expand Down Expand Up @@ -302,26 +297,17 @@ let default = (props: props): React.element => {
let getStaticProps_All: Next.GetStaticProps.t<props, params> = async _ctx => {
let props = {
posts: BlogApi.getLivePosts(),
category: Official,
category: All,
}

{"props": props}
}

let getStaticProps_Archived: Next.GetStaticProps.t<props, params> = async _ctx => {
let props = {
posts: BlogApi.getSpecialPosts("archive"),
posts: BlogApi.getArchivedPosts(),
category: Archived,
}

{"props": props}
}

let getStaticProps_Community: Next.GetStaticProps.t<props, params> = async _ctx => {
let props = {
posts: BlogApi.getSpecialPosts("community"),
category: Community,
}

{"props": props}
}
3 changes: 1 addition & 2 deletions src/Blog.resi
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ let defaultPreviewImg: string
type params
type props

type category = Official | Community | Archived
type category = All | Archived

let default: props => React.element

let getStaticProps_All: Next.GetStaticProps.t<props, params>
let getStaticProps_Archived: Next.GetStaticProps.t<props, params>
let getStaticProps_Community: Next.GetStaticProps.t<props, params>
33 changes: 2 additions & 31 deletions src/BlogArticle.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ module AuthorBox = {
<div className="w-10 h-10 bg-berry-40 block rounded-full mr-3"> authorImg </div>
<div className="body-sm">
<a
href={switch author.social {
| X(handle) => "https://x.com/" ++ handle
| Bluesky(handle) => "https://bsky.app/profile/" ++ handle
}}
href={"https://x.com/" ++ author.xHandle}
className="hover:text-gray-80"
rel="noopener noreferrer">
{React.string(author.fullname)}
Expand All @@ -63,7 +60,6 @@ module BlogHeader = {
~category: option<string>=?,
~description: option<string>,
~articleImg: option<string>,
~originalSrc: option<(string, string)>,
) => {
let date = DateStr.toDate(date)

Expand Down Expand Up @@ -92,17 +88,6 @@ module BlogHeader = {
</div>
}
)}
{switch originalSrc {
| None => React.null
| Some("", _) => React.null
| Some(_, "") => React.null
| Some(url, title) =>
<div className="mt-1 mb-8">
<a className="body-sm no-underline text-fire hover:underline" href=url>
{React.string(`Originally posted on ${title}`)}
</a>
</div>
}}
<div className="flex flex-col md:flex-row mb-12">
{Array.map(authors, author =>
<div
Expand Down Expand Up @@ -162,17 +147,7 @@ let default = (props: props) => {
: React.null

let content = switch fm {
| Ok({
date,
author,
co_authors,
title,
description,
articleImg,
previewImg,
originalSrc,
originalSrcUrl,
}) =>
| Ok({date, author, co_authors, title, description, articleImg, previewImg}) =>
<div className="w-full">
<Meta
siteName="ReScript Blog"
Expand All @@ -188,10 +163,6 @@ let default = (props: props) => {
title
description={description->Null.toOption}
articleImg={articleImg->Null.toOption}
originalSrc={switch (originalSrcUrl->Null.toOption, originalSrc->Null.toOption) {
| (Some(url), Some(title)) => Some(url, title)
| _ => None
}}
/>
</div>
<div className="flex justify-center">
Expand Down
34 changes: 9 additions & 25 deletions src/common/BlogApi.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ type post = {
}

let blogPathToSlug = path => {
path
->String.replaceRegExp(%re(`/^(archive\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/`), "$2")
->String.replaceRegExp(%re(`/^(community\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/`), "$2")
path->String.replaceRegExp(%re(`/^(archive\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/`), "$2")
}

let mdxFiles = dir => {
Expand All @@ -51,7 +49,6 @@ let mdxFiles = dir => {
let getAllPosts = () => {
let postsDirectory = Node.Path.join2(Node.Process.cwd(), "_blogposts")
let archivedPostsDirectory = Node.Path.join2(postsDirectory, "archive")
let communityPostsDirectory = Node.Path.join2(postsDirectory, "community")

let nonArchivedPosts = mdxFiles(postsDirectory)->Array.map(path => {
let {GrayMatter.data: data} =
Expand Down Expand Up @@ -79,20 +76,7 @@ let getAllPosts = () => {
}
})

let communityPosts = mdxFiles(communityPostsDirectory)->Array.map(path => {
let {GrayMatter.data: data} =
Node.Path.join2(communityPostsDirectory, path)->Node.Fs.readFileSync->GrayMatter.matter
switch BlogFrontmatter.decode(data) {
| Error(msg) => Exn.raiseError(msg)
| Ok(d) => {
path: Node.Path.join2("community", path),
frontmatter: d,
archived: false,
}
}
})

Array.concatMany(nonArchivedPosts, [archivedPosts, communityPosts])->Array.toSorted((a, b) =>
Array.concat(nonArchivedPosts, archivedPosts)->Array.toSorted((a, b) =>
String.compare(Node.Path.basename(b.path), Node.Path.basename(a.path))
)
}
Expand All @@ -118,24 +102,24 @@ let getLivePosts = () => {
)
}

let getSpecialPosts = directory => {
let getArchivedPosts = () => {
let postsDirectory = Node.Path.join2(Node.Process.cwd(), "_blogposts")
let specialPostsDirectory = Node.Path.join2(postsDirectory, directory)
let archivedPostsDirectory = Node.Path.join2(postsDirectory, "archive")

let specialPosts = mdxFiles(specialPostsDirectory)->Array.map(path => {
let archivedPosts = mdxFiles(archivedPostsDirectory)->Array.map(path => {
let {GrayMatter.data: data} =
Node.Path.join2(specialPostsDirectory, path)->Node.Fs.readFileSync->GrayMatter.matter
Node.Path.join2(archivedPostsDirectory, path)->Node.Fs.readFileSync->GrayMatter.matter
switch BlogFrontmatter.decode(data) {
| Error(msg) => Exn.raiseError(msg)
| Ok(d) => {
path: Node.Path.join2(directory, path),
path: Node.Path.join2("archive", path),
frontmatter: d,
archived: directory === "archive",
archived: true,
}
}
})

specialPosts->Array.toSorted((a, b) =>
archivedPosts->Array.toSorted((a, b) =>
String.compare(Node.Path.basename(b.path), Node.Path.basename(a.path))
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/BlogApi.resi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type post = {

let getAllPosts: unit => array<post>
let getLivePosts: unit => array<post>
let getSpecialPosts: string => array<post>
let getArchivedPosts: unit => array<post>
let blogPathToSlug: string => string

module RssFeed: {
Expand Down
Loading
Loading