diff --git a/components/AuthorCard.tsx b/components/AuthorCard.tsx index 5ee31e5d9..5fed59e3a 100644 --- a/components/AuthorCard.tsx +++ b/components/AuthorCard.tsx @@ -2,6 +2,7 @@ import React from "react"; import Image from "next/image"; import Link from "next/link"; import { sanitizeAuthorSlug } from "../utils/sanitizeAuthorSlug"; +import { resolveAuthorAvatar } from "../lib/constants"; /* ── Small arrow icon ── */ const ArrowRightIcon = () => ( @@ -55,13 +56,13 @@ const AuthorCard: React.FC = ({ const roleBg = role === "Writer" ? "#FFF7ED" : "#F5F3FF"; const profileHref = `/authors/${sanitizeAuthorSlug(name)}`; - /* Resolve avatar src (handle external URLs via proxy) */ + /* Resolve avatar src: normalize junk (imag1/image/n/a/empty) to the local + placeholder first, then route real external URLs through the proxy. */ + const safeUrl = resolveAuthorAvatar(imageUrl); const resolvedSrc = - !imageUrl || imageUrl === "n/a" - ? "/blog/images/author.png" - : /^https?:\/\//i.test(imageUrl) && basePath - ? `${basePath}/api/proxy-image?url=${encodeURIComponent(imageUrl)}` - : imageUrl; + /^https?:\/\//i.test(safeUrl) && basePath + ? `${basePath}/api/proxy-image?url=${encodeURIComponent(safeUrl)}` + : safeUrl; /* Clean description sentences */ const descriptionText = diff --git a/components/AuthorHero.tsx b/components/AuthorHero.tsx index 5dafdf40d..e003a0be0 100644 --- a/components/AuthorHero.tsx +++ b/components/AuthorHero.tsx @@ -3,6 +3,7 @@ import Image from "next/image"; import Link from "next/link"; import { motion } from "framer-motion"; import { IoLogoLinkedin } from "react-icons/io5"; +import { resolveAuthorAvatar } from "../lib/constants"; interface AuthorHeroProps { name: string; @@ -17,7 +18,7 @@ const AuthorHero: React.FC = ({ description, linkedIn, }) => { - const resolvedAvatar = !avatarUrl || avatarUrl === "n/a" ? "/blog/images/author.png" : avatarUrl; + const resolvedAvatar = resolveAuthorAvatar(avatarUrl); // Only show social links that actually exist const socialSlots = [linkedIn].filter(link => link && link !== "n/a"); @@ -53,9 +54,10 @@ const AuthorHero: React.FC = ({ href={link!} target="_blank" rel="noopener noreferrer" + aria-label={`${name} on LinkedIn`} className="group flex items-center justify-center w-11 h-11 rounded-full bg-gray-100 text-[#637277] shadow-sm hover:bg-[#0077B5] hover:text-white hover:shadow-md transition-all duration-300" > - +