feat: оживление сайта — обложки, hero-фон, статистика, анимации

- ArticleCard: реальные обложки с fallback на детерминированный градиент по id статьи
- HeroBackground: 3 анимированных blob'а + dot-grid + плавный fade к контенту
- Stats компонент: 4 карточки — статьи / минуты чтения / токены / просмотры
- Reveal компонент: IntersectionObserver-based fade-in при скролле, respect prefers-reduced-motion
- next.config: rewrites /uploads/* → engine, чтобы картинки работали с относительными путями
- На странице статьи — обложка над контентом
This commit is contained in:
Alexey Pavlov
2026-05-31 09:17:08 +03:00
parent a16bf812e4
commit b1c09aa53f
8 changed files with 352 additions and 84 deletions
+11
View File
@@ -65,6 +65,17 @@ export default async function ArticlePage({ params }) {
)} )}
</div> </div>
{article.cover_url && (
<div className="mb-10 -mx-4 sm:mx-0">
<img
src={article.cover_url}
alt={article.title}
className="w-full rounded-xl"
style={{ aspectRatio: '16/9', objectFit: 'cover' }}
/>
</div>
)}
<div <div
className="prose prose-lg max-w-none font-serif prose-headings:font-sans" className="prose prose-lg max-w-none font-serif prose-headings:font-sans"
dangerouslySetInnerHTML={{ __html: html }} dangerouslySetInnerHTML={{ __html: html }}
+70 -47
View File
@@ -2,7 +2,10 @@ import Link from 'next/link';
import Header from '@/components/Header'; import Header from '@/components/Header';
import Footer from '@/components/Footer'; import Footer from '@/components/Footer';
import ArticleCard from '@/components/ArticleCard'; import ArticleCard from '@/components/ArticleCard';
import { listArticles, listTags } from '@/lib/engine'; import HeroBackground from '@/components/HeroBackground';
import Stats from '@/components/Stats';
import Reveal from '@/components/Reveal';
import { listArticles, listTags, getStats } from '@/lib/engine';
import { Sparkles, ArrowRight } from 'lucide-react'; import { Sparkles, ArrowRight } from 'lucide-react';
export const dynamic = 'force-dynamic'; export const dynamic = 'force-dynamic';
@@ -10,10 +13,12 @@ export const dynamic = 'force-dynamic';
export default async function HomePage() { export default async function HomePage() {
let articles = []; let articles = [];
let tags = []; let tags = [];
let stats = null;
try { try {
[articles, tags] = await Promise.all([ [articles, tags, stats] = await Promise.all([
listArticles({ limit: 13 }), listArticles({ limit: 13 }),
listTags(), listTags(),
getStats(),
]); ]);
} catch (err) { } catch (err) {
console.error('Home load failed:', err.message); console.error('Home load failed:', err.message);
@@ -26,50 +31,66 @@ export default async function HomePage() {
<Header /> <Header />
{/* Hero */} {/* Hero */}
<section className="container-wide pt-12 pb-10 sm:pt-20 sm:pb-16"> <section className="relative">
<div className="max-w-3xl"> <HeroBackground />
<div <div className="container-wide pt-16 pb-12 sm:pt-24 sm:pb-20 relative">
className="inline-flex items-center gap-2 text-xs accent px-3 py-1.5 rounded-full mb-6" <Reveal>
style={{ background: 'rgb(var(--accent) / 0.1)', border: '1px solid rgb(var(--accent) / 0.2)' }} <div className="max-w-3xl reveal">
> <div
<Sparkles className="w-3.5 h-3.5" /> className="inline-flex items-center gap-2 text-xs accent px-3 py-1.5 rounded-full mb-6"
Блог, который ведёт ИИ style={{ background: 'rgb(var(--accent) / 0.1)', border: '1px solid rgb(var(--accent) / 0.25)' }}
</div> >
<h1 className="text-4xl sm:text-6xl font-bold tracking-tight leading-tight mb-5 ink"> <Sparkles className="w-3.5 h-3.5" />
Практический ИИ.<br /> Блог, который ведёт ИИ
<span className="mute">Без воды и хайпа.</span> </div>
</h1> <h1 className="text-4xl sm:text-6xl lg:text-7xl font-bold tracking-tight leading-[1.05] mb-5 ink">
<p className="text-lg mute mb-8 max-w-2xl"> Практический ИИ.<br />
Промпты, кейсы, инструменты и разборы. Всё пишет ИИ кроме редакторских заметок. Если хочешь так же вести свой Telegram-канал попробуй наш сервис. <span className="mute">Без воды и хайпа.</span>
</p> </h1>
<div className="flex flex-wrap gap-3"> <p className="text-lg sm:text-xl mute mb-8 max-w-2xl leading-relaxed">
<Link href="#articles" className="btn btn-primary"> Промпты, кейсы, инструменты и разборы. Всё пишет ИИ кроме редакторских заметок. Если хочешь так же вести свой Telegram-канал попробуй наш сервис.
Читать статьи <ArrowRight className="w-4 h-4" /> </p>
</Link> <div className="flex flex-wrap gap-3">
<a href="https://app.zeropost.ru" className="btn btn-ghost"> <Link href="#articles" className="btn btn-primary">
Получить ассистента Читать статьи <ArrowRight className="w-4 h-4" />
</a> </Link>
</div> <a href="https://app.zeropost.ru" className="btn btn-ghost">
Получить ассистента
</a>
</div>
</div>
</Reveal>
</div> </div>
</section> </section>
{/* Stats */}
<Reveal>
<div className="reveal">
<Stats data={stats} />
</div>
</Reveal>
{/* Featured */} {/* Featured */}
{featured && ( {featured && (
<section id="articles" className="container-wide pb-8"> <Reveal>
<ArticleCard article={featured} featured /> <section id="articles" className="container-wide pb-8 reveal">
</section> <ArticleCard article={featured} featured />
</section>
</Reveal>
)} )}
{/* Rest */} {/* Rest */}
{rest.length > 0 && ( {rest.length > 0 && (
<section className="container-wide pb-12"> <Reveal>
<h2 className="text-sm font-medium uppercase tracking-widest mute mb-5"> <section className="container-wide pb-12 reveal">
Последние материалы <h2 className="text-sm font-medium uppercase tracking-widest mute mb-5">
</h2> Последние материалы
<div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-5"> </h2>
{rest.map(a => <ArticleCard key={a.id} article={a} />)} <div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-5">
</div> {rest.map(a => <ArticleCard key={a.id} article={a} />)}
</section> </div>
</section>
</Reveal>
)} )}
{articles.length === 0 && ( {articles.length === 0 && (
@@ -80,16 +101,18 @@ export default async function HomePage() {
{/* Tags */} {/* Tags */}
{tags.length > 0 && ( {tags.length > 0 && (
<section className="container-wide pb-12"> <Reveal>
<h2 className="text-sm font-medium uppercase tracking-widest mute mb-4">Темы</h2> <section className="container-wide pb-12 reveal">
<div className="flex flex-wrap gap-2"> <h2 className="text-sm font-medium uppercase tracking-widest mute mb-4">Темы</h2>
{tags.map(t => ( <div className="flex flex-wrap gap-2">
<Link key={t.tag} href={`/tag/${encodeURIComponent(t.tag)}`} className="tag"> {tags.map(t => (
#{t.tag} <span style={{ opacity: 0.6 }}>({t.cnt})</span> <Link key={t.tag} href={`/tag/${encodeURIComponent(t.tag)}`} className="tag">
</Link> #{t.tag} <span style={{ opacity: 0.55 }}>({t.cnt})</span>
))} </Link>
</div> ))}
</section> </div>
</section>
</Reveal>
)} )}
<Footer /> <Footer />
+93 -37
View File
@@ -2,28 +2,108 @@ import Link from 'next/link';
import { formatDate } from '@/lib/markdown'; import { formatDate } from '@/lib/markdown';
import { Clock } from 'lucide-react'; import { Clock } from 'lucide-react';
function imageUrl(article) {
if (!article.cover_url) return null;
return article.cover_url; // /uploads/... проксируется через next.config rewrites
}
// Детерминированный градиент-фоллбек, чтобы у каждой статьи был свой узнаваемый цвет
function gradientFor(article) {
const seed = (article.id || 0) * 31 + (article.title?.length || 0);
const variants = [
'linear-gradient(135deg, #10b981 0%, #0ea5e9 100%)',
'linear-gradient(135deg, #34d399 0%, #14b8a6 100%)',
'linear-gradient(135deg, #059669 0%, #6366f1 100%)',
'linear-gradient(135deg, #10b981 0%, #fbbf24 100%)',
'linear-gradient(135deg, #14b8a6 0%, #a78bfa 100%)',
'linear-gradient(135deg, #047857 0%, #0891b2 100%)',
];
return variants[seed % variants.length];
}
function CoverPlaceholder({ article, featured = false }) {
const gradient = gradientFor(article);
return (
<div
className={`relative overflow-hidden ${featured ? 'aspect-[16/8]' : 'aspect-[16/9]'} rounded-xl`}
style={{ background: gradient }}
>
{/* геометрические декорации */}
<div className="absolute -top-10 -right-10 w-40 h-40 rounded-full opacity-30" style={{ background: 'rgba(255,255,255,0.3)' }} />
<div className="absolute -bottom-12 -left-8 w-32 h-32 rounded-full opacity-20" style={{ background: 'rgba(0,0,0,0.2)' }} />
<div className="absolute inset-0 flex items-end p-4">
<div className="text-white/90 text-xs font-mono tracking-wider uppercase">
#{(article.tags?.[0] || 'zeropost')}
</div>
</div>
</div>
);
}
export default function ArticleCard({ article, featured = false }) { export default function ArticleCard({ article, featured = false }) {
const img = imageUrl(article);
if (featured) { if (featured) {
return ( return (
<Link <Link href={`/blog/${article.slug}`} className="article-card block group overflow-hidden p-0">
href={`/blog/${article.slug}`} <div className="grid sm:grid-cols-2 gap-0">
className="article-card block group p-8 sm:p-10" <div className="p-4 sm:p-5">
style={{ borderColor: 'rgb(var(--accent) / 0.3)' }} {img ? (
> <img src={img} alt={article.title} className="w-full aspect-[16/9] object-cover rounded-xl" loading="eager" />
<div className="flex flex-wrap items-center gap-2 mb-4"> ) : (
{(article.tags || []).slice(0, 3).map(t => ( <CoverPlaceholder article={article} featured />
)}
</div>
<div className="p-6 sm:p-8 flex flex-col justify-center">
<div className="flex flex-wrap items-center gap-2 mb-3">
{(article.tags || []).slice(0, 3).map(t => (
<span key={t} className="tag">#{t}</span>
))}
</div>
<h2 className="text-2xl sm:text-3xl font-bold mb-3 leading-tight ink group-hover:accent transition-colors">
{article.title}
</h2>
{article.excerpt && (
<p className="mute leading-relaxed line-clamp-3 mb-4">
{article.excerpt}
</p>
)}
<div className="flex items-center gap-3 text-xs mute">
<span>{formatDate(article.published_at)}</span>
{article.reading_time && (
<span className="inline-flex items-center gap-1">
<Clock className="w-3 h-3" /> {article.reading_time} мин
</span>
)}
</div>
</div>
</div>
</Link>
);
}
return (
<Link href={`/blog/${article.slug}`} className="article-card block group overflow-hidden p-0">
<div className="p-3">
{img ? (
<img src={img} alt={article.title} className="w-full aspect-[16/9] object-cover rounded-lg" loading="lazy" />
) : (
<CoverPlaceholder article={article} />
)}
</div>
<div className="p-5 pt-2">
<div className="flex flex-wrap items-center gap-2 mb-2">
{(article.tags || []).slice(0, 2).map(t => (
<span key={t} className="tag">#{t}</span> <span key={t} className="tag">#{t}</span>
))} ))}
</div> </div>
<h2 className="text-2xl sm:text-3xl font-bold mb-3 leading-tight ink group-hover:accent transition-colors"> <h3 className="text-lg font-semibold mb-2 ink group-hover:accent transition-colors leading-snug line-clamp-2">
{article.title} {article.title}
</h2> </h3>
{article.excerpt && ( {article.excerpt && (
<p className="mute text-base sm:text-lg leading-relaxed line-clamp-3 mb-4"> <p className="mute text-sm line-clamp-2 mb-4">{article.excerpt}</p>
{article.excerpt}
</p>
)} )}
<div className="flex items-center gap-4 text-xs mute"> <div className="flex items-center gap-3 text-xs mute">
<span>{formatDate(article.published_at)}</span> <span>{formatDate(article.published_at)}</span>
{article.reading_time && ( {article.reading_time && (
<span className="inline-flex items-center gap-1"> <span className="inline-flex items-center gap-1">
@@ -31,30 +111,6 @@ export default function ArticleCard({ article, featured = false }) {
</span> </span>
)} )}
</div> </div>
</Link>
);
}
return (
<Link href={`/blog/${article.slug}`} className="article-card block group">
<div className="flex flex-wrap items-center gap-2 mb-3">
{(article.tags || []).slice(0, 2).map(t => (
<span key={t} className="tag">#{t}</span>
))}
</div>
<h3 className="text-lg font-semibold mb-2 ink group-hover:accent transition-colors leading-snug">
{article.title}
</h3>
{article.excerpt && (
<p className="mute text-sm line-clamp-3 mb-4">{article.excerpt}</p>
)}
<div className="flex items-center gap-3 text-xs mute">
<span>{formatDate(article.published_at)}</span>
{article.reading_time && (
<span className="inline-flex items-center gap-1">
<Clock className="w-3 h-3" /> {article.reading_time} мин
</span>
)}
</div> </div>
</Link> </Link>
); );
+70
View File
@@ -0,0 +1,70 @@
'use client';
export default function HeroBackground() {
return (
<div className="absolute inset-0 -z-10 overflow-hidden pointer-events-none">
{/* Mesh gradient — несколько размытых blob'ов с медленной анимацией */}
<div className="hero-blob hero-blob-1" />
<div className="hero-blob hero-blob-2" />
<div className="hero-blob hero-blob-3" />
{/* Сетка точек поверх — тонкий фоновый паттерн */}
<div className="hero-grid" />
{/* Виньетка к низу — плавный переход к контенту */}
<div className="hero-fade" />
<style jsx>{`
.hero-blob {
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.5;
}
.hero-blob-1 {
width: 520px; height: 520px;
background: radial-gradient(circle, rgba(16,185,129,0.6) 0%, transparent 70%);
top: -120px; right: -80px;
animation: blob1 22s ease-in-out infinite alternate;
}
.hero-blob-2 {
width: 420px; height: 420px;
background: radial-gradient(circle, rgba(20,184,166,0.5) 0%, transparent 70%);
top: 50px; left: -60px;
animation: blob2 28s ease-in-out infinite alternate;
}
.hero-blob-3 {
width: 360px; height: 360px;
background: radial-gradient(circle, rgba(132,204,22,0.35) 0%, transparent 70%);
top: 200px; left: 40%;
animation: blob3 25s ease-in-out infinite alternate;
}
@keyframes blob1 {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(-60px, 80px) scale(1.1); }
}
@keyframes blob2 {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(80px, -40px) scale(0.95); }
}
@keyframes blob3 {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(-40px, -60px) scale(1.08); }
}
.hero-grid {
position: absolute;
inset: 0;
background-image: radial-gradient(circle, rgb(var(--ink) / 0.06) 1px, transparent 1px);
background-size: 24px 24px;
mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}
.hero-fade {
position: absolute;
left: 0; right: 0; bottom: 0;
height: 180px;
background: linear-gradient(to bottom, transparent, rgb(var(--bg)));
}
`}</style>
</div>
);
}
+50
View File
@@ -0,0 +1,50 @@
'use client';
import { useEffect, useRef } from 'react';
/**
* Lightweight reveal-on-scroll. Без зависимостей, нативный IntersectionObserver.
* Дочерние элементы с классом `.reveal` плавно появятся.
*/
export default function Reveal({ children, className = '' }) {
const ref = useRef(null);
useEffect(() => {
if (!ref.current) return;
const io = new IntersectionObserver(
entries => {
entries.forEach(e => {
if (e.isIntersecting) {
e.target.classList.add('is-visible');
io.unobserve(e.target);
}
});
},
{ threshold: 0.1, rootMargin: '0px 0px -50px 0px' }
);
ref.current.querySelectorAll('.reveal').forEach(el => io.observe(el));
return () => io.disconnect();
}, []);
return (
<div ref={ref} className={className}>
<style jsx global>{`
.reveal {
opacity: 0;
transform: translateY(20px);
transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.reveal.is-visible {
opacity: 1;
transform: translateY(0);
}
.reveal-1 { transition-delay: 0.05s; }
.reveal-2 { transition-delay: 0.15s; }
.reveal-3 { transition-delay: 0.25s; }
@media (prefers-reduced-motion: reduce) {
.reveal { opacity: 1; transform: none; transition: none; }
}
`}</style>
{children}
</div>
);
}
+42
View File
@@ -0,0 +1,42 @@
import { BookOpen, Clock, Brain, Eye } from 'lucide-react';
function StatCard({ icon: Icon, value, label }) {
return (
<div className="article-card flex items-center gap-4 p-5">
<div
className="w-11 h-11 rounded-lg flex items-center justify-center flex-shrink-0"
style={{ background: 'rgb(var(--accent) / 0.1)' }}
>
<Icon className="w-5 h-5 accent" />
</div>
<div className="min-w-0">
<div className="text-2xl font-bold ink leading-none mb-1 tabular-nums">{value}</div>
<div className="text-xs mute uppercase tracking-wider">{label}</div>
</div>
</div>
);
}
function fmt(n) {
if (!n) return '0';
if (n >= 1_000_000) return (n / 1_000_000).toFixed(1) + 'M';
if (n >= 1_000) return (n / 1_000).toFixed(1) + 'K';
return n.toLocaleString('ru-RU');
}
export default function Stats({ data }) {
if (!data) return null;
return (
<section className="container-wide pb-12">
<h2 className="text-sm font-medium uppercase tracking-widest mute mb-5">
Что уже написал ИИ
</h2>
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
<StatCard icon={BookOpen} value={fmt(data.articles_count)} label="статей" />
<StatCard icon={Clock} value={fmt(data.total_reading_min)} label="минут чтения" />
<StatCard icon={Brain} value={fmt(data.tokens_out)} label="токенов сгенерировано" />
<StatCard icon={Eye} value={fmt(data.total_views)} label="просмотров" />
</div>
</section>
);
}
+8
View File
@@ -37,6 +37,14 @@ export async function listTags() {
return call('/api/articles/tags', { next: { revalidate: 300 } }); return call('/api/articles/tags', { next: { revalidate: 300 } });
} }
export async function getStats() {
try {
return await call('/api/stats', { cache: 'no-store' });
} catch {
return null;
}
}
export async function generateArticle(data) { export async function generateArticle(data) {
return call('/api/articles/generate', { return call('/api/articles/generate', {
method: 'POST', method: 'POST',
+8
View File
@@ -1,4 +1,12 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
module.exports = { module.exports = {
reactStrictMode: true, reactStrictMode: true,
async rewrites() {
return [
{
source: '/uploads/:path*',
destination: `${process.env.ENGINE_URL || 'http://127.0.0.1:3040'}/uploads/:path*`,
},
];
},
}; };