From 169e36328a9495d5893ef803c4184e2f5b854b00 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Wed, 7 Feb 2024 16:35:57 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=89=20update=20header=20nav=20to?= =?UTF-8?q?=20new=20taxonomy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/SiteNavigation.tsx | 527 ++++++++++++++++++---------------------- 1 file changed, 238 insertions(+), 289 deletions(-) diff --git a/site/SiteNavigation.tsx b/site/SiteNavigation.tsx index 3b12695166f..919a142b896 100644 --- a/site/SiteNavigation.tsx +++ b/site/SiteNavigation.tsx @@ -296,7 +296,7 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { ], }, { - name: "Distribution of the World Population", + name: "Geography of the World Population", slug: "distribution-of-the-world-population", entries: [ { @@ -314,20 +314,7 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { { name: "Health", slug: "health", - entries: [ - { - slug: "tuberculosis", - title: "Tuberculosis", - }, - { - slug: "pandemics", - title: "Pandemics", - }, - { - slug: "cardiovascular-diseases", - title: "Cardiovascular Diseases", - }, - ], + entries: [], subcategories: [ { name: "Health Risks", @@ -337,6 +324,14 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "lead-pollution", title: "Lead Pollution", }, + { + slug: "alcohol-consumption", + title: "Alcohol Consumption", + }, + { + slug: "illicit-drug-use", + title: "Opioids, Cocaine, Cannabis, and Other Illicit Drugs", + }, { slug: "air-pollution", title: "Air Pollution", @@ -357,14 +352,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "smoking", title: "Smoking", }, - { - slug: "alcohol-consumption", - title: "Alcohol Consumption", - }, - { - slug: "illicit-drug-use", - title: "Opioids, Cocaine, Cannabis, and Other Illicit Drugs", - }, ], }, { @@ -372,16 +359,16 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "infectious-diseases", entries: [ { - slug: "influenza", - title: "Influenza", + slug: "coronavirus", + title: "Coronavirus Pandemic (COVID-19)", }, { - slug: "monkeypox", - title: "Mpox (monkeypox)", + slug: "pandemics", + title: "Pandemics", }, { - slug: "coronavirus", - title: "Coronavirus Pandemic (COVID-19)", + slug: "monkeypox", + title: "Mpox (monkeypox)", }, { slug: "hiv-aids", @@ -391,17 +378,17 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "malaria", title: "Malaria", }, - { - slug: "eradication-of-diseases", - title: "Eradication of Diseases", - }, { slug: "diarrheal-diseases", title: "Diarrheal Diseases", }, { - slug: "smallpox", - title: "Smallpox", + slug: "influenza", + title: "Influenza", + }, + { + slug: "tuberculosis", + title: "Tuberculosis", }, { slug: "polio", @@ -415,45 +402,57 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "tetanus", title: "Tetanus", }, + { + slug: "smallpox", + title: "Smallpox", + }, ], }, { name: "Health Institutions and Interventions", slug: "health-institutions-and-interventions", entries: [ + { + slug: "vaccination", + title: "Vaccination", + }, { slug: "financing-healthcare", title: "Healthcare Spending", }, { - slug: "vaccination", - title: "Vaccination", + slug: "eradication-of-diseases", + title: "Eradication of Diseases", }, ], }, { name: "Life and Death", - slug: "life-death-health", + slug: "life-and-death", entries: [ { slug: "life-expectancy", title: "Life Expectancy", }, + { + slug: "causes-of-death", + title: "Causes of Death", + }, { slug: "child-mortality", title: "Child and Infant Mortality", }, { - slug: "maternal-mortality", - title: "Maternal Mortality", + slug: "mental-health", + title: "Mental Health", }, { - slug: "health-meta", - title: "Global Health", + slug: "suicide", + title: "Suicides", }, { - slug: "causes-of-death", - title: "Causes of Death", + slug: "cardiovascular-diseases", + title: "Cardiovascular Diseases", }, { slug: "burden-of-disease", @@ -464,12 +463,12 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { title: "Cancer", }, { - slug: "mental-health", - title: "Mental Health", + slug: "maternal-mortality", + title: "Maternal Mortality", }, { - slug: "suicide", - title: "Suicides", + slug: "health-meta", + title: "Global Health", }, ], }, @@ -481,39 +480,35 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { entries: [], subcategories: [ { - name: "Energy", - slug: "energy", + name: "Energy Systems", + slug: "energy-systems", entries: [ - { - slug: "nuclear-energy", - title: "Nuclear Energy", - }, { slug: "energy-access", title: "Access to Energy", }, { - slug: "energy", - title: "Energy", + slug: "fossil-fuels", + title: "Fossil Fuels", }, { slug: "renewable-energy", title: "Renewable Energy", }, { - slug: "fossil-fuels", - title: "Fossil Fuels", + slug: "energy", + title: "Energy", + }, + { + slug: "nuclear-energy", + title: "Nuclear Energy", }, ], }, { name: "Waste and Pollution", - slug: "waste", + slug: "waste-and-pollution", entries: [ - { - slug: "lead-pollution", - title: "Lead Pollution", - }, { slug: "plastic-pollution", title: "Plastic Pollution", @@ -522,11 +517,15 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "oil-spills", title: "Oil Spills", }, + { + slug: "lead-pollution", + title: "Lead Pollution", + }, ], }, { - name: "Air and Climate", - slug: "air-and-climate", + name: "Climate and Air", + slug: "climate-and-air", entries: [ { slug: "co2-and-greenhouse-gas-emissions", @@ -536,6 +535,10 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "climate-change", title: "Climate Change", }, + { + slug: "ozone-layer", + title: "Ozone Layer", + }, { slug: "air-pollution", title: "Air Pollution", @@ -548,10 +551,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "indoor-air-pollution", title: "Indoor Air Pollution", }, - { - slug: "ozone-layer", - title: "Ozone Layer", - }, ], }, { @@ -577,9 +576,13 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { ], }, { - name: "Land and Ecosystems", + name: "Environment and Ecosystems", slug: "land-and-ecosystems", entries: [ + { + slug: "natural-disasters", + title: "Natural Disasters", + }, { slug: "biodiversity", title: "Biodiversity", @@ -588,6 +591,10 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "environmental-impacts-of-food", title: "Environmental Impacts of Food Production", }, + { + slug: "animal-welfare", + title: "Animal Welfare", + }, { slug: "forests-and-deforestation", title: "Forests and Deforestation", @@ -596,10 +603,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "land-use", title: "Land Use", }, - { - slug: "natural-disasters", - title: "Natural Disasters", - }, ], }, ], @@ -607,12 +610,7 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { { name: "Food and Agriculture", slug: "food", - entries: [ - { - slug: "animal-welfare", - title: "Animal Welfare", - }, - ], + entries: [], subcategories: [ { name: "Nutrition", @@ -622,37 +620,33 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "hunger-and-undernourishment", title: "Hunger and Undernourishment", }, - { - slug: "famines", - title: "Famines", - }, { slug: "food-supply", title: "Food Supply", }, { - slug: "human-height", - title: "Human Height", - }, - { - slug: "micronutrient-deficiency", - title: "Micronutrient Deficiency", + slug: "food-prices", + title: "Food Prices", }, { slug: "diet-compositions", title: "Diet Compositions", }, - { - slug: "food-prices", - title: "Food Prices", - }, { slug: "obesity", title: "Obesity", }, { - slug: "alcohol-consumption", - title: "Alcohol Consumption", + slug: "human-height", + title: "Human Height", + }, + { + slug: "micronutrient-deficiency", + title: "Micronutrient Deficiency", + }, + { + slug: "famines", + title: "Famines", }, ], }, @@ -660,10 +654,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { name: "Food Production", slug: "food-production", entries: [ - { - slug: "farm-size", - title: "Farm Size and Productivity", - }, { slug: "agricultural-production", title: "Agricultural Production", @@ -672,6 +662,10 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "environmental-impacts-of-food", title: "Environmental Impacts of Food Production", }, + { + slug: "animal-welfare", + title: "Animal Welfare", + }, { slug: "crop-yields", title: "Crop Yields", @@ -680,20 +674,16 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "meat-production", title: "Meat and Dairy Production", }, + { + slug: "farm-size", + title: "Farm Size and Productivity", + }, ], }, { name: "Agricultural Inputs", slug: "agricultural-inputs", entries: [ - { - slug: "employment-in-agriculture", - title: "Employment in Agriculture", - }, - { - slug: "land-use", - title: "Land Use", - }, { slug: "fertilizers", title: "Fertilizers", @@ -702,6 +692,14 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "pesticides", title: "Pesticides", }, + { + slug: "employment-in-agriculture", + title: "Employment in Agriculture", + }, + { + slug: "land-use", + title: "Land Use", + }, ], }, ], @@ -716,16 +714,16 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "public-sector", entries: [ { - slug: "government-spending", - title: "Government Spending", + slug: "state-capacity", + title: "State Capacity", }, { slug: "taxation", title: "Taxation", }, { - slug: "military-personnel-spending", - title: "Military Personnel and Spending", + slug: "government-spending", + title: "Government Spending", }, { slug: "financing-healthcare", @@ -735,30 +733,32 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "financing-education", title: "Education Spending", }, + { + slug: "military-personnel-spending", + title: "Military Personnel and Spending", + }, + { + slug: "corruption", + title: "Corruption", + }, ], }, { name: "Poverty and Prosperity", slug: "poverty-and-prosperity", entries: [ - { - slug: "economic-inequality", - title: "Economic Inequality", - }, { slug: "poverty", title: "Poverty", }, + { + slug: "economic-inequality", + title: "Economic Inequality", + }, { slug: "economic-growth", title: "Economic Growth", }, - ], - }, - { - name: "Economic Inequality", - slug: "economic-inequality", - entries: [ { slug: "economic-inequality-by-gender", title: "Economic Inequality by Gender", @@ -784,19 +784,13 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { ], }, { - name: "Corruption", - slug: "corruption", + name: "Global Connections", + slug: "trade-migration", entries: [ { - slug: "corruption", - title: "Corruption", + slug: "tourism", + title: "Tourism", }, - ], - }, - { - name: "Trade and Migration", - slug: "trade-migration", - entries: [ { slug: "migration", title: "Migration", @@ -805,10 +799,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "trade-and-globalization", title: "Trade and Globalization", }, - { - slug: "tourism", - title: "Tourism", - }, ], }, ], @@ -819,7 +809,7 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { entries: [], subcategories: [ { - name: "Educational Access and Outcomes", + name: "Education", slug: "educational-outcomes", entries: [ { @@ -830,16 +820,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "literacy", title: "Literacy", }, - { - slug: "research-and-development", - title: "Research and Development", - }, - ], - }, - { - name: "Inputs to Education", - slug: "inputs-to-education", - entries: [ { slug: "financing-education", title: "Education Spending", @@ -847,17 +827,21 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { ], }, { - name: "Media", - slug: "media-education", + name: "Knowledge", + slug: "inputs-to-education", entries: [ { - slug: "books", - title: "Books", + slug: "research-and-development", + title: "Research and Development", }, { slug: "internet", title: "Internet", }, + { + slug: "books", + title: "Books", + }, ], }, ], @@ -865,86 +849,71 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { { name: "Innovation and Technological Change", slug: "technology", - entries: [], - subcategories: [ + entries: [ + { + slug: "artificial-intelligence", + title: "Artificial Intelligence", + }, + { + slug: "space-exploration-satellites", + title: "Space Exploration and Satellites", + }, + { + slug: "internet", + title: "Internet", + }, + { + slug: "research-and-development", + title: "Research and Development", + }, { - name: "Technological Change", slug: "technological-change", - entries: [ - { - slug: "artificial-intelligence", - title: "Artificial Intelligence", - }, - { - slug: "space-exploration-satellites", - title: "Space Exploration and Satellites", - }, - { - slug: "transport", - title: "Transport", - }, - { - slug: "internet", - title: "Internet", - }, - { - slug: "research-and-development", - title: "Research and Development", - }, - { - slug: "technological-change", - title: "Technological Change", - }, - ], + title: "Technological Change", + }, + { + slug: "transport", + title: "Transport", }, ], + subcategories: [], }, { - name: "Living Conditions, Community and Wellbeing", + name: "Living Conditions, Community, and Wellbeing", slug: "work-life", entries: [], subcategories: [ { - name: "Culture", - slug: "culture", + name: "Housing and Infrastructure", + slug: "housing-and-infrastructure", entries: [ { - slug: "trust", - title: "Trust", + slug: "energy-access", + title: "Access to Energy", }, - ], - }, - { - name: "Housing", - slug: "housing", - entries: [ { - slug: "clean-water-sanitation", - title: "Clean Water and Sanitation", + slug: "light-at-night", + title: "Light at Night", }, { - slug: "energy-access", - title: "Access to Energy", + slug: "clean-water-sanitation", + title: "Clean Water and Sanitation", }, { slug: "water-access", title: "Clean Water", }, { - slug: "homelessness", - title: "Homelessness", + slug: "sanitation", + title: "Sanitation", }, { slug: "indoor-air-pollution", title: "Indoor Air Pollution", }, + { - slug: "light-at-night", - title: "Light at Night", - }, - { - slug: "sanitation", - title: "Sanitation", + slug: "homelessness", + title: "Homelessness", }, ], }, @@ -960,10 +929,6 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "working-hours", title: "Working Hours", }, - { - slug: "tourism", - title: "Tourism", - }, ], }, { @@ -978,20 +943,24 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { slug: "social-connections-and-loneliness", title: "Loneliness and Social Connections", }, + { + slug: "trust", + title: "Trust", + }, ], }, { name: "Happiness and Wellbeing", slug: "happiness-wellbeing", entries: [ - { - slug: "happiness-and-life-satisfaction", - title: "Happiness and Life Satisfaction", - }, { slug: "human-development-index", title: "Human Development Index (HDI)", }, + { + slug: "happiness-and-life-satisfaction", + title: "Happiness and Life Satisfaction", + }, ], }, ], @@ -999,100 +968,80 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { { name: "Human Rights and Democracy", slug: "politics", - entries: [], - subcategories: [ + entries: [ { - name: "Human Rights", slug: "human-rights", - entries: [ - { - slug: "state-capacity", - title: "State Capacity", - }, - { - slug: "lgbt-rights", - title: "LGBT+ Rights", - }, - { - slug: "women-rights", - title: "Women’s Rights", - }, - { - slug: "child-labor", - title: "Child Labor", - }, - { - slug: "human-rights", - title: "Human Rights", - }, - ], + title: "Human Rights", }, { - name: "Democracy and Corruption", slug: "democracy", - entries: [ - { - slug: "democracy", - title: "Democracy", - }, - { - slug: "corruption", - title: "Corruption", - }, - ], + title: "Democracy", + }, + { + slug: "state-capacity", + title: "State Capacity", + }, + { + slug: "women-rights", + title: "Women’s Rights", + }, + { + slug: "lgbt-rights", + title: "LGBT+ Rights", + }, + { + slug: "economic-inequality-by-gender", + title: "Economic Inequality by Gender", + }, + { + slug: "violence-against-rights-for-children", + title: "Violence Against Children and Children’s Rights", + }, + { + slug: "child-labor", + title: "Child Labor", }, ], + subcategories: [], }, { name: "Violence and War", slug: "violence-rights", - entries: [], - subcategories: [ + entries: [ { - name: "War and Peace", - slug: "war-peace", - entries: [ - { - slug: "biological-and-chemical-weapons", - title: "Biological and Chemical Weapons", - }, - { - slug: "war-and-peace", - title: "War and Peace", - }, - { - slug: "military-personnel-spending", - title: "Military Personnel and Spending", - }, - { - slug: "terrorism", - title: "Terrorism", - }, - { - slug: "nuclear-weapons", - title: "Nuclear Weapons", - }, - ], + slug: "war-and-peace", + title: "War and Peace", }, { - name: "Violence", - slug: "violence", - entries: [ - { - slug: "state-capacity", - title: "State Capacity", - }, - { - slug: "violence-against-rights-for-children", - title: "Violence Against Children and Children’s Rights", - }, - { - slug: "homicides", - title: "Homicides", - }, - ], + slug: "nuclear-weapons", + title: "Nuclear Weapons", + }, + { + slug: "homicides", + title: "Homicides", + }, + { + slug: "terrorism", + title: "Terrorism", + }, + { + slug: "state-capacity", + title: "State Capacity", + }, + { + slug: "military-personnel-spending", + title: "Military Personnel and Spending", + }, + { + slug: "biological-and-chemical-weapons", + title: "Biological and Chemical Weapons", + }, + { + slug: "violence-against-rights-for-children", + title: "Violence Against Children and Children’s Rights", }, ], + subcategories: [], }, ], } From bbc25e2e1aa56629bddf350f5951ea302ae20859 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Wed, 7 Feb 2024 17:06:09 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20update=20header=20nav=20Populat?= =?UTF-8?q?ion=20Life=20and=20Death=20to=20Population=20Births=20and=20Dea?= =?UTF-8?q?ths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/SiteNavigation.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/SiteNavigation.tsx b/site/SiteNavigation.tsx index 919a142b896..275fbadf89f 100644 --- a/site/SiteNavigation.tsx +++ b/site/SiteNavigation.tsx @@ -278,8 +278,8 @@ export const SiteNavigationStatic: { categories: CategoryWithEntries[] } = { ], }, { - name: "Life and Death", - slug: "life-and-death", + name: "Births and Deaths", + slug: "births-and-deaths", entries: [ { slug: "life-expectancy", From 6f0b3d36cec13418cc777349dcc4246f6ffdd3a5 Mon Sep 17 00:00:00 2001 From: Matthieu Bergel Date: Thu, 8 Feb 2024 14:16:57 +0000 Subject: [PATCH 3/3] tests: add site navigation tests --- devTools/navigationTest/navigationTest.ts | 41 +++++++++++++++++++++++ devTools/navigationTest/tsconfig.json | 8 +++++ package.json | 1 + tsconfig.json | 3 ++ 4 files changed, 53 insertions(+) create mode 100644 devTools/navigationTest/navigationTest.ts create mode 100644 devTools/navigationTest/tsconfig.json diff --git a/devTools/navigationTest/navigationTest.ts b/devTools/navigationTest/navigationTest.ts new file mode 100644 index 00000000000..705aa45ff00 --- /dev/null +++ b/devTools/navigationTest/navigationTest.ts @@ -0,0 +1,41 @@ +// Test all the slugs in the SiteNavigationStatic object and makes sure +// https://ourworldindata.org/{slug} returns a 200 + +import { SiteNavigationStatic } from "../../site/SiteNavigation.js" + +const testSiteNavigation = async () => { + const slugs = SiteNavigationStatic.categories + .map((category) => { + const categorySlugs = category.entries + .map((entry) => entry.slug) + .concat( + (category.subcategories?.length && + category.subcategories.flatMap((subcategory) => + subcategory.entries.map((entry) => entry.slug) + )) || + [] + ) + return categorySlugs + }) + .flat() + + let promises = slugs.map((slug) => { + return fetch(`https://ourworldindata.org/${slug}`, { + method: "HEAD", + }) + }) + + const responses: Response[] = await Promise.all(promises) + if (responses.some((response) => !response.ok)) { + console.error( + "❌ One or more fetches failed: ", + responses + .filter((response) => !response.ok) + .map((response) => response.url) + ) + return + } + console.log("✅ All fetches completed") +} + +testSiteNavigation() diff --git a/devTools/navigationTest/tsconfig.json b/devTools/navigationTest/tsconfig.json new file mode 100644 index 00000000000..91e0ebd46fd --- /dev/null +++ b/devTools/navigationTest/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfigs/tsconfig.base.json", + "compilerOptions": { + "outDir": "../../itsJustJavascript/devTools/navigationTest", + "rootDir": "." + }, + "references": [{ "path": "../../site" }] +} diff --git a/package.json b/package.json index 4a152d1ae5f..018768255cf 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "testLint": "eslint .", "testPrettierAll": "yarn prettier --check \"**/*.{tsx,ts,jsx,js,json,md,html,css,scss,yml}\"", "testJest": "lerna run buildTests && jest", + "testSiteNavigation": "node --enable-source-maps ./itsJustJavascript/devTools/navigationTest/navigationTest.js", "generateDbTypes": "npx @rmp135/sql-ts -c db/sql-ts/sql-ts-config.json" }, "dependencies": { diff --git a/tsconfig.json b/tsconfig.json index 7e2ab3c01aa..75ff206086b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -51,6 +51,9 @@ }, { "path": "./devTools/regionsUpdater" + }, + { + "path": "./devTools/navigationTest" } ] }