diff --git a/app/posts/page.tsx b/app/blog/page.tsx
similarity index 74%
rename from app/posts/page.tsx
rename to app/blog/page.tsx
index 56ead0c..7f873df 100644
--- a/app/posts/page.tsx
+++ b/app/blog/page.tsx
@@ -1,10 +1,11 @@
-import { getAllPosts } from "../../lib/api";
+import { getAllPosts, getPostSlugs, getPostBySlug } from "../../lib/api";
import PostPreview from "../../components/postPreview";
import PageTitle from "../../components/page-title";
import styles from "./styles.module.css";
export default function Posts() {
+
const posts = getAllPosts(["title", "date", "excerpt", "slug"]);
return (
@@ -13,11 +14,12 @@ export default function Posts() {
All Posts
- {posts.map((post) => (
+ {posts.map((post) => (
- ))}
+ ))
+ }
@@ -26,3 +28,4 @@ export default function Posts() {
);
}
+
diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx
index eef84a2..f50e7dd 100644
--- a/app/posts/[slug]/page.tsx
+++ b/app/posts/[slug]/page.tsx
@@ -4,9 +4,18 @@ import styles from "./styles.module.css";
import Image from "next-image-export-optimizer";
import Link from "next/link";
-export default async function Page({ params }: { params: { slug: string } }) {
+export async function generateStaticParams() {
+ const posts = getPostSlugs();
+ return posts.map((post) => ({
+ slug: post,
+ }));
+}
+
+export default async function Page({ params }: { params: { slug: string }}) {
+
+ const { slug } = params;
- const getPost = getPostBySlug(params.slug, ["title", "author", "content", "date"]);
+ const getPost = getPostBySlug(slug, ["title", "author", "content", "date"]);
const content = await markdownToHtml(getPost["content"] || "");
diff --git a/app/posts/styles.module.css b/app/posts/styles.module.css
deleted file mode 100644
index 5e52f41..0000000
--- a/app/posts/styles.module.css
+++ /dev/null
@@ -1,172 +0,0 @@
-.logoLine {
- padding-top: 12px;
- padding-bottom: 0;
- margin: auto;
-}
-
-.logo {
- height: auto;
- width: 100%;
- display: block;
- margin: auto;
-}
-
-@media (min-width: 640px) {
- .logo {
- max-width: 564px;
- }
-}
-
-.newsletterName {
- padding-top: 0;
- padding-bottom: 12px;
- font-size: 1.25rem;
- color: black;
- font-weight: 400;
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
- margin: auto;
- max-width: fit-content;
-}
-
-.vert {
- color: #c40000;
-}
-
-.breakLine {
- height: 7px;
- background-color: #c40000;
- border-radius: 5px 0px 5px 0px;
- margin: 20px 50px;
- margin: auto;
- max-width: 100%;
-}
-
-@media (min-width: 640px) {
- .breakLine {
- max-width: 1000px;
- }
-}
-
-.title {
- font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;
- text-align: center;
- font-size: 2.5rem;
- padding-top: 1rem;
-}
-
-.date {
- text-transform: uppercase;
-}
-
-.button {
- margin: auto;
- max-width: fit-content;
- padding-top: 12px;
- padding-bottom: 12px;
- margin-bottom: 2rem;
-}
-
-.donateButton {
- background-color: var(--color-brand);
- border: 2px solid var(--color-brand);
- border-radius: 12px;
- color: white;
- padding: 12px 1.5rem;
- transition: background-color 0.2s ease, color 0.2s ease;
- font-weight: 500;
- font-size: 1.25rem;
-}
-
-.donateButton:hover {
- background-color: transparent;
- color: var(--color-brand);
-}
-
-.mediaIcons {
- display: flex;
- flex-wrap: wrap;
- gap: 3rem;
- margin: auto;
- align-items: center;
- justify-content: center;
- justify-items: center;
- justify-self: center;
- padding-top: 2rem;
-}
-
-.icon {
- display: flex;
- border: 0;
- width: 50px;
- height: auto;
- max-width: 100%;
- align-items: center;
- justify-content: center;
- justify-items: center;
- justify-self: center;
-}
-
-.markdown {
- margin: auto;
- margin-bottom: 2rem;
-}
-
-@media (min-width: 1280px) {
- .markdown {
- width: 1280px;
- padding: 0 10rem;
- }
-}
-
-@media (min-width: 1536px) {
- .markdown {
- max-width: 1536px;
- padding: 0 10rem;
- }
-}
-
-.markdown p,
-.markdown ul,
-.markdown ol,
-.markdown blockquote {
- font-size: 1.25rem;
- font-weight: 200;
- text-align: justify;
-}
-
-.markdown img {
- width: 1000px;
- height: auto;
- max-width: 100%;
- border-radius: 10px;
- display: block;
-}
-
-.markdown h1,
-.markdown h2 {
- font-weight: bold;
- font-size: 2rem;
- color: #c40000;
- text-align: center;
- line-height: 4rem;
- margin-top: 2rem;
-}
-
-.markdown h4 {
- background-color: transparent;
- padding-top: 0;
- padding-bottom: 12px;
- text-align: center;
- font-size: 1.25rem;
- font-weight: 200;
- color: gray;
-}
-
-.markdown a {
- color: #c40000;
-}
-
-.markdown a:hover {
- color: #c40000;
- text-decoration: underline;
-}
\ No newline at end of file
diff --git a/components/navbar.tsx b/components/navbar.tsx
index 6dcb1d5..5c22750 100644
--- a/components/navbar.tsx
+++ b/components/navbar.tsx
@@ -15,7 +15,7 @@ const Navbar = () => {
},
{label: "Awards", to: "/awards"},
{ label: "Our Team", to: "/team" },
- { label: "Build Blog", to: "/posts" },
+ { label: "Build Blog", to: "/blog" },
{ label: "Sponsors", to: "/sponsors" },
{ label: "Gallery", to: "/gallery" },
{ label: "Contact", to: "/contact" },
diff --git a/lib/api.ts b/lib/api.ts
index 40aac48..e51ee1e 100644
--- a/lib/api.ts
+++ b/lib/api.ts
@@ -2,7 +2,8 @@ import * as fs from "fs";
import { join } from "path";
import matter from "gray-matter";
-const postsDirectory = join(process.cwd(), "_posts");
+const postsDirectory = "_posts";
+//join("process.cwd()", "_posts");
export function getPostSlugs() {
return fs.readdirSync(postsDirectory);