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