thermograph/backend/api/sitemap.py

27 lines
1.1 KiB
Python
Raw Normal View History

"""The indexable-page URL list — shared by the sitemap, IndexNow submission, and
(eventually) the frontend's own sitemap.xml, so all three never drift apart.
"""
from data import cities
MONTHS = ["january", "february", "march", "april", "may", "june",
"july", "august", "september", "october", "november", "december"]
def sitemap_entries() -> list[tuple[str, str, str]]:
"""Every indexable page as (path, changefreq, priority). Paths are relative to
BASE."""
entries = [("/", "daily", "1.0")]
for p in ("/climate", "/about", "/glossary", "/calendar", "/compare", "/legend"):
entries.append((p, "weekly", "0.6"))
for slug in cities.all_slugs():
entries.append((f"/climate/{slug}", "daily", "0.8"))
entries.append((f"/climate/{slug}/records", "monthly", "0.5"))
for m in MONTHS:
entries.append((f"/climate/{slug}/{m}", "monthly", "0.5"))
return entries
def public_paths() -> list[str]:
"""BASE-relative paths of every indexable page — for IndexNow submission."""
return [p for p, _, _ in sitemap_entries()]