import { EMAIL, PHONE_E164, SITE_NAME, SITE_URL } from "@/lib/site"; import { EINSATZGEBIET } from "@/lib/leistungen"; /** Gemeinsame Open-Graph-Felder; Unterseiten überschreiben openGraph komplett, daher überall einbinden. */ export const OG_COMMON = { type: "website" as const, locale: "de_DE", siteName: SITE_NAME, images: [{ url: "/og", width: 1200, height: 630, alt: "MBO-Tech-IT – IT-Service in Crailsheim" }], }; const ORG_ID = `${SITE_URL}/#organization`; type Crumb = { name: string; path: string }; export function breadcrumbSchema(crumbs: Crumb[]) { return { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [{ name: "Startseite", path: "/" }, ...crumbs].map((c, i) => ({ "@type": "ListItem", position: i + 1, name: c.name, item: `${SITE_URL}${c.path === "/" ? "" : c.path}`, })), }; } interface ServiceInput { name: string; description: string; path: string; /** Optional: Preis in EUR (z. B. "89") für ein Offer */ price?: string; /** true, wenn der Preis ein „ab“-Preis ist */ priceFrom?: boolean; } export function serviceSchema({ name, description, path, price, priceFrom }: ServiceInput) { return { "@context": "https://schema.org", "@type": "Service", name, description, url: `${SITE_URL}${path}`, provider: { "@id": ORG_ID }, areaServed: EINSATZGEBIET.map((name) => ({ "@type": "City", name })), ...(price && { offers: { "@type": "Offer", priceCurrency: "EUR", ...(priceFrom ? { priceSpecification: { "@type": "PriceSpecification", priceCurrency: "EUR", minPrice: price } } : { price }), availability: "https://schema.org/InStock", }, }), }; } const TAGE: Record = { mo: "Monday", di: "Tuesday", mi: "Wednesday", do: "Thursday", fr: "Friday", sa: "Saturday", so: "Sunday", }; const TAG_REIHE = ["mo", "di", "mi", "do", "fr", "sa", "so"]; /** Wandelt z. B. „Mo – Fr“, „Montag bis Freitag“ oder „Sa“ in schema.org-Wochentage um. Unbekanntes → []. */ export function parseTage(tag: string): string[] { if (tag.includes(",")) return []; const teile = tag .toLowerCase() .split(/\s*(?:–|-|bis)\s*/) .map((t) => t.trim().slice(0, 2)) .filter(Boolean); if (teile.length === 1 && TAGE[teile[0]]) return [TAGE[teile[0]]]; if (teile.length === 2) { const a = TAG_REIHE.indexOf(teile[0]); const b = TAG_REIHE.indexOf(teile[1]); if (a >= 0 && b >= a) return TAG_REIHE.slice(a, b + 1).map((t) => TAGE[t]); } return []; } const UHRZEIT = /^\d{1,2}:\d{2}$/; interface LocalBusinessInput { oeffnungszeiten?: { tag: string; von: string; bis: string }[]; /** Profile wie Google, LinkedIn, Instagram – stärkt die Zuordnung der Marke */ sameAs?: string[]; } export function localBusinessSchema({ oeffnungszeiten = [], sameAs = [] }: LocalBusinessInput = {}) { const openingHoursSpecification = oeffnungszeiten.flatMap((oz) => { const tage = parseTage(oz.tag); const von = oz.von.trim().replace(/\s*uhr$/i, "").replace(".", ":"); const bis = oz.bis.trim().replace(/\s*uhr$/i, "").replace(".", ":"); if (!tage.length || !UHRZEIT.test(von) || !UHRZEIT.test(bis)) return []; return [{ "@type": "OpeningHoursSpecification", dayOfWeek: tage, opens: von, closes: bis }]; }); return { "@context": "https://schema.org", "@graph": [ { "@type": ["LocalBusiness", "ProfessionalService"], "@id": ORG_ID, name: SITE_NAME, description: "IT-Dienstleister in Crailsheim für Privat- und Geschäftskunden: WLAN und Netzwerk, Datensicherung, Zero-Trust-VPN, Nextcloud und Paperless-ngx, Familienschutz, Server und Webseiten.", url: SITE_URL, image: `${SITE_URL}/og`, logo: `${SITE_URL}/icon`, telephone: PHONE_E164, email: EMAIL, founder: { "@type": "Person", name: "Markus Butz" }, ...(openingHoursSpecification.length > 0 && { openingHoursSpecification }), ...(sameAs.length > 0 && { sameAs }), address: { "@type": "PostalAddress", streetAddress: "Mörikestr. 2", addressLocality: "Crailsheim", postalCode: "74564", addressRegion: "Baden-Württemberg", addressCountry: "DE", }, geo: { "@type": "GeoCoordinates", latitude: 49.1374, longitude: 10.0695 }, areaServed: [ ...EINSATZGEBIET.map((name) => ({ "@type": "City", name })), { "@type": "AdministrativeArea", name: "Landkreis Schwäbisch Hall" }, { "@type": "GeoCircle", geoMidpoint: { "@type": "GeoCoordinates", latitude: 49.1374, longitude: 10.0695 }, geoRadius: "100000" }, ], knowsAbout: [ "WLAN", "Netzwerk", "Datensicherung", "Zero-Trust-VPN", "Nextcloud", "Paperless-ngx", "Docker", "Proxmox", "Hetzner Cloud", "IT-Sicherheit", "Linux", ], contactPoint: { "@type": "ContactPoint", contactType: "customer service", telephone: PHONE_E164, email: EMAIL, availableLanguage: "German", }, hasOfferCatalog: { "@type": "OfferCatalog", name: "IT-Leistungen", itemListElement: [ { "@type": "Offer", itemOffered: { "@type": "Service", name: "MBO FamilyGuard Familienschutz", url: `${SITE_URL}/pakete/familyguard` } }, { "@type": "Offer", itemOffered: { "@type": "Service", name: "Nextcloud + Paperless-ngx Dokumentenarchiv", url: `${SITE_URL}/pakete/nextcloud` } }, { "@type": "Offer", itemOffered: { "@type": "Service", name: "Zero-Trust-VPN (Netbird)", url: `${SITE_URL}/pakete/vpn` } }, { "@type": "Offer", itemOffered: { "@type": "Service", name: "IT-Leistungen für Privat- und Geschäftskunden", url: `${SITE_URL}/services` } }, ], }, }, { "@type": "WebSite", "@id": `${SITE_URL}/#website`, url: SITE_URL, name: SITE_NAME, inLanguage: "de-DE", publisher: { "@id": ORG_ID }, }, ], }; } /** FAQPage-Schema: nur für FAQs, die auch sichtbar auf der Seite stehen. */ export function faqSchema(faq: { frage: string; antwort: string }[]) { return { "@context": "https://schema.org", "@type": "FAQPage", mainEntity: faq.map((f) => ({ "@type": "Question", name: f.frage, acceptedAnswer: { "@type": "Answer", text: f.antwort }, })), }; }