@autobusal/routes-search 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utilities.ts +28 -2
package/package.json
CHANGED
package/utilities.ts
CHANGED
|
@@ -6,15 +6,41 @@ export const getCities = (cities: CityData[], t: TFunction<'common'>): Autocompl
|
|
|
6
6
|
const data: AutocompleteData[] = [];
|
|
7
7
|
|
|
8
8
|
cities.forEach(city => {
|
|
9
|
+
/*
|
|
10
|
+
* Claude - Date: 2026-08-21
|
|
11
|
+
*
|
|
12
|
+
* Every spelling this place answers to, so the box matches what the
|
|
13
|
+
* visitor TYPES rather than what their interface language happens to
|
|
14
|
+
* call the place. `aliases` comes from /api/cities/browse and holds the
|
|
15
|
+
* name in all 15 languages plus historical and colloquial variants -
|
|
16
|
+
* "Solun", "Selanik", "Θεσσαλονίκη" and "Salonic" all reach
|
|
17
|
+
* Thessaloniki. The country name and the slug go in too: the slug is
|
|
18
|
+
* what appears in the URL, so somebody pasting or half-remembering one
|
|
19
|
+
* finds the city.
|
|
20
|
+
*
|
|
21
|
+
* These are NEVER displayed - `name` is what shows, resolved to the
|
|
22
|
+
* visitor's own language server-side.
|
|
23
|
+
*/
|
|
24
|
+
const search = [
|
|
25
|
+
...(city.aliases ?? []),
|
|
26
|
+
city.country?.name ?? '',
|
|
27
|
+
city.slug
|
|
28
|
+
].filter(Boolean);
|
|
29
|
+
|
|
9
30
|
data.push({
|
|
10
31
|
name: `${ city.name }, ${ city.country?.name ?? '' } (${ t('all_stations', { ns: 'common' }) })`,
|
|
11
|
-
value: `${ city.slug }
|
|
32
|
+
value: `${ city.slug }`,
|
|
33
|
+
search
|
|
12
34
|
});
|
|
13
35
|
|
|
14
36
|
city.stops?.forEach(stop => {
|
|
15
37
|
data.push({
|
|
16
38
|
name: `${ city.name }, ${ city.country?.name ?? '' } (${ stop.name })`,
|
|
17
|
-
value: `${ city.slug }:${ stop.id }
|
|
39
|
+
value: `${ city.slug }:${ stop.id }`,
|
|
40
|
+
// the stop's own name as well - station names are not translated
|
|
41
|
+
// (they are what is written on the building) but they are certainly
|
|
42
|
+
// searched for
|
|
43
|
+
search: [ ...search, stop.name ]
|
|
18
44
|
});
|
|
19
45
|
});
|
|
20
46
|
});
|