spb/datacenterindex
Public
HTML 53.9%
TypeScript 44.5%
JavaScript 0.6%
SQL 0.5%
1import type { CountrySummary } from "@dci/core";2import { api } from "@/lib/api";3import { routes } from "@/lib/routes";45/** iso2 → canonical country slug (falls back to the iso2, which the API also accepts). */6export async function countrySlugMap(): Promise<{ map: Map<string, string>; countries: CountrySummary[] }> {7 const r = await api.countries();8 const map = new Map<string, string>();9 for (const c of r.items) map.set(c.iso2.toUpperCase(), c.slug);10 return { map, countries: r.items };11}1213export function countryHref(map: Map<string, string>, iso2: string | null | undefined): string | null {14 if (!iso2) return null;15 return routes.country(map.get(iso2.toUpperCase()) ?? iso2.toLowerCase());16}1718/** construction + planned MW when at least one is published; null otherwise (never 0 for unknown). */19export function pipelineMw(m: { constructionMw: number | null; plannedMw: number | null }): number | null {20 if (m.constructionMw === null && m.plannedMw === null) return null;21 return (m.constructionMw ?? 0) + (m.plannedMw ?? 0);22}23