From 1319c79d614f74d8dbcf8bf1da2d1db8cfa8ed2c Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Fri, 28 Feb 2025 02:16:27 -0600 Subject: [PATCH] refactor: replace anchor tags with buttons for author interactions --- .../[locale]/blog/components/BlogPostCard.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/website/app/[locale]/blog/components/BlogPostCard.tsx b/apps/website/app/[locale]/blog/components/BlogPostCard.tsx index 5fe5659..22f108d 100644 --- a/apps/website/app/[locale]/blog/components/BlogPostCard.tsx +++ b/apps/website/app/[locale]/blog/components/BlogPostCard.tsx @@ -3,13 +3,14 @@ import type { Post } from "@/lib/ghost"; import Image from "next/image"; import Link from "next/link"; - +import { useRouter } from "next/navigation"; interface BlogPostCardProps { post: Post; locale: string; } export function BlogPostCard({ post, locale }: BlogPostCardProps) { + const router = useRouter(); const formattedDate = new Date(post.published_at).toLocaleDateString(locale, { year: "numeric", month: "long", @@ -17,6 +18,9 @@ export function BlogPostCard({ post, locale }: BlogPostCardProps) { }); const handleTwitterClick = (e: React.MouseEvent) => { + if (post.primary_author?.twitter) { + router.push(`https://twitter.com/${post.primary_author.twitter}`); + } e.preventDefault(); e.stopPropagation(); }; @@ -29,7 +33,7 @@ export function BlogPostCard({ post, locale }: BlogPostCardProps) {
{post.feature_image {post.primary_author.twitter ? ( - - + ) : ( )} {post.primary_author?.twitter ? ( - {post.primary_author.name || "Unknown Author"} - + ) : ( {post.primary_author?.name || "Unknown Author"} )}