import Link from "next/link"; import type { BlogPost } from "@/types/blog"; import { editorjsToHtml, getCmsImageUrl } from "@/utils"; import { toSlug } from "@/utils/slugify"; import CommentsSection from "./CommentsSection"; interface NewsDetailsContentProps { post: BlogPost; } export default function NewsDetailsContent({ post }: NewsDetailsContentProps) { // Lấy comments từ post (đã được bao gồm trong API response) const postComments = post.comments || []; // Lấy base URL cho EditorJS images const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"; // URL tuyệt đối của bài viết để share lên mạng xã hội const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"; const postUrl = `${siteUrl}/blog/${post.slug}`; const encodedPostUrl = encodeURIComponent(postUrl); const encodedTitle = encodeURIComponent(post.title); // Chuyển đổi EditorJS content sang HTML const renderContent = () => { const html = editorjsToHtml(post.content, baseUrl); return { __html: html }; }; // Chuyển đổi EditorJS contentAfterQuote sang HTML const renderContentAfterQuote = () => { const html = editorjsToHtml(post.contentAfterQuote, baseUrl); return { __html: html }; }; return (
{post.title}
  • By {post.author}
  • {post.publishedAt}
  • {postComments.length} Comments

{post.title}

{/* Hình ảnh gallery */} {post.galleryImages && post.galleryImages.length > 0 && (
{post.galleryImages.map((image, index) => (
{`${post.title}
))}
)} {/* Quote/Sidebar */} {post.quote && (
{post.quote}
)} {/* Nội dung sau Quote */} {post.contentAfterQuote && (
)} {/* Tags và Social Share */}
Tags: {post.tags.map((tagName) => { // Tạo slug từ tên tag (hỗ trợ tiếng Việt) const tagSlug = toSlug(tagName); return ( {tagName} ); })}
); }