generated from acm-ucr/acm-ucr-website
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Typescript for Blog #1814
Closed
Closed
Typescript for Blog #1814
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import matter from "gray-matter"; | ||
import fs from "fs"; | ||
import Link from "next/link"; | ||
|
||
interface Data { | ||
date: string; | ||
title: string; | ||
author: string; | ||
link: string; | ||
} | ||
|
||
const getBlogPost = async (): Promise<Data[]> => { | ||
const directory = process.cwd() + "/src/engineering/"; | ||
const files = fs.readdirSync(directory); | ||
|
||
return files.map((file) => { | ||
const path = `${directory}/${file}`; | ||
const contents = fs.readFileSync(path); | ||
const markdown = matter(contents); | ||
|
||
return markdown.data as Data; | ||
}); | ||
}; | ||
const Blog = async () => { | ||
const data = await getBlogPost(); | ||
|
||
const blogs = data.sort( | ||
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(), | ||
); | ||
|
||
return ( | ||
<> | ||
<div className="m-auto mt-[10%] w-10/12"> | ||
<title>Engineering | Engineering Blogs</title> | ||
<p className="m-0 text-center text-3xl font-bold md:text-left"> | ||
Engineering Blogs | ||
</p> | ||
<p className="my-3 w-full text-center md:w-3/4 md:text-left"> | ||
Check out our engineering blogs to learn more about the behind the | ||
scenes as engineers discuss various challenges, migrations, | ||
bottlenecks. Our engineering blogs captures how our engineers approach | ||
problems and bring innovative solutions to the table. | ||
</p> | ||
<div className="my-8 grid w-full grid-cols-1 gap-4 md:grid-cols-3 xl:grid-cols-5"> | ||
{blogs.map(({ title, author, date, link }, index) => ( | ||
<Link | ||
href={`/engineering/blog/${link}`} | ||
key={index} | ||
className="rounded-lg bg-hackathon-blue-200 px-3 py-2 text-white hover:cursor-pointer hover:opacity-80" | ||
> | ||
<p className="text-lg font-semibold">{title}</p> | ||
<p className="text-sm text-gray-300">{author}</p> | ||
<p className="flex justify-end text-sm text-gray-300"> | ||
{new Date(date).toLocaleDateString("en-US", { | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
})} | ||
</p> | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Blog; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the js file should have been deleted but there's no file modifications for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help