From adb4266e5e37913cd52d42e575d40b5437a40b21 Mon Sep 17 00:00:00 2001 From: Aleksei Pavlov Date: Sun, 21 Jun 2026 21:38:13 +0300 Subject: [PATCH] =?UTF-8?q?feat(AutogenPanel):=20=D0=BF=D0=BE=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20=D1=81=D0=BB=D0=B5=D0=B4?= =?UTF-8?q?=D1=83=D1=8E=D1=89=D1=83=D1=8E=20=D1=82=D0=B5=D0=BC=D1=83=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=BA=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Каждая карточка теперь показывает: - жанровый бейдж: [ТУТОРИАЛ] синий / [СРАВНЕНИЕ] фиолетовый / [МНЕНИЕ] янтарный / [ДАЙДЖЕСТ] зелёный - название темы (без маркера, line-clamp-2) - если уже генерировали сегодня → '✓ уже сгенерировано сегодня' parseTopic() разбирает [ЖАНР] префикс из blog_topics.topic. next_topic приходит из getAutogenStatus() через subquery в SQL. --- components/admin/AutogenPanel.js | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/components/admin/AutogenPanel.js b/components/admin/AutogenPanel.js index a16e76b..e3e648b 100644 --- a/components/admin/AutogenPanel.js +++ b/components/admin/AutogenPanel.js @@ -76,6 +76,29 @@ function buildCatMap(categories) { return map; } +// Разбирает [ЖАНР] из названия темы → { genre, title, color } +function parseTopic(topic) { + if (!topic) return { genre: null, title: topic, color: 'neutral' }; + const m = topic.match(/^\[([^\]]+)\]\s*(.*)/s); + if (!m) return { genre: null, title: topic, color: 'neutral' }; + const genres = { + 'ТУТОРИАЛ': { label: 'Туториал', color: 'blue' }, + 'СРАВНЕНИЕ': { label: 'Сравнение', color: 'purple' }, + 'МНЕНИЕ': { label: 'Мнение', color: 'amber' }, + 'ДАЙДЖЕСТ': { label: 'Дайджест', color: 'emerald' }, + }; + const g = genres[m[1]] || { label: m[1], color: 'neutral' }; + return { genre: g.label, title: m[2], color: g.color }; +} + +const GENRE_COLORS = { + blue: 'bg-blue-100 text-blue-700 dark:bg-blue-950 dark:text-blue-300', + purple: 'bg-purple-100 text-purple-700 dark:bg-purple-950 dark:text-purple-300', + amber: 'bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300', + emerald: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300', + neutral: 'bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400', +}; + export default function AutogenPanel({ status, queue, topics, categories = [] }) { const CAT_LABELS = buildCatMap(categories); const router = useRouter(); @@ -224,6 +247,32 @@ export default function AutogenPanel({ status, queue, topics, categories = [] })
{s.article_count || 0} статей · {s.topic_count_free ?? s.topic_count ?? 0} тем свободно
+ + {/* Следующая тема */} + {s.next_topic && (() => { + const { genre, title, color } = parseTopic(s.next_topic); + const drafted = parseInt(s.drafts_today, 10) > 0; + return ( +
+
+ {drafted + ? ✓ уже сгенерировано сегодня + : <> + Следующая тема: + {genre && ( + + {genre} + + )} + + } +
+ {!drafted && ( +
{title}
+ )} +
+ ); + })()}