Skip to content

Commit

Permalink
enhance(countries): sort countries alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Aug 5, 2024
1 parent 8d77c0d commit c0b5e33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
11 changes: 4 additions & 7 deletions site/CountriesIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import React from "react"
import { Head } from "./Head.js"
import { SiteHeader } from "./SiteHeader.js"
import { SiteFooter } from "./SiteFooter.js"

interface Country {
name: string
slug: string
code: string
}
import { Country, sortBy } from "@ourworldindata/utils"

export const CountriesIndexPage = (props: {
countries: Country[]
baseUrl: string
}) => {
const { countries, baseUrl } = props

const sortedCountries = sortBy(countries, (country) => country.name)

return (
<html>
<Head
Expand All @@ -28,7 +25,7 @@ export const CountriesIndexPage = (props: {
<main className="wrapper">
<h1>Data by country</h1>
<ul>
{countries.map((country) => (
{sortedCountries.map((country) => (
<li key={country.code}>
<a href={`/country/${country.slug}`}>
<img
Expand Down
7 changes: 2 additions & 5 deletions site/CountryProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Head } from "./Head.js"
import { SiteHeader } from "./SiteHeader.js"
import { SiteFooter } from "./SiteFooter.js"
import urljoin from "url-join"
import { Country } from "@ourworldindata/utils"

export interface CountryProfileIndicator {
name: string
Expand All @@ -21,11 +22,7 @@ export interface CountryProfileKeyStats {
}

export interface CountryProfilePageProps {
country: {
name: string
slug: string
code: string
}
country: Country
indicators: CountryProfileIndicator[]
baseUrl: string
}
Expand Down

0 comments on commit c0b5e33

Please sign in to comment.