import type { Metadata } from "next";

const siteName = "Funktechnik Schubert";
const defaultTitle = "Funktechnik Schubert | Funkgeräte-Service & Messtechnik";
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? "http://127.0.0.1:3010";
const keywords = [
  "Funktechnik Schubert",
  "Funkgeräte Reparatur",
  "CB Funk Service",
  "Amateurfunk Service",
  "Funkgeräte Abgleich",
  "Funkgeräte Diagnose",
  "Messtechnik",
  "Funktechnik Service",
  "Kommunikationstechnik",
  "Service Manual",
  "Schaltplan",
  "Funkwerkstatt",
  "Reparaturannahme",
];

export function createMetadata(title: string, description: string, path = "/"): Metadata {
  const url = new URL(path, siteUrl).toString();
  const fullTitle = title === siteName ? title : `${title} | ${siteName}`;

  return {
    metadataBase: new URL(siteUrl),
    title: title === siteName ? { default: defaultTitle, template: `%s | ${siteName}` } : fullTitle,
    applicationName: siteName,
    description,
    keywords,
    icons: {
      icon: [
        { url: "/favicon.ico", sizes: "any" },
        { url: "/favicon-16x16.png", sizes: "16x16", type: "image/png" },
        { url: "/favicon-32x32.png", sizes: "32x32", type: "image/png" },
      ],
      apple: [{ url: "/apple-touch-icon.png", sizes: "180x180", type: "image/png" }],
    },
    alternates: {
      canonical: url,
    },
    openGraph: {
      type: "website",
      locale: "de_DE",
      url,
      siteName,
      title: fullTitle,
      description,
      images: [
        {
          url: "/funktechnik_schubert_logo.jpg",
          width: 1672,
          height: 941,
          alt: siteName,
        },
      ],
    },
  };
}

export { defaultTitle, siteName, siteUrl };
