// Динамический sitemap из всех 6 коллекций import { getCollection } from 'astro:content'; const BASE = 'https://нейросети.рус'; function lastmod(dateStr) { if (!dateStr) return new Date().toISOString().split('T')[0]; const d = typeof dateStr === 'string' ? new Date(dateStr) : dateStr; return d.toISOString().split('T')[0]; } const pages = [ { url: '/', priority: '1.0' }, { url: '/examples/', priority: '0.9' }, { url: '/models/', priority: '0.9' }, { url: '/compare/', priority: '0.8' }, { url: '/news/', priority: '0.8' }, { url: '/guide/', priority: '0.8' }, { url: '/ace-studio/', priority: '0.8' }, ]; export async function GET() { const collections = ['examples', 'models', 'compare', 'news', 'guide', 'aceStudio']; for (const name of collections) { try { const items = await getCollection(name); for (const item of items) { const slug = name === 'aceStudio' ? 'ace-studio' : name; pages.push({ url: `/${slug}/${item.slug}/`, priority: '0.7', lastmod: lastmod(item.data.date), }); } } catch (e) { // коллекция может быть пустой } } const xml = ` ${pages.map(p => ` ${BASE}${p.url}${p.priority}${p.lastmod ? `${p.lastmod}` : ''}` ).join('\n')} `; return new Response(xml, { headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, max-age=86400', }, }); }