From 785371bb3eccca455e5ce5fccbe9b6e3752a03f6 Mon Sep 17 00:00:00 2001
From: Bertrand Yuan <bert.yuan@outlook.com>
Date: Tue, 16 Dec 2025 00:15:04 +0800
Subject: fix(front-end): bug in viewing posts

---
 src/components/json-ld.tsx | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

(limited to 'src/components/json-ld.tsx')

diff --git a/src/components/json-ld.tsx b/src/components/json-ld.tsx
index a7cd884..58cb0ba 100644
--- a/src/components/json-ld.tsx
+++ b/src/components/json-ld.tsx
@@ -1,33 +1,30 @@
 import { title as homeTitle } from '@/app/(main)/layout.config';
 import { owner } from '@/app/(main)/layout.config';
 import { baseUrl } from '@/lib/constants';
-import type { Post } from '@/lib/source';
+import type { BlogPost } from '@/lib/payload-posts';
 import type { BlogPosting, BreadcrumbList, Graph } from 'schema-dts';
 
-export const PostJsonLd = ({ page }: { page: Post }) => {
-  if (!page) {
+export const PostJsonLd = ({ post }: { post: BlogPost }) => {
+  if (!post) {
     return null;
   }
 
-  const url = new URL(page.url, baseUrl.href).href;
+  const url = new URL(post.url, baseUrl.href).href;
 
-  const post: BlogPosting = {
+  const blogPosting: BlogPosting = {
     '@type': 'BlogPosting',
-    headline: page.data.title,
-    description: page.data.description,
-    image: new URL(`/og/${page.slugs.join('/')}/image.png`, baseUrl.href).href,
-    datePublished: new Date(page.data.date).toISOString(),
-    dateModified: page.data.lastModified
-      ? new Date(page.data.lastModified).toISOString()
-      : undefined,
+    headline: post.title,
+    description: post.description,
+    image: post.image ? new URL(post.image, baseUrl.href).href : undefined,
+    datePublished: post.date.toISOString(),
+    dateModified: post.updatedAt.toISOString(),
     mainEntityOfPage: {
       '@type': 'WebPage',
       '@id': url,
     },
     author: {
       '@type': 'Person',
-      name: page.data.author,
-      // url: 'https://techwithanirudh.com/',
+      name: post.author,
     },
     publisher: {
       '@type': 'Person',
@@ -54,7 +51,7 @@ export const PostJsonLd = ({ page }: { page: Post }) => {
       {
         '@type': 'ListItem',
         position: 3,
-        name: page.data.title,
+        name: post.title,
         item: url,
       },
     ],
@@ -62,7 +59,7 @@ export const PostJsonLd = ({ page }: { page: Post }) => {
 
   const graph: Graph = {
     '@context': 'https://schema.org',
-    '@graph': [post, breadcrumbList],
+    '@graph': [blogPosting, breadcrumbList],
   };
 
   return (
-- 
cgit v1.2.3

