fix(blog): update fallback image handling, use SafeImage, and enhance related products display
Deploy Canina / deploy (push) Successful in 1m37s

This commit is contained in:
parsa aghaei committed 2026-08-24 17:49:40 +03:30
1 parent fe6a900665
commit 1ddfb0a823
14 files changed
+11087 -9377

No files matched your search

@@ -512,13 +512,13 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
/>
</div>
<div className="flex-1 min-w-0">
<span className="text-[10px] font-bold text-white/60 block truncate">{p.category?.name}</span>
<span className="text-[10px] font-bold text-white/60 block truncate">{p.category?.name || p.categorySlug}</span>
<h5 className="text-xs font-black text-white truncate group-hover:text-canina-gold transition-colors">
{p.nameFa}
</h5>
{p.prices?.[0]?.price && (
{(p.priceDisplay || p.priceValue || p.prices?.[0]?.price) && (
<span className="text-[11px] font-bold text-canina-gold font-mono mt-0.5 block">
{Number(p.prices[0].price).toLocaleString('fa-IR')} تومان
{p.priceDisplay || (p.priceValue ? `${Number(p.priceValue).toLocaleString('fa-IR')} تومان` : `${Number(p.prices[0].price).toLocaleString('fa-IR')} تومان`)}
</span>
)}
</div>
+1 -1
View File
@@ -58,7 +58,7 @@ async function getBlogs() {
? new Date(String(b.createdAt)).toLocaleDateString('fa-IR')
: '',
readingTime: b.readingTime || 3,
image: String(b.imageUrl || b.coverImage || 'https://images.unsplash.com/photo-1548767797-d8c844163c4c?auto=format&fit=crop&q=80&w=800'),
image: String(b.imageUrl || b.coverImage || '/assets/images/blog-placeholder.png'),
imageAlt: b.imageAlt || b.title,
author: authorName || 'نویسنده کنینا',
content: String(b.content || ''),
+10 -11
View File
@@ -23,6 +23,7 @@ import { Product } from "../lib/data/products";
import { productService } from "../lib/services/productService";
import { useRouter } from 'next/navigation';
import Image from 'next/image';
import SafeImage from './SafeImage';
export interface BlogCategory {
id: string;
@@ -240,15 +241,14 @@ export default function BlogPage({
className="bg-white rounded-[3.5rem] overflow-hidden border border-medical-gray-200 shadow-2xl flex flex-col lg:flex-row cursor-pointer group hover:border-canina-blue/30 transition-all"
onClick={() => router.push(`/blog/${featuredPost.slug}`)}
>
<div className="lg:w-1/2 aspect-video lg:aspect-auto relative overflow-hidden">
<Image
<div className="lg:w-1/2 aspect-video lg:aspect-auto relative overflow-hidden bg-medical-gray-100">
<SafeImage
src={featuredPost.image}
alt={featuredPost.imageAlt || featuredPost.title}
fill
priority
sizes="(max-width: 1024px) 100vw, 50vw"
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
unoptimized
className="w-full h-full"
imgClassName="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
/>
{featuredPost.featured && (
<div className="absolute top-6 right-6 px-3.5 py-1.5 bg-amber-500 text-white rounded-full text-xs font-black flex items-center gap-1.5 shadow-lg backdrop-blur-md">
@@ -311,17 +311,16 @@ export default function BlogPage({
onClick={() => router.push(`/blog/${post.slug}`)}
>
<div>
<div className="aspect-[16/10] overflow-hidden relative">
<Image
<div className="aspect-[16/10] overflow-hidden relative bg-medical-gray-100">
<SafeImage
src={post.image}
alt={post.imageAlt || post.title}
fill
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
className="w-full h-full object-cover group-hover:scale-108 transition-transform duration-700"
unoptimized
className="w-full h-full"
imgClassName="w-full h-full object-cover group-hover:scale-108 transition-transform duration-700"
/>
{post.category && (
<span className="absolute bottom-3 right-3 px-3 py-1 bg-black/60 backdrop-blur-md text-white rounded-xl text-[10px] font-bold">
<span className="absolute bottom-3 right-3 px-3 py-1 bg-black/60 backdrop-blur-md text-white rounded-xl text-[10px] font-bold z-10">
{post.category}
</span>
)}