From 0e16ad2a93476dd30866ded40cd6d8734574afce Mon Sep 17 00:00:00 2001 From: Emi Griffith Date: Wed, 15 Jul 2026 20:22:47 -0700 Subject: [PATCH] =?UTF-8?q?SEO:=20climate=20hub=20=E2=80=94=20collapse=20a?= =?UTF-8?q?ll=20countries=20by=20default,=20order=20alphabetically=20(#104?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the open-by-default on the first three countries (every
starts collapsed) and order the country sections alphabetically instead of by largest city's population. --- cities.py | 5 ++--- templates/hub.html.j2 | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cities.py b/cities.py index d209ce3..67f7db8 100644 --- a/cities.py +++ b/cities.py @@ -58,12 +58,11 @@ def display_name(city: dict) -> str: def by_country() -> dict[str, list[dict]]: """Cities grouped by country (population-descending within each), country keys - ordered by their largest city — for the /climate hub's crawlable link graph.""" + ordered alphabetically — for the /climate hub's crawlable link graph.""" groups: dict[str, list[dict]] = {} for c in _load(): key = c.get("country") or c.get("country_code") or "Other" groups.setdefault(key, []).append(c) for v in groups.values(): v.sort(key=lambda x: -x["population"]) - # order countries by their biggest city's population (most prominent first) - return dict(sorted(groups.items(), key=lambda kv: -kv[1][0]["population"])) + return dict(sorted(groups.items(), key=lambda kv: kv[0].lower())) diff --git a/templates/hub.html.j2 b/templates/hub.html.j2 index 12113ec..ef932bd 100644 --- a/templates/hub.html.j2 +++ b/templates/hub.html.j2 @@ -12,7 +12,7 @@ {{ n_cities }} cities across {{ n_countries }} countries. Every day is graded against that location's own ~45 years of climate history.

{% for country, cs in groups.items() %} -
+
{{ country }} {{ cs | length }}