From 15e21b5d882959f2d35123c358dd963e2fa551e1 Mon Sep 17 00:00:00 2001 From: Hugo Gonzaga Date: Tue, 8 Oct 2024 10:59:30 +0100 Subject: [PATCH] remove blog pages and respective dependencies --- app/blog/[slug]/page.tsx | 71 ----------------------------------- app/blog/page.tsx | 24 ------------ components/NavBar.tsx | 6 --- components/PostMetadata.ts | 6 --- components/PostPreview.tsx | 15 -------- components/getPostMetadata.ts | 22 ----------- package.json | 8 ++-- posts/hello-world.md | 50 ------------------------ 8 files changed, 3 insertions(+), 199 deletions(-) delete mode 100644 app/blog/[slug]/page.tsx delete mode 100644 app/blog/page.tsx delete mode 100644 components/PostMetadata.ts delete mode 100644 components/PostPreview.tsx delete mode 100644 components/getPostMetadata.ts delete mode 100644 posts/hello-world.md diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx deleted file mode 100644 index 56dd595..0000000 --- a/app/blog/[slug]/page.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import getPostMetadata from '@/components/getPostMetadata'; -import fs from 'fs'; -import matter from 'gray-matter'; -import Markdown from 'markdown-to-jsx'; -import type { Metadata } from 'next'; - -const getPostContent = (slug: string) => { - const folder = 'posts/'; - const file = `${folder}${slug}.md`; - const content = fs.readFileSync(file, 'utf8'); - const matterResult = matter(content); - return matterResult; -}; - -export const generateStaticParams = async () => { - const posts = getPostMetadata(); - return posts.map((post) => ({ - slug: post.slug, - })); -}; - -export async function generateMetadata( - props: any -): Promise { - const posts = getPostMetadata(); - const post = posts.find((post) => post.slug === props.slug); - if (!post) { - return; - } - - const { title, subtitle: description, date: publishedTime, slug } = post; - - return { - title, - description, - openGraph: { - title, - description, - type: 'article', - publishedTime, - url: `https://hgonzaga.com/blog/${slug}`, - }, - }; -} - -const PostPage = (props: any) => { - const slug = props.params.slug; - const post = getPostContent(slug); - - return ( -
-

- {post.data.title} -

-

{post.data.subtitle}

- -
-
- {post.data.date} -
-
-
- -
- {post.content} -
-
- ); -}; - -export default PostPage; diff --git a/app/blog/page.tsx b/app/blog/page.tsx deleted file mode 100644 index 6bd28dd..0000000 --- a/app/blog/page.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import PostPreview from '@/components/PostPreview'; -import getPostMetadata from '@/components/getPostMetadata'; -import { Metadata } from 'next'; - -export const metadata: Metadata = { - title: 'Blog', - description: 'A space for my thoughts on it world, and more.', -}; - -const BlogPage = () => { - const postMetadata = getPostMetadata(); - const postPreview = postMetadata.map((post) => ( - - )); - - return ( -
-

Blog

-
{postPreview}
-
- ); -}; - -export default BlogPage; diff --git a/components/NavBar.tsx b/components/NavBar.tsx index ef6523e..c58c252 100644 --- a/components/NavBar.tsx +++ b/components/NavBar.tsx @@ -12,16 +12,10 @@ const navItems = { '/about': { name: 'about', }, - '/blog': { - name: 'blog', - }, }; const Navbar = () => { let pathname = usePathname() || '/'; - if (pathname.includes('/blog/')) { - pathname = '/blog'; - } return (