import Link from 'next/link'; import { Activity, Cpu, Calendar, Sparkles, Zap } from 'lucide-react'; import { formatDate } from '@/lib/markdown'; // Сколько прошло времени с даты function timeAgo(iso) { if (!iso) return null; const seconds = Math.max(0, Math.floor((Date.now() - new Date(iso).getTime()) / 1000)); const mins = Math.floor(seconds / 60); const hours = Math.floor(mins / 60); const days = Math.floor(hours / 24); if (days > 0) return `${days} дн назад`; if (hours > 0) return `${hours} ч назад`; if (mins > 0) return `${mins} мин назад`; return 'только что'; } export default function NowBlock({ live }) { if (!live) return null; const { latest, processing, week } = live; const maxCnt = Math.max(1, ...week.map(d => d.cnt)); return (

Сейчас

{/* Главная карточка — последняя статья / процесс */}
{processing ? ( <>
ИИ пишет статью
«{processing.topic}»
Началось {timeAgo(processing.created_at)} · подожди немного, скоро появится
) : latest ? (
Последний материал — {timeAgo(latest.published_at)}
{latest.title}
claude-sonnet-4-6 {latest.tokens_out && ( {latest.tokens_out.toLocaleString('ru-RU')} токенов )}
) : (
Скоро здесь что-нибудь появится…
)}
{/* Bar-чарт за 7 дней */}
Активность за неделю
{week.map((d, i) => { const h = d.cnt > 0 ? Math.max(10, (d.cnt / maxCnt) * 100) : 4; const isToday = i === week.length - 1; return (
0 ? (isToday ? 'rgb(var(--accent))' : 'rgb(var(--accent) / 0.45)') : 'rgb(var(--surface-2))', }} title={`${d.day}: ${d.cnt} ${d.cnt === 1 ? 'статья' : 'статей'}`} />
); })}
{week.map((d, i) => { const date = new Date(d.day); const dow = ['вс','пн','вт','ср','чт','пт','сб'][date.getDay()]; return ( {dow} ); })}
); }