From 515515090ab929d5ba31841011926c4d6e9bc24e Mon Sep 17 00:00:00 2001 From: ridhozhr10 Date: Sat, 1 Jun 2024 08:32:15 +0700 Subject: [PATCH] feat: fix twitter tag to summary card --- src/app/posts/[...path]/page.tsx | 10 ++++++++++ src/app/tags/[tag]/page.tsx | 9 +++++++-- src/constants.ts | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/app/posts/[...path]/page.tsx b/src/app/posts/[...path]/page.tsx index c294862..5b2f58d 100644 --- a/src/app/posts/[...path]/page.tsx +++ b/src/app/posts/[...path]/page.tsx @@ -99,6 +99,11 @@ export function generateMetadata({ params }: Props): Metadata { images: `/img/smug-ico.png`, type: "website", }, + twitter: { + card: "summary", + title: `${params.path.join("/")} Posts :: Ridho Azhar`, + images: [`/img/smug-ico.png`], + }, }; } @@ -122,6 +127,11 @@ export function generateMetadata({ params }: Props): Metadata { publishedTime: post.created_at, modifiedTime: post.updated_at, }, + twitter: { + card: "summary", + title, + images: [post.ogImage.url], + }, }; } diff --git a/src/app/tags/[tag]/page.tsx b/src/app/tags/[tag]/page.tsx index 22b62ad..44cbea1 100644 --- a/src/app/tags/[tag]/page.tsx +++ b/src/app/tags/[tag]/page.tsx @@ -64,11 +64,16 @@ export function generateMetadata({ params }: Props): Metadata { title, robots: { follow: true, index: true }, openGraph: { - title: `title`, + title, url: `/tags/${params.tag}`, - images: `/img/smug-ico.png`, + images: [`/img/smug-ico.png`], type: "website", }, + twitter: { + card: "summary", + title, + images: [`/img/smug-ico.png`], + }, }; } export function generateStaticParams() { diff --git a/src/constants.ts b/src/constants.ts index b3f1384..20dbd60 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -18,8 +18,14 @@ export const baseMetadata = (path: string, titlePrefix?: string): Metadata => { title: `${titlePrefix || ""}${titlePrefix ? " :: " : ""}${title}`, url: `${path ? "/" : ""}${path}`, description: description, - images: `/img/smug-ico.png`, + images: [`/img/smug-ico.png`], type: "website", }, + twitter: { + card: "summary", + description, + title: `${titlePrefix || ""}${titlePrefix ? " :: " : ""}${title}`, + images: [`/img/smug-ico.png`], + }, }; };