; // 2. Функция обработки текста в JSON-LD const lines = rawData.trim().split('\n'); const items = lines.map((line, index) => { // Регулярное выражение для очистки: убираем номер в начале и цену в конце const cleanLine = line.trim().replace(/^\d+\s+/, ''); // Убираем порядковый номер const parts = cleanLine.split(/\s{2,}/); // Делим по большим пробелам const sku = parts[0]; // Артикул const name = parts[1]; // Название и описание return { "@type": "ListItem", "position": index + 1, "item": { "@type": "Product", "name": name, "sku": sku, "brand": { "@type": "Brand", "name": "НАШИ ИНСТРУМЕНТЫ" }, "description": name // Используем название как описание } }; }); // 3. Создаем финальный объект const schema = { "@context": "https://schema.org", "@type": "CollectionPage", "name": "Полный каталог микрохирургических инструментов", "mainEntity": { "@type": "ItemList", "numberOfItems": items.length, "itemListElement": items } }; // 4. Внедряем скрипт в head страницы const script = document.createElement('script'); script.type = 'application/ld+json'; script.text = JSON.stringify(schema); document.head.appendChild(script); })();