diff --git a/frontend/application/app/blog/[slug]/page.tsx b/frontend/application/app/blog/[slug]/page.tsx
index 83c19567..d0cef91b 100644
--- a/frontend/application/app/blog/[slug]/page.tsx
+++ b/frontend/application/app/blog/[slug]/page.tsx
@@ -1,22 +1,7 @@
import React from "react";
-import {
- ChevronRight,
- Calendar,
- User,
- Clock,
- Tag,
- Share2,
- MessageSquare,
- Sparkles,
- ShoppingBag,
- ArrowLeft,
- Send,
- Eye,
-} from "lucide-react";
-import Link from 'next/link';
import { notFound } from 'next/navigation';
import type { Metadata } from 'next';
-import SafeImage from "../../../components/SafeImage";
+import BlogPostClient from "../../../components/BlogPostClient";
import { getSeoConfig, formatPageTitle } from "../../../lib/seo";
function safeIso(val: any, fallback?: string): string | undefined {
@@ -174,10 +159,8 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
const publishedIso = safeIso(blog.publishedAt) || safeIso(blog.createdAt) || new Date().toISOString();
const modifiedIso = safeIso(blog.updatedAt) || publishedIso;
- // JSON-LD Structured Data Schema (BlogPosting & BreadcrumbList)
const schemaType = blog.schemaType || 'BlogPosting';
- // Robust Author object for Google Rich Results
const authorSchema = blog.author && (blog.author.firstName || blog.author.lastName)
? {
'@type': 'Person',
@@ -259,13 +242,8 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
],
};
- const relatedProducts = Array.isArray(blog.relatedProducts) ? blog.relatedProducts : [];
- const relatedBlogs = Array.isArray(blog.relatedBlogs) ? blog.relatedBlogs : [];
- const comments = Array.isArray(blog.comments) ? blog.comments : [];
-
return (
-
- {/* Inject JSON-LD Schema */}
+ <>
-
-
- {/* Breadcrumbs */}
-
- خانه
-
- مجله سلامت
- {blog.category && (
- <>
-
-
- {blog.category.name}
-
- >
- )}
-
- {blog.title}
-
-
-
- {/* Main Article Content Column */}
-
-
- {/* Featured Image */}
- {blog.imageUrl && (
-
-
- {blog.imageCaption && (
-
- {blog.imageCaption}
-
- )}
-
- )}
-
- {/* Meta details bar */}
-
- {blog.category && (
-
- {blog.category.name}
-
- )}
- {publishedDate && (
-
-
- {publishedDate}
-
- )}
-
-
- {blog.readingTime || 4} دقیقه مطالعه
-
-
-
- {blog.viewCount || 0} بازدید
-
-
-
- {/* Title */}
-
- {blog.title}
-
-
- {/* Excerpt / Summary Callout */}
- {blog.excerpt && (
-
- {blog.excerpt}
-
- )}
-
- {/* Main Rich Content HTML Renderer */}
-
-
- {/* Tags Chip Footer */}
- {Array.isArray(blog.tags) && blog.tags.length > 0 && (
-
-
-
- برچسبهای مرتبط:
-
- {blog.tags.map((tag: any, idx: number) => {
- const tagName = typeof tag === 'string' ? tag : tag?.name || '';
- const tagId = tag?.id || idx;
- if (!tagName) return null;
- return (
-
- #{tagName}
-
- );
- })}
-
- )}
-
- {/* Author Box */}
-
-
-
-
-
-
-
{authorName}
-
- تیم تحقیق و توسعه علمی کنینا آلمان (Canina Pharma)
-
-
-
-
-
-
-
-
-
- {/* Comments Section */}
- {blog.allowComments !== false && (
-
-
-
-
- دیدگاهها و پرسشهای کاربران ({comments.length})
-
-
-
- {/* Comment Form */}
-
-
- {/* Comments List */}
- {comments.length > 0 ? (
-
- {comments.map((c: any) => (
-
-
- {c.authorName}
-
- {safeLocalDate(c.createdAt)}
-
-
-
{c.content}
-
- ))}
-
- ) : (
-
- هنوز دیدگاهی برای این مقاله ثبت نشده است. اولین نظر را شما بنویسید!
-
- )}
-
- )}
-
-
- {/* Sidebar Column */}
-
-
-
-
+
+ >
);
}
diff --git a/frontend/application/components/BlogPostClient.tsx b/frontend/application/components/BlogPostClient.tsx
new file mode 100644
index 00000000..fdae9c0e
--- /dev/null
+++ b/frontend/application/components/BlogPostClient.tsx
@@ -0,0 +1,372 @@
+"use client";
+import React, { useState } from "react";
+import {
+ ChevronRight,
+ Calendar,
+ User,
+ Clock,
+ Tag,
+ Share2,
+ MessageSquare,
+ Sparkles,
+ ShoppingBag,
+ ArrowLeft,
+ Send,
+ Eye,
+} from "lucide-react";
+import Link from 'next/link';
+import SafeImage from "./SafeImage";
+
+interface BlogPostClientProps {
+ blog: any;
+ publishedDate: string;
+ authorName: string;
+}
+
+export default function BlogPostClient({ blog, publishedDate, authorName }: BlogPostClientProps) {
+ const [copied, setCopied] = useState(false);
+ const [commentName, setCommentName] = useState("");
+ const [commentEmail, setCommentEmail] = useState("");
+ const [commentText, setCommentText] = useState("");
+ const [commentSent, setCommentSent] = useState(false);
+
+ const relatedProducts = Array.isArray(blog.relatedProducts) ? blog.relatedProducts : [];
+ const relatedBlogs = Array.isArray(blog.relatedBlogs) ? blog.relatedBlogs : [];
+ const comments = Array.isArray(blog.comments) ? blog.comments : [];
+
+ const handleShare = () => {
+ if (typeof window !== 'undefined') {
+ if (navigator.share) {
+ navigator.share({ title: blog.title, url: window.location.href }).catch(() => null);
+ } else {
+ navigator.clipboard.writeText(window.location.href);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 3000);
+ }
+ }
+ };
+
+ const handleCommentSubmit = (e: React.FormEvent) => {
+ e.preventDefault();
+ setCommentSent(true);
+ setCommentName("");
+ setCommentEmail("");
+ setCommentText("");
+ };
+
+ return (
+
+
+ {/* Breadcrumbs */}
+
+ خانه
+
+ مجله سلامت
+ {blog.category && (
+ <>
+
+
+ {blog.category.name}
+
+ >
+ )}
+
+ {blog.title}
+
+
+
+ {/* Main Article Content Column */}
+
+
+ {/* Featured Image */}
+ {blog.imageUrl && (
+
+
+ {blog.imageCaption && (
+
+ {blog.imageCaption}
+
+ )}
+
+ )}
+
+ {/* Meta details bar */}
+
+ {blog.category && (
+
+ {blog.category.name}
+
+ )}
+ {publishedDate && (
+
+
+ {publishedDate}
+
+ )}
+
+
+ {blog.readingTime || 4} دقیقه مطالعه
+
+
+
+ {blog.viewCount || 0} بازدید
+
+
+
+ {/* Title */}
+
+ {blog.title}
+
+
+ {/* Excerpt / Summary Callout */}
+ {blog.excerpt && (
+
+ {blog.excerpt}
+
+ )}
+
+ {/* Main Rich Content HTML Renderer */}
+
+
+ {/* Tags Chip Footer */}
+ {Array.isArray(blog.tags) && blog.tags.length > 0 && (
+
+
+
+ برچسبهای مرتبط:
+
+ {blog.tags.map((tag: any, idx: number) => {
+ const tagName = typeof tag === 'string' ? tag : tag?.name || '';
+ const tagId = tag?.id || idx;
+ if (!tagName) return null;
+ return (
+
+ #{tagName}
+
+ );
+ })}
+
+ )}
+
+ {/* Author Box */}
+
+
+
+
+
+
+
{authorName}
+
+ تیم تحقیق و توسعه علمی کنینا آلمان (Canina Pharma)
+
+
+
+
+
+
+
+
+
+ {/* Comments Section */}
+ {blog.allowComments !== false && (
+
+
+
+
+ دیدگاهها و پرسشهای کاربران ({comments.length})
+
+
+
+ {commentSent ? (
+
+ دیدگاه شما با موفقیت ثبت شد و پس از بررسی و تایید تیم علمی، در سایت نمایش داده میشود.
+
+ ) : (
+
+ )}
+
+ {/* Comments List */}
+ {comments.length > 0 ? (
+
+ {comments.map((c: any) => (
+
+
+ {c.authorName}
+
+ {c.createdAt ? new Date(c.createdAt).toLocaleDateString('fa-IR') : ''}
+
+
+
{c.content}
+
+ ))}
+
+ ) : (
+
+ هنوز دیدگاهی برای این مقاله ثبت نشده است. اولین نظر را شما بنویسید!
+
+ )}
+
+ )}
+
+
+ {/* Sidebar Column */}
+
+
+
+
+ );
+}