import Image from 'next/image'; import Link from 'next/link'; import { Article } from '@/lib/types'; import { formatDate } from '@/lib/utils'; import { Card, CardContent } from '@/app/components/ui/card'; import { Badge } from '@/app/components/ui/badge'; import { Share2, ArrowLeft, Calendar, User, Tag, Clock, Eye } from 'lucide-react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import rehypeRaw from 'rehype-raw'; import rehypeSanitize from 'rehype-sanitize'; import ServerHeader from '@/app/components/ServerHeader'; import Footer from '@/app/components/Footer'; import { newsDetailTranslations } from '@/translations/news-detail'; import ShareButton from './ShareButton'; import BackButton from './BackButton'; interface NewsArticleServerComponentProps { article: Article; relatedArticles: Article[]; locale: string; } export default function NewsArticleServerComponent({ article, relatedArticles, locale }: NewsArticleServerComponentProps) { // 获取当前语言的翻译 const currentTranslations = newsDetailTranslations[locale as keyof typeof newsDetailTranslations] || newsDetailTranslations['zh-CN']; // 估算阅读时间 const estimateReadingTime = (content: string) => { const wordsPerMinute = 200; const words = content.split(/\s+/).length; return Math.ceil(words / wordsPerMinute); }; const readingTime = estimateReadingTime(article.content); return (
{/* 返回按钮 */} {/* 文章主体 */}
{/* 文章标题区域 */}
{article.metadata.category} {article.metadata.tags.map((tag, index) => ( {tag} ))}

{article.metadata.title}

{article.metadata.author}
{formatDate(article.metadata.date, locale)}
{readingTime} 分钟阅读

{article.metadata.description}

{/* 文章封面图 */} {article.metadata.image && (
{article.metadata.title}
)} {/* 文章内容 */}
(
{alt
), a: ({ href, children, ...props }) => ( {children} ), }} > {article.content}
{/* 相关文章推荐 */} {relatedArticles.length > 0 && (

{currentTranslations.relatedArticles}

{currentTranslations.relatedArticlesSubtitle}

{relatedArticles.map((relatedArticle) => (
{relatedArticle.metadata.title}

{relatedArticle.metadata.title}

{relatedArticle.metadata.excerpt}

{formatDate(relatedArticle.metadata.date, locale)} {relatedArticle.metadata.category}
))}
)}
); }