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 (