import { definePerson, defineOrganization } from "nuxt-schema-org/schema";
import type { Settings } from "~/types/Contact";

export const useAboutSchema = (settings = {} as Settings, t: any) => {
  const localPath = useLocalePath();
  const config = useRuntimeConfig();
  const siteUrl = config.public.BASE_URL;

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

  const socialLinks = [
    settings?.facebook_link,
    settings?.instagram_link,
    settings?.tiktok_link,
    settings?.X_link,
    settings?.linkedIn_link,
    settings?.snapchat_link,
    settings?.youtube_link,
  ].filter(Boolean);

  useSchemaOrg([
    {
      "@type": "AboutPage",
      name: t("about"),
      description: t("aboutSeo.description"),
    },
    definePerson({
      "@id": `${toAbs(localPath("/about"))}#ceo`,
      name: "Mahmoud Nabil",
      jobTitle: "CEO",
      worksFor: {
        "@id": "https://webstdy.com/#identity",
      },
      image: {
        "@type": "ImageObject",
        url: "https://webstdy.com/images/about-img.png",
      },
      sameAs: socialLinks,
    }),
    // Reinforce Organization data on About page
    defineOrganization({
      "@id": "https://webstdy.com/#identity",
      name: "WebSTDY",
      url: localPath("https://webstdy.com/"),
      logo:
        settings?.light_logo ||
        "https://webstdy.com/web/img/2022/new-share-image.png",
      description: t("homeSeo.description"),
    }),
  ]);
};
