diff --git a/src/app/blog/[slug]/page.tsx b/src/app/blog/[slug]/page.tsx
index 49f242d..f0a04bc 100644
--- a/src/app/blog/[slug]/page.tsx
+++ b/src/app/blog/[slug]/page.tsx
@@ -1,18 +1,22 @@
+import { Box, Typography } from '@mui/material';
import { getPostBySlug, getAllSlugs } from '../../../lib/posts';
import { notFound } from 'next/navigation';
-type Params = { slug: string };
+
+type Props = { params: Promise<{ slug: string }> };
+
export async function generateStaticParams() {
const slugs = getAllSlugs();
- return slugs.map(slug => ({ slug }));
+ return slugs.map(slug => ({ slug: slug.params?.slug }));
}
-export default async function BlogPost({ params }: { params: Params }) {
- const post = await getPostBySlug(params.slug);
+export default async function BlogPost({ params }: Props) {
+ const { slug } = await params;
+ const post = await getPostBySlug(slug);
if (!post) return notFound();
return (
-
- {post.title}
- {post.date}
-
-
+
+ {post.title}
+ {post.date}
+
+
);
}
\ No newline at end of file
diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx
index 57f99af..9588469 100644
--- a/src/app/blog/page.tsx
+++ b/src/app/blog/page.tsx
@@ -1,4 +1,3 @@
-
import { getAllPosts } from '../../lib/posts';
import ArticleIcon from '@mui/icons-material/Article';
import { Avatar, Box, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemText, Typography } from '@mui/material';
diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx
index eb8ebf1..ad363f1 100644
--- a/src/app/not-found.tsx
+++ b/src/app/not-found.tsx
@@ -1,7 +1,9 @@
+import { Box, Typography } from "@mui/material";
+
export default function Home() {
return (
-
-
Nothing to see here
-
+
+ Nothing to see here
+
);
}
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index db73a5d..020b0a3 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -42,9 +42,9 @@ export default function Header() {
)
return (
-
-
-
+ <>
+
+
TCG
+
@@ -68,6 +69,6 @@ export default function Header() {
>
{drawer}
-
+ >
)
}
\ No newline at end of file
diff --git a/src/components/ModeSwitch/ModeSwitch.tsx b/src/components/ModeSwitch/ModeSwitch.tsx
index 806405c..cc532c7 100644
--- a/src/components/ModeSwitch/ModeSwitch.tsx
+++ b/src/components/ModeSwitch/ModeSwitch.tsx
@@ -2,7 +2,7 @@
import * as React from 'react';
import FormControl from '@mui/material/FormControl';
import { useColorMode } from '@/theme/ThemeContext';
-import { styled, Switch } from '@mui/material';
+import { Box, styled, Switch } from '@mui/material';
const MaterialUISwitch = styled(Switch)(({ theme }) => ({
width: 62,
@@ -63,9 +63,11 @@ export default function ModeSwitch() {
return null;
}
return (
-
- {/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
- toggleColorMode()} />
-
+
+
+ {/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
+ toggleColorMode()} />
+
+
);
}
\ No newline at end of file
diff --git a/src/lib/posts.ts b/src/lib/posts.ts
index 7e929f3..5961eea 100644
--- a/src/lib/posts.ts
+++ b/src/lib/posts.ts
@@ -1,4 +1,3 @@
-// lib/posts.ts
import fs from 'fs';
import path from 'path';
import matter from 'gray-matter';
@@ -30,6 +29,9 @@ export function getAllPosts() {
export async function getPostBySlug(slug: string) {
const fullPath = path.join(postsDirectory, `${slug}.md`);
+ if (!fs.existsSync(fullPath)) {
+ throw new Error(`Post not found: ${slug}`);
+ }
const fileContents = fs.readFileSync(fullPath, 'utf8');
const { data, content } = matter(fileContents);
@@ -45,7 +47,7 @@ export async function getPostBySlug(slug: string) {
};
}
-export const getAllSlugs = (): Array<{ params: { slug: string } }> => {
+export const getAllSlugs = () => {
return fs.readdirSync(postsDirectory).map((fileName) => ({
params: { slug: fileName.replace(/\.md$/, '') },
}));
diff --git a/src/posts/first-post.md b/src/posts/first-post.md
index 4acb08c..93a0867 100644
--- a/src/posts/first-post.md
+++ b/src/posts/first-post.md
@@ -5,6 +5,6 @@ slug: 'first-post'
excerpt: 'This is an excerpt from the first post.'
---
-# My First Post
+# First Heading
Welcome to my blog post written in **Markdown**.