import { site } from "@/content/site";
import { absoluteUrl } from "@/lib/seo";

export function JsonLd() {
  const eventSchema = {
    "@context": "https://schema.org",
    "@type": "Event",
    name: site.name,
    description: site.tagline,
    startDate: site.dates.start,
    endDate: site.dates.end,
    eventAttendanceMode: "https://schema.org/OfflineEventAttendanceMode",
    eventStatus: "https://schema.org/EventScheduled",
    location: {
      "@type": "Place",
      name: site.venue.name,
      address: {
        "@type": "PostalAddress",
        streetAddress: site.venue.address,
        addressLocality: "Addis Ababa",
        addressCountry: "ET",
      },
    },
    organizer: {
      "@type": "Organization",
      name: site.presentedBy,
      url: absoluteUrl("/"),
    },
    image: absoluteUrl("/branding/logo.png"),
    url: absoluteUrl("/"),
  };

  const organizationSchema = {
    "@context": "https://schema.org",
    "@type": "Organization",
    name: site.presentedBy,
    url: absoluteUrl("/"),
    logo: absoluteUrl("/branding/logo-icon.png"),
  };

  const websiteSchema = {
    "@context": "https://schema.org",
    "@type": "WebSite",
    name: site.name,
    url: absoluteUrl("/"),
    description: site.tagline,
  };

  return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(eventSchema) }}
      />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationSchema) }}
      />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(websiteSchema) }}
      />
    </>
  );
}
