export const SITE_NAME = "GitDataAi";
export const DEFAULT_SITE_URL = "http://localhost:5173";
export const DEFAULT_OG_IMAGE = "/logo.png";
export const SITE_TWITTER = "@gtdataai";

export const getSiteUrl = () => {
  const envSiteUrl = import.meta.env.VITE_SITE_URL;
  if (!envSiteUrl) {
    return DEFAULT_SITE_URL;
  }
  return envSiteUrl.endsWith("/") ? envSiteUrl.slice(0, -1) : envSiteUrl;
};

export const toAbsoluteUrl = (path: string) => {
  if (path.startsWith("http://") || path.startsWith("https://")) {
    return path;
  }
  const normalizedPath = path.startsWith("/") ? path : `/${path}`;
  return `${getSiteUrl()}${normalizedPath}`;
};

export const getWebsiteSchema = () => {
  const siteUrl = getSiteUrl();
  return {
    "@context": "https://schema.org",
    "@type": "WebSite",
    name: SITE_NAME,
    url: siteUrl,
  };
};
