import React from 'react' import { Head } from '@inertiajs/react' function normalizeJsonLd(input) { if (!input) return [] return (Array.isArray(input) ? input : [input]).filter((schema) => schema && typeof schema === 'object') } export default function SeoHead({ seo = {}, title = null, description = null, jsonLd = null }) { const metaTitle = seo?.title || title || 'Skinbase' const metaDescription = seo?.description || description || '' const canonical = seo?.canonical || null const robots = seo?.robots || null const prev = seo?.prev || null const next = seo?.next || null const ogTitle = seo?.og_title || metaTitle const ogDescription = seo?.og_description || metaDescription const ogUrl = seo?.og_url || canonical const ogType = seo?.og_type || 'website' const ogImage = seo?.og_image || null const keywords = seo?.keywords || null const twitterCard = seo?.twitter_card || (ogImage ? 'summary_large_image' : 'summary') const twitterTitle = seo?.twitter_title || ogTitle const twitterDescription = seo?.twitter_description || ogDescription const twitterImage = seo?.twitter_image || ogImage || null const schemas = [...normalizeJsonLd(seo?.json_ld), ...normalizeJsonLd(jsonLd)] return ( {metaTitle} {metaDescription ? : null} {keywords ? : null} {robots ? : null} {canonical ? : null} {prev ? : null} {next ? : null} {ogDescription ? : null} {ogUrl ? : null} {ogImage ? : null} {seo?.og_image_alt ? : null} {twitterDescription ? : null} {twitterImage ? : null} {schemas.map((schema, index) => { const schemaType = typeof schema?.['@type'] === 'string' ? schema['@type'] : 'schema' return ( ) })} ) }