import { config } from './config';

const getSiteUrl = () => {
  if (process.env.CI) return 'http://klz.localhost';
  return (config.baseUrl as string) || 'https://klz-cables.com';
};

export const SITE_URL = getSiteUrl();
export const LOGO_URL = `${SITE_URL}/logo.png`;

export const getOrganizationSchema = () => ({
  '@context': 'https://schema.org' as const,
  '@type': 'Organization' as const,
  name: 'KLZ Cables',
  url: SITE_URL,
  logo: LOGO_URL,
  sameAs: ['https://www.linkedin.com/company/klz-cables'],
  contactPoint: {
    '@type': 'ContactPoint' as const,
    telephone: '+49-881-92537298',
    contactType: 'customer service' as const,
    email: 'info@klz-cables.com',
    availableLanguage: ['German', 'English'],
  },
});

export const getBreadcrumbSchema = (items: { name: string; item: string }[]) => ({
  '@context': 'https://schema.org' as const,
  '@type': 'BreadcrumbList' as const,
  itemListElement: items.map((item, index) => ({
    '@type': 'ListItem' as const,
    position: index + 1,
    name: item.name,
    item: item.item.startsWith('http') ? item.item : `${SITE_URL}${item.item}`,
  })),
});
