feat: zeropost-web — публичный AI-блог на zeropost.ru
- Next.js 16, Tailwind с @tailwindcss/typography - Главная: hero, featured-статья, сетка карточек, облако тегов - /blog/[slug]: статья со SSG + revalidate 60s, prose typography - /tag/[name]: фильтр по тегам - /about: про проект - /api/cron/generate: endpoint для авто-генерации (защищён x-cron-token) - SEO: dynamic metadata, OG, sitemap-ready - Лента грузится с zeropost-engine /api/articles
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { generateArticle } from '@/lib/engine';
|
||||
|
||||
/**
|
||||
* POST /api/cron/generate — генерит одну новую статью.
|
||||
* Защищено токеном CRON_TOKEN.
|
||||
* Cron на сервере дёргает каждые N часов с темой из бэклога.
|
||||
*/
|
||||
export async function POST(req) {
|
||||
const auth = req.headers.get('x-cron-token');
|
||||
if (auth !== process.env.CRON_TOKEN) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
try {
|
||||
const { topic, tags = [], keywords = [] } = await req.json();
|
||||
if (!topic) return NextResponse.json({ error: 'topic required' }, { status: 400 });
|
||||
const article = await generateArticle({ topic, tags, keywords, autoPublish: true });
|
||||
return NextResponse.json({ ok: true, slug: article.slug, title: article.title });
|
||||
} catch (err) {
|
||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user