import Link from "next/link" import { fetchSiteInfo } from "@/graphql/queries/getSiteInfo" function normalizePhone(raw: string) { const digits = raw.replace(/[^\d+]/g, "") return digits ? `tel:${digits}` : null } function lines(v: string) { return v.split(/\r?\n/).filter(Boolean) } export default async function SiteInfo() { const page = await fetchSiteInfo() const get = (k: string) => page?.metadata ?.find((m) => m.key.toLowerCase() === k.toLowerCase()) ?.value?.trim() || "" const address = get("Address") const email = get("Email") const phone = get("Phone") const timings = get("Timings") const allEmpty = [address, email, phone, timings].every((v) => !v) if (allEmpty) return null return (
SITE INFO
{address && (
{lines(address).map((l, i) => (
{l}
))}
)} {email && ( {email} )} {phone && (
{(() => { const phLines = lines(phone) const last = phLines[phLines.length - 1] const telHref = normalizePhone(last || phone) return ( <> {phLines.slice(0, -1).map((l, i) => (
{l}
))} {last && telHref ? ( {last} ) : ( last &&
{last}
)} ) })()}
)} {timings && (
{timings}
)}
) }