From 82c9bd815fec63211f72a1d4c308375c68e76460 Mon Sep 17 00:00:00 2001 From: Ashish Agarwal Date: Fri, 26 Apr 2024 02:03:56 +0530 Subject: [PATCH] Hm --- .../blog/[postSlug]/components/Article.jsx | 65 +++++++++++++++++ src/app/blog/[postSlug]/page.js | 72 ++----------------- 2 files changed, 72 insertions(+), 65 deletions(-) create mode 100644 src/app/blog/[postSlug]/components/Article.jsx diff --git a/src/app/blog/[postSlug]/components/Article.jsx b/src/app/blog/[postSlug]/components/Article.jsx new file mode 100644 index 0000000..a32eeaa --- /dev/null +++ b/src/app/blog/[postSlug]/components/Article.jsx @@ -0,0 +1,65 @@ +import Image from "next/image"; + +export const Article = ({ post }) => { + + return ( +
+ +
+

{post.title}

+
+ +
+

{post.author.name}

+ +
+
+

+ Published on + {` `} + {new Date(post.publishedAt).toLocaleDateString("en-us", { + weekday: "long", + year: "numeric", + month: "short", + day: "numeric", + })} +

+
+
+
+ ); +} diff --git a/src/app/blog/[postSlug]/page.js b/src/app/blog/[postSlug]/page.js index 8226188..9f279d1 100644 --- a/src/app/blog/[postSlug]/page.js +++ b/src/app/blog/[postSlug]/page.js @@ -1,20 +1,19 @@ -import Image from "next/image"; import { getPostBySlug, getAllPostSlugs } from "@/lib/posts"; +import { Article } from "./components/Article"; export async function generateStaticParams() { const slugs = await getAllPostSlugs(); return slugs.map((slug) => ({ - postSlug: slug + postSlug: slug, })); } -export async function generateMetadata({ - params, -}) { +export async function generateMetadata({ params }) { const post = await getPostBySlug(params.postSlug); return { title: `${post.title} - Ashish Agarwal`, - description: post.seo?.description || `Read ${post.title} on Ashish Agarwal's Blog`, + description: + post.seo?.description || `Read ${post.title} on Ashish Agarwal's Blog`, }; } @@ -22,64 +21,7 @@ export default async function Post({ params }) { const post = await getPostBySlug(params.postSlug); return ( <> -
- -
-

{post.title}

-
- -
-

{post.author.name}

- -
-
-

- Published on - {` `} - {new Date(post.publishedAt).toLocaleDateString("en-us", { - weekday: "long", - year: "numeric", - month: "short", - day: "numeric", - })} -

-
-
-
+
); -} \ No newline at end of file +}