From 5fd8dd21cc03224e2a07f8d1a8f2b5cccc1891bb Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 27 Mar 2025 18:54:21 +0700 Subject: [PATCH] fix: Refactor opengraph-image and page components --- src/app/(main)/berita/[slug]/opengraph-image.tsx | 10 ++++++++++ src/app/(main)/berita/[slug]/page.tsx | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/(main)/berita/[slug]/opengraph-image.tsx b/src/app/(main)/berita/[slug]/opengraph-image.tsx index 5eb4b41..77e6137 100644 --- a/src/app/(main)/berita/[slug]/opengraph-image.tsx +++ b/src/app/(main)/berita/[slug]/opengraph-image.tsx @@ -129,6 +129,16 @@ export const options: ImageResponseOptions = { ], }; +export function generateImageMetadata() { + return [ + { + contentType: "image/jpeg", + size: { width: 600, height: 600 }, + id: "medium", + }, + ]; +} + export default async function opengraphImage({ params, }: { diff --git a/src/app/(main)/berita/[slug]/page.tsx b/src/app/(main)/berita/[slug]/page.tsx index 88bff1a..b529fcf 100644 --- a/src/app/(main)/berita/[slug]/page.tsx +++ b/src/app/(main)/berita/[slug]/page.tsx @@ -28,12 +28,12 @@ export async function generateMetadata({ return { title: post.title, - description: post.description, + description: post.description.trim() || null, authors: { name: post.user.name }, openGraph: { url: `${process.env.URL ?? "https://www.moklet.org"}/berita/${post.slug}`, title: post.title, - description: post.description, + description: post.description.trim() || undefined, type: "article", publishedTime: new Date(post.published_at!).toISOString(), modifiedTime: new Date(post.updated_at).toISOString(), @@ -57,12 +57,10 @@ export default async function Post({ const jsonLd: WithContext = { "@context": "https://schema.org", "@type": "NewsArticle", - image: post.thumbnail, description: post.description, headline: post.title, datePublished: new Date(post.published_at!).toISOString(), dateModified: new Date(post.updated_at).toISOString(), - thumbnailUrl: post.thumbnail, }; return (