import type { Profile, Project } from "@/lib/models";
import { site } from "@/content/site";

export function JsonLd({
  profile,
  featured,
}: {
  profile: Profile;
  featured: Project[];
}) {
  const graph = {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "Person",
        name: profile.realName,
        alternateName: profile.handle,
        url: site.url,
        description: profile.role,
        knowsAbout: featured.map((f) => f.category).filter((v, i, a) => a.indexOf(v) === i),
      },
      {
        "@type": "WebSite",
        url: site.url,
        name: "eldov.win",
        inLanguage: ["de", "en"],
        author: { "@type": "Person", name: profile.realName },
      },
      ...featured.map((f) => ({
        "@type": "CreativeWork",
        name: f.slug,
        url: `${site.url}/projekte/${f.slug}`,
        about: f.category,
        keywords: f.stack,
        abstract: f.summary,
      })),
    ],
  };
  return (
    <script
      type="application/ld+json"
      dangerouslySetInnerHTML={{ __html: JSON.stringify(graph) }}
    />
  );
}
