feat: comprehensive SEO system with keywords and schema markup
- Add 4-locale keyword configurations (SR, EN, DE, FR) - Create schema generators (Product, Organization, Breadcrumb) - Add React components for JSON-LD rendering - Implement caching for keyword performance - Abstract all SEO logic for maintainability
This commit is contained in:
67
src/components/seo/ProductSchema.tsx
Normal file
67
src/components/seo/ProductSchema.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import { JsonLd } from './JsonLd';
|
||||
import { generateProductSchema, generateCategorizedProductSchema } from '@/lib/seo/schema/productSchema';
|
||||
import { generateProductBreadcrumbs } from '@/lib/seo/schema/breadcrumbSchema';
|
||||
import { Locale } from '@/lib/seo/keywords/types';
|
||||
|
||||
interface ProductSchemaProps {
|
||||
baseUrl: string;
|
||||
locale: Locale;
|
||||
product: {
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
images: string[];
|
||||
price: {
|
||||
amount: number;
|
||||
currency: string;
|
||||
};
|
||||
sku?: string;
|
||||
availability?: 'InStock' | 'OutOfStock' | 'PreOrder';
|
||||
};
|
||||
category?: 'antiAging' | 'hydration' | 'glow' | 'sensitive' | 'natural' | 'organic';
|
||||
rating?: {
|
||||
value: number;
|
||||
count: number;
|
||||
};
|
||||
includeBreadcrumbs?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product schema component
|
||||
* Renders Product + BreadcrumbList JSON-LD schemas
|
||||
*
|
||||
* @param baseUrl - Site base URL
|
||||
* @param locale - Current locale
|
||||
* @param product - Product data object
|
||||
* @param category - Optional category for enhanced targeting
|
||||
* @param rating - Optional aggregate rating data
|
||||
* @param includeBreadcrumbs - Whether to include breadcrumb schema (default: true)
|
||||
*/
|
||||
export function ProductSchema({
|
||||
baseUrl,
|
||||
locale,
|
||||
product,
|
||||
category,
|
||||
rating,
|
||||
includeBreadcrumbs = true,
|
||||
}: ProductSchemaProps) {
|
||||
// Generate product schema
|
||||
const productSchema = category
|
||||
? generateCategorizedProductSchema(baseUrl, locale, { ...product, rating }, category)
|
||||
: generateProductSchema(baseUrl, locale, { ...product, rating });
|
||||
|
||||
// Generate breadcrumbs if requested
|
||||
if (includeBreadcrumbs) {
|
||||
const breadcrumbSchema = generateProductBreadcrumbs(
|
||||
baseUrl,
|
||||
locale,
|
||||
product.name,
|
||||
product.slug
|
||||
);
|
||||
return <JsonLd data={[productSchema, breadcrumbSchema]} />;
|
||||
}
|
||||
|
||||
return <JsonLd data={productSchema} />;
|
||||
}
|
||||
|
||||
export default ProductSchema;
|
||||
Reference in New Issue
Block a user