aboutsummaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2023-07-15 13:43:54 -0400
committerAndrew Lee <alee14498@protonmail.com>2023-07-15 13:43:54 -0400
commitb5b66d3841cebac5ab34744e63fc60e2a69a7252 (patch)
tree5a01d5bc019b118f38bebde87b96611aa8a233a7 /components
parent959996961284a2800004eca2205add8e7d4f40f2 (diff)
downloadalure-website-b5b66d3841cebac5ab34744e63fc60e2a69a7252.tar.gz
alure-website-b5b66d3841cebac5ab34744e63fc60e2a69a7252.tar.bz2
alure-website-b5b66d3841cebac5ab34744e63fc60e2a69a7252.zip
New page; Post system; Fixed more padding
Diffstat (limited to 'components')
-rw-r--r--components/PostPreview.js14
-rw-r--r--components/getPostMetadata.js20
2 files changed, 34 insertions, 0 deletions
diff --git a/components/PostPreview.js b/components/PostPreview.js
new file mode 100644
index 0000000..6eca000
--- /dev/null
+++ b/components/PostPreview.js
@@ -0,0 +1,14 @@
+import Link from "next/link";
+
+export default function PostPreview(props) {
+ return (
+ <div key="post" className="py-2 bg-zinc-800 py-3 px-5 border border-gray-600 rounded-lg space-y-3">
+ <Link href={`/updates/${props.slug}`}>
+ <h2 className="font-medium text-2xl hover:underline">{props.title}</h2>
+ </Link>
+ <span>By {props.author}</span>
+ <p>{props.description}</p>
+ <p className="font-medium text-sm">Posted on {props.date}</p>
+ </div>
+ )
+}
diff --git a/components/getPostMetadata.js b/components/getPostMetadata.js
new file mode 100644
index 0000000..88e4566
--- /dev/null
+++ b/components/getPostMetadata.js
@@ -0,0 +1,20 @@
+import {readdirSync, readFileSync} from "fs";
+import matter from "gray-matter";
+
+export default function getPostMetadata() {
+ const folder = "posts/";
+ const files = readdirSync(folder);
+ const markdownPosts = files.filter((file) => file.endsWith(".md"));
+
+ return markdownPosts.map((fileName) => {
+ const fileContent = readFileSync(`posts/${fileName}`, "utf-8");
+ const matterResult = matter(fileContent);
+ return {
+ title: matterResult.data.title,
+ author: matterResult.data.author,
+ date: matterResult.data.date,
+ description: matterResult.data.description,
+ slug: fileName.replace(".md", "")
+ }
+ })
+}