Repository Public
1import type { Metadata } from "next";2import { site } from "./data";3import { getDict, LOCALES, type Locale } from "./i18n";45type PageKey = keyof ReturnType<typeof getDict>["meta"] & ("home" | "live" | "nodes" | "architecture" | "research" | "benchmarks" | "gallery" | "access");67/** Localized title/description, canonical URL, hreflang alternates and an Open Graph preview cut from a real photograph. */8export function pageMetadata(locale: Locale, key: PageKey, path: string, override?: { title?: string; description?: string }): Metadata {9 const t = getDict(locale);10 const m = t.meta[key];11 const title = override?.title ?? m.title;12 const description = override?.description ?? m.description;13 const languages = Object.fromEntries(LOCALES.map((l) => [l === "fr" ? "fr-CA" : "en", `${site.url}/${l}${path}`]));14 return {15 title: key === "home" && !override ? { absolute: title } : title,16 description,17 alternates: { canonical: `${site.url}/${locale}${path}`, languages: { ...languages, "x-default": `${site.url}/en${path}` } },18 openGraph: {19 type: "website",20 siteName: t.meta.siteName,21 title,22 description,23 url: `${site.url}/${locale}${path}`,24 locale: locale === "fr" ? "fr_CA" : "en_CA",25 images: [{ url: "/og.jpg", width: 1200, height: 630, alt: locale === "fr" ? "Étagère de Mac Studio et de Mac mini du cluster MacLustr" : "Shelving unit of Mac Studio and Mac mini machines in the MacLustr cluster" }],26 },27 twitter: { card: "summary_large_image", title, description, images: ["/og.jpg"] },28 };29}30