'use client'; import { ContentItem } from '../lib/content'; interface DocumentListProps { documents: ContentItem[]; currentLang: string; } export function DocumentList({ documents, currentLang }: DocumentListProps) { const formatDate = (dateString: string) => { const date = new Date(dateString); return date.toLocaleDateString(currentLang === 'en' ? 'en-US' : 'zh-CN', { year: 'numeric', month: 'long', day: 'numeric', }); }; const getCategoryColor = (category: string) => { const colors = { 入门指南: 'bg-green-100 text-green-800', 配置: 'bg-blue-100 text-blue-800', 内容: 'bg-purple-100 text-purple-800', 部署: 'bg-orange-100 text-orange-800', 'Getting Started': 'bg-green-100 text-green-800', Configuration: 'bg-blue-100 text-blue-800', Content: 'bg-purple-100 text-purple-800', Deployment: 'bg-orange-100 text-orange-800', }; return colors[category] || 'bg-gray-100 text-gray-800'; }; if (documents.length === 0) { return (

{currentLang === 'en' ? 'No documents found' : '暂无文档'}

); } return (
{documents.map((doc) => (

{doc.metadata.title}

{doc.metadata.description}

{doc.metadata.category}
{doc.metadata.author} {formatDate(doc.metadata.date)}
{doc.metadata.tags && doc.metadata.tags.length > 0 && (
{doc.metadata.tags.slice(0, 3).map((tag) => ( {tag} ))} {doc.metadata.tags.length > 3 && ( +{doc.metadata.tags.length - 3} )}
)}
{currentLang === 'en' ? 'Read more' : '阅读更多'}
))}
); }