interface ServiceParams {
  name: string;
  serviceType: string;
  description: string;
  url: string;
}

export const useServiceSchema = ({
  name,
  serviceType,
  description,
  url,
}: ServiceParams) => {
  const config = useRuntimeConfig();
  const siteUrl = config.public.BASE_URL;

  const toAbs = (path: string) => new URL(path, siteUrl).toString();

  useSchemaOrg([
    {
      "@type": "Service",
      "@id": `${toAbs(url)}#service`,
      name: name,
      serviceType: serviceType,
      description: description,
      provider: {
        "@id": "https://webstdy.com/#identity",
      },
      areaServed: [
        { "@type": "Country", name: "Egypt" },
        { "@type": "Country", name: "Saudi Arabia" },
        { "@type": "AdministrativeArea", name: "Worldwide" },
      ],
      url: toAbs(url),
    },
  ]);
};
