interface StructuredDataProps {
  data: Record<string, any>;
}

export function StructuredData({ data }: StructuredDataProps) {
  return (
    <script type="application/ld+json">
      {JSON.stringify(data)}
    </script>
  );
}

// Önceden tanımlanmış structured data şablonları
export const structuredDataTemplates = {
  organization: (name: string, url: string, logo?: string, sameAs?: string[]) => ({
    '@context': 'https://schema.org',
    '@type': 'Organization',
    name,
    url,
    ...(logo && { logo }),
    ...(sameAs && { sameAs }),
  }),

  website: (name: string, url: string, searchUrl?: string) => ({
    '@context': 'https://schema.org',
    '@type': 'WebSite',
    name,
    url,
    ...(searchUrl && {
      potentialAction: {
        '@type': 'SearchAction',
        target: `${searchUrl}?q={search_term_string}`,
        'query-input': 'required name=search_term_string',
      },
    }),
  }),

  breadcrumb: (items: Array<{ name: string; url: string }>) => ({
    '@context': 'https://schema.org',
    '@type': 'BreadcrumbList',
    itemListElement: items.map((item, index) => ({
      '@type': 'ListItem',
      position: index + 1,
      name: item.name,
      item: item.url,
    })),
  }),

  article: (
    headline: string,
    description: string,
    image: string,
    datePublished: string,
    dateModified: string,
    author: string
  ) => ({
    '@context': 'https://schema.org',
    '@type': 'Article',
    headline,
    description,
    image,
    datePublished,
    dateModified,
    author: {
      '@type': 'Person',
      name: author,
    },
  }),

  touristAttraction: (
    name: string,
    description: string,
    image: string,
    address: {
      streetAddress?: string;
      addressLocality: string;
      addressRegion?: string;
      addressCountry: string;
    },
    geo?: {
      latitude: number;
      longitude: number;
    }
  ) => ({
    '@context': 'https://schema.org',
    '@type': 'TouristAttraction',
    name,
    description,
    image,
    address: {
      '@type': 'PostalAddress',
      ...address,
    },
    ...(geo && {
      geo: {
        '@type': 'GeoCoordinates',
        latitude: geo.latitude,
        longitude: geo.longitude,
      },
    }),
  }),

  trip: (
    name: string,
    description: string,
    startDate: string,
    endDate: string,
    location: string
  ) => ({
    '@context': 'https://schema.org',
    '@type': 'Trip',
    name,
    description,
    startDate,
    endDate,
    itinerary: {
      '@type': 'Place',
      name: location,
    },
  }),
};
