import type { TopicId } from './types'; /** * Static mirror of `registry/topics.yaml` (id, name, short, order, blurb). The API is the source of truth for * indicator membership and counts; this list exists so navigation, the home grid and metadata never need a * fetch. Keep in sync when the registry changes (19 topics, fixed set — ARCHITECTURE §4). */ export interface TopicDef { id: TopicId; name: string; short: string; order: number; blurb: string; } export const TOPICS: readonly TopicDef[] = [ { id: 'economy', name: 'Economy', short: 'Economy', order: 1, blurb: 'Output, growth, prices, productivity and external balance.' }, { id: 'government', name: 'Government & public finance', short: 'Government', order: 2, blurb: 'Public debt, deficits, revenue, spending and taxation.' }, { id: 'population', name: 'Population & demographics', short: 'Population', order: 3, blurb: 'Size, growth, ages, births, deaths, urbanisation and migration.' }, { id: 'labor', name: 'Employment & wages', short: 'Labor', order: 4, blurb: 'Unemployment, participation, employment, youth, wages and hours.' }, { id: 'income', name: 'Income & inequality', short: 'Income', order: 5, blurb: 'Living standards, poverty and distribution.' }, { id: 'housing', name: 'Housing', short: 'Housing', order: 6, blurb: 'Prices, rents, affordability, mortgages and construction.' }, { id: 'health', name: 'Health', short: 'Health', order: 7, blurb: 'Longevity, mortality, health system capacity and risk factors.' }, { id: 'education', name: 'Education', short: 'Education', order: 8, blurb: 'Literacy, enrolment, attainment and spending.' }, { id: 'trade', name: 'Trade', short: 'Trade', order: 9, blurb: 'Exports, imports, balances, openness and composition.' }, { id: 'energy', name: 'Energy', short: 'Energy', order: 10, blurb: 'Generation, consumption, mix, dependence and intensity.' }, { id: 'climate', name: 'Climate', short: 'Climate', order: 11, blurb: 'Greenhouse gases, intensity and temperature contribution.' }, { id: 'environment', name: 'Environment', short: 'Environment', order: 12, blurb: 'Forests, air quality, land, water and protected areas.' }, { id: 'infrastructure', name: 'Infrastructure & transportation', short: 'Infrastructure', order: 13, blurb: 'Transport networks, passengers, freight and access.' }, { id: 'digital', name: 'Digital economy & Internet', short: 'Digital', order: 14, blurb: 'Connectivity, adoption and digital infrastructure.' }, { id: 'innovation', name: 'Innovation, research & technology', short: 'Innovation', order: 15, blurb: 'R&D, patents, publications, researchers and high-tech.' }, { id: 'agriculture', name: 'Agriculture & natural resources', short: 'Agriculture', order: 16, blurb: 'Land, production, employment and resource rents.' }, { id: 'tourism', name: 'Tourism', short: 'Tourism', order: 17, blurb: 'Arrivals, departures and tourism receipts.' }, { id: 'security', name: 'Security & governance', short: 'Security', order: 18, blurb: 'Homicide, military spending, refugees, displacement and institutions.' }, { id: 'quality-of-life', name: 'Quality of life', short: 'Quality of life', order: 19, blurb: 'Human development, happiness, safety, access and environment.' }, ]; const BY_ID = new Map(TOPICS.map((tp) => [tp.id, tp])); export function topicById(id: string): TopicDef | undefined { return BY_ID.get(id as TopicId); } export function isTopicId(id: string): id is TopicId { return BY_ID.has(id as TopicId); } /** Headline indicators on the country overview, in order (registry/topics.yaml `headline`). */ export const HEADLINE_INDICATORS = [ 'population', 'gdp', 'gdp-per-capita', 'gdp-growth', 'inflation', 'unemployment-rate', 'life-expectancy', 'median-age', 'general-government-gross-debt-pct-gdp', 'co2-per-capita', 'renewable-electricity-share', 'internet-users', ] as const; /** Indicator slug → topic id fallback (used to build `/countries/[slug]/[topic]#indicator` links for headline metrics). */ export const HEADLINE_TOPIC: Record<(typeof HEADLINE_INDICATORS)[number], TopicId> = { population: 'population', gdp: 'economy', 'gdp-per-capita': 'economy', 'gdp-growth': 'economy', inflation: 'economy', 'unemployment-rate': 'labor', 'life-expectancy': 'health', 'median-age': 'population', 'general-government-gross-debt-pct-gdp': 'government', 'co2-per-capita': 'climate', 'renewable-electricity-share': 'energy', 'internet-users': 'digital', };