import { getPageStructuredSchemas } from "../../lib/seo";
import StructuredData from "./StructuredData";

function buildSchemaId(pathname) {
  return `${pathname.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "") || "home"}-seo-schema`;
}

export default async function PageSeoStructuredData({ pathname }) {
  const schemaData = await getPageStructuredSchemas(pathname);

  return <StructuredData id={buildSchemaId(pathname)} data={schemaData} />;
}
