Set page title server-side for link preview compatibility

When a specific relation URL is loaded, fetch_relation_name() makes a
lightweight GET /relation/{id}.json call to get the name tag and pass
it to the template. The <title> and og:title are then set server-side,
so forum link previews and crawlers see the route name in the HTML
without executing JavaScript.

Errors are swallowed silently so a slow or failed API response just
falls back to the default title.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-02-27 21:01:25 +00:00
parent 7a4cdfcca7
commit c2355a053d
3 changed files with 26 additions and 2 deletions

View file

@ -3,7 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OSM Public Transport → GeoJSON</title>
<title>{% if route_name %}{{ route_name }} {% endif %}OSM Public Transport → GeoJSON</title>
{% if route_name %}<meta property="og:title" content="{{ route_name }} OSM Public Transport → GeoJSON">{% endif %}
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='favicon.svg') }}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">