Добавлена микроразметка для улучшения SEO на страницах каталога, карточки товара, о компании и контактов. Внедрены схемы Organization, Product, BreadcrumbList и LocalBusiness для соответствующих страниц. Обновлены компоненты для поддержки новых атрибутов микроразметки.

This commit is contained in:
Bivekich
2025-07-06 18:46:00 +03:00
parent 2b5f787fbe
commit 8284385e3c
9 changed files with 399 additions and 10 deletions

View File

@ -1,5 +1,7 @@
import MetaTags from "../components/MetaTags";
import { getMetaByPath, createProductMeta } from "../lib/meta-config";
import JsonLdScript from "@/components/JsonLdScript";
import { generateProductSchema, convertAvailability, type SchemaOrgProduct } from "@/lib/schema";
import { useRouter } from "next/router";
import { useEffect, useState, useMemo } from "react";
import { useQuery, useLazyQuery } from "@apollo/client";
@ -199,6 +201,30 @@ export default function CardPage() {
price: allOffers.length > 0 ? Math.min(...allOffers.map(offer => offer.sortPrice)) : undefined
}) : getMetaByPath('/card');
// Генерируем микроразметку Product
const productSchema = useMemo(() => {
if (!result || allOffers.length === 0) return null;
const schemaProduct: SchemaOrgProduct = {
name: result.name,
description: `${result.brand} ${result.articleNumber} - ${result.name}`,
brand: result.brand,
sku: result.articleNumber,
image: mainImageUrl || (result?.partsIndexImages && result.partsIndexImages.length > 0 ? result.partsIndexImages[0].url : undefined),
category: "Автозапчасти",
offers: allOffers.map(offer => ({
price: offer.sortPrice,
currency: "RUB",
availability: convertAvailability(offer.quantity || 0),
seller: offer.type === 'internal' ? 'Protek' : 'AutoEuro',
deliveryTime: offer.deliveryTime ? `${offer.deliveryTime} дней` : undefined,
warehouse: offer.warehouse || 'Склад'
}))
};
return generateProductSchema(schemaProduct);
}, [result, allOffers, mainImageUrl]);
if (loading) {
return (
<>
@ -226,6 +252,7 @@ export default function CardPage() {
ogTitle={metaConfig.ogTitle}
ogDescription={metaConfig.ogDescription}
/>
{productSchema && <JsonLdScript schema={productSchema} />}
<InfoCard
brand={result ? result.brand : brandQuery}
articleNumber={result ? result.articleNumber : searchQuery}