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}
+ )} +
+ ); + })()}