"use client"; import {useState,useEffect} from 'react'; import Link from 'next/link'; import {trackGoal} from '../lib/metrika.mjs'; import {formatDate} from '../lib/dates.mjs'; export default function Catalog({articles}){const [q,setQ]=useState(''),[topic,setTopic]=useState('Все');const topics=['Все',...new Set(articles.flatMap(a=>a.categories))];const shown=articles.filter(a=>(topic==='Все'||a.categories.includes(topic))&&(a.title+' '+a.excerpt+' '+a.categories.join(' ')).toLocaleLowerCase('ru').includes(q.toLocaleLowerCase('ru')));useEffect(()=>{if(!q.trim()||shown.length)return;const timer=setTimeout(()=>trackGoal('search_zero_results'),500);return()=>clearTimeout(timer);},[q,shown.length]);return

ПОЛНЫЙ ИНДЕКС

Статьи и заметки

{articles.length} материалов
{topics.map(t=>)}

{shown.length?`Найдено материалов: ${shown.length}`:'По этому запросу ничего нет. Попробуйте другое слово или сбросьте тему.'}

{shown.map(a=>
{a.categories.join(' · ')}
{if(e.isTrusted&&q.trim())trackGoal('search_used');}} href={'/articles/'+encodeURIComponent(a.slug)+'/'}>

{a.title}

{a.excerpt}

{a.readingMinutes} мин
)}
{!shown.length&&}
}