import { serverApi } from './serverApi.js'; const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://top-sysops.ru'; export const ORGANIZATION_ID = `${SITE_URL}/#organization`; // Единая сущность Organization/LocalBusiness для всего сайта - рендерится один // раз в корневом layout, чтобы на каждой странице был ровно один JSON-LD блок // про компанию, а не несколько дублирующих друг друга. export async function getOrganizationSchema() { const [contact, reviews, services] = await Promise.all([ serverApi.getContact(), serverApi.getReviews(), serverApi.getServices(), ]); return { '@context': 'https://schema.org', '@type': 'LocalBusiness', '@id': ORGANIZATION_ID, name: 'TopSysOps', url: SITE_URL, foundingDate: '2023', numberOfEmployees: { '@type': 'QuantitativeValue', minValue: 20 }, ...(contact?.address ? { address: { '@type': 'PostalAddress', streetAddress: contact.address, addressCountry: 'RU' } } : {}), ...(contact?.phone ? { telephone: contact.phone } : {}), ...(contact?.email ? { email: contact.email } : {}), ...(reviews.length > 0 ? { aggregateRating: { '@type': 'AggregateRating', ratingValue: (reviews.reduce((sum, r) => sum + r.rating, 0) / reviews.length).toFixed(1), reviewCount: reviews.length, }, } : {}), ...(services.length > 0 ? { hasOfferCatalog: { '@type': 'OfferCatalog', name: 'Услуги TopSysOps', itemListElement: services.flatMap((cat) => cat.items.map((it) => ({ '@type': 'Offer', itemOffered: { '@type': 'Service', name: it.name, description: it.note || cat.description }, })) ), }, } : {}), }; }