@sarimarcus/content-sites-tourism 0.22.1 → 0.22.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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.22.2 (2026-10-04)
6
+
7
+ - `./schema`: `cityEventPolicy`, `organization`, `tourismCityBuilders` and `touristTripBuilder` (moved from core); the entity builders build on core `placeNode` (SLA-2918).
8
+ - `./schema` `guideItemListBuilder`: an item's postal code comes from `postalCodeOf` (its `postalCode`, else the address), like the entity builders (SLA-2918).
9
+
5
10
  ## 0.22.1 (2026-10-04)
6
11
 
7
12
  - No changes; lockstep release with ui (SLA-2920).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-tourism",
3
- "version": "0.22.1",
3
+ "version": "0.22.2",
4
4
  "description": "City-tourism vertical: city-entity components, pages templates and utilities for the tourism sites.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "peerDependencies": {
37
37
  "astro": "^7.0.6",
38
38
  "tailwindcss": "^4.1.18",
39
- "@sarimarcus/content-sites-core": "0.22.1",
40
- "@sarimarcus/content-sites-ui": "0.22.1"
39
+ "@sarimarcus/content-sites-core": "0.22.2",
40
+ "@sarimarcus/content-sites-ui": "0.22.2"
41
41
  }
42
42
  }
@@ -1,12 +1,10 @@
1
1
  import {
2
- aggregateRating, createPersonSchema, generateOpeningHours, geoCoordinates,
3
- normalizeHotelPriceRange, normalizePriceRange, parseHoursString, postalAddress, postalCodeOf, withAuthorPersonSchema,
2
+ aggregateRating, createPersonSchema, generateOpeningHours, geoCoordinates, hotelBuilder, isFreeEntry,
3
+ normalizeHotelPriceRange, normalizePriceRange, offer, parseHoursString, placeNode, postalAddress, postalCodeOf,
4
4
  } from '@sarimarcus/content-sites-core/schema';
5
- import type { JsonLdNode, SchemaBuilder } from '@sarimarcus/content-sites-core/schema';
5
+ import type { JsonLdNode, SchemaBuilder, SchemaBuilders } from '@sarimarcus/content-sites-core/schema';
6
6
  import { cityAddressPolicy, type TourismCity } from './city.ts';
7
7
 
8
- const isFree = (data: Record<string, any>) => data.tags?.includes('free') || data.fees?.toLowerCase().includes('free');
9
-
10
8
  export interface MonumentOptions {
11
9
  city: TourismCity;
12
10
  touristType?: string;
@@ -16,36 +14,24 @@ export interface MonumentOptions {
16
14
  export function monumentBuilder(options: MonumentOptions): SchemaBuilder {
17
15
  const address = cityAddressPolicy(options.city);
18
16
  const touristType = options.touristType ?? 'Cultural';
19
- return (data, ctx) => withAuthorPersonSchema(ctx, {
20
- '@type': 'TouristAttraction',
21
- name: data.name,
22
- description: data.description,
23
- image: ctx.resolveImageUrl(data.image, data.slug),
17
+ return (data, ctx) => placeNode(ctx, data, 'TouristAttraction', 'monument', {
24
18
  address: postalAddress(address, data, { street: data.address, postalCode: postalCodeOf(data) }),
25
19
  geo: geoCoordinates(data.coordinates),
26
20
  openingHoursSpecification: parseHoursString(data.hours),
27
- isAccessibleForFree: isFree(data),
21
+ isAccessibleForFree: isFreeEntry(data, 'fees'),
28
22
  touristType,
29
- mainEntityOfPage: { '@id': ctx.pageUrl },
30
- url: ctx.route('monument', data.slug),
31
- }, data.author);
23
+ });
32
24
  }
33
25
 
34
26
  /** Museum at route `museum`; hours from the free-text `hours` line. */
35
27
  export function museumBuilder(options: { city: TourismCity }): SchemaBuilder {
36
28
  const address = cityAddressPolicy(options.city);
37
- return (data, ctx) => withAuthorPersonSchema(ctx, {
38
- '@type': 'Museum',
39
- name: data.name,
40
- description: data.description,
41
- image: ctx.resolveImageUrl(data.image, data.slug),
29
+ return (data, ctx) => placeNode(ctx, data, 'Museum', 'museum', {
42
30
  address: postalAddress(address, data, { street: data.address, postalCode: postalCodeOf(data) }),
43
31
  geo: geoCoordinates(data.coordinates),
44
32
  openingHoursSpecification: parseHoursString(data.hours),
45
- isAccessibleForFree: isFree(data),
46
- mainEntityOfPage: { '@id': ctx.pageUrl },
47
- url: ctx.route('museum', data.slug),
48
- }, data.author);
33
+ isAccessibleForFree: isFreeEntry(data, 'fees'),
34
+ });
49
35
  }
50
36
 
51
37
  const menu = (sectionName: string, items: string[] | undefined): JsonLdNode | undefined =>
@@ -67,11 +53,7 @@ export interface RestaurantOptions {
67
53
  export function restaurantBuilder(options: RestaurantOptions): SchemaBuilder {
68
54
  const address = cityAddressPolicy(options.city);
69
55
  const sectionName = options.menuSectionName ?? 'Specialties';
70
- return (data, ctx) => withAuthorPersonSchema(ctx, {
71
- '@type': 'Restaurant',
72
- name: data.name,
73
- description: data.description,
74
- image: ctx.resolveImageUrl(data.image, data.slug),
56
+ return (data, ctx) => placeNode(ctx, data, 'Restaurant', 'restaurant', {
75
57
  address: postalAddress(address, data, { street: data.address, postalCode: postalCodeOf(data) }),
76
58
  servesCuisine: data.cuisine,
77
59
  priceRange: normalizePriceRange(data.averagePrice, data.priceFrom),
@@ -81,9 +63,7 @@ export function restaurantBuilder(options: RestaurantOptions): SchemaBuilder {
81
63
  geo: geoCoordinates(data.coordinates),
82
64
  sameAs: data.website ? [data.website] : undefined,
83
65
  hasMenu: menu(sectionName, data.specialties),
84
- mainEntityOfPage: { '@id': ctx.pageUrl },
85
- url: ctx.route('restaurant', data.slug),
86
- }, data.author);
66
+ });
87
67
  }
88
68
 
89
69
  export interface BarOptions {
@@ -98,11 +78,7 @@ export function barBuilder(options: BarOptions): SchemaBuilder {
98
78
  const address = cityAddressPolicy(options.city);
99
79
  const sectionName = options.menuSectionName ?? 'Signature Drinks';
100
80
  const tapas = options.tapasCuisine ?? 'Tapas';
101
- return (data, ctx) => withAuthorPersonSchema(ctx, {
102
- '@type': 'BarOrPub',
103
- name: data.name,
104
- description: data.description,
105
- image: ctx.resolveImageUrl(data.image, data.slug),
81
+ return (data, ctx) => placeNode(ctx, data, 'BarOrPub', 'bar', {
106
82
  address: postalAddress(address, data, { street: data.address, postalCode: postalCodeOf(data) }),
107
83
  geo: geoCoordinates(data.coordinates),
108
84
  priceRange: normalizePriceRange(data.averagePrice, data.priceFrom),
@@ -112,9 +88,7 @@ export function barBuilder(options: BarOptions): SchemaBuilder {
112
88
  hasMenu: menu(sectionName, data.specialties),
113
89
  openingHoursSpecification: generateOpeningHours(data.openingHours),
114
90
  telephone: data.phone,
115
- mainEntityOfPage: { '@id': ctx.pageUrl },
116
- url: ctx.route('bar', data.slug),
117
- }, data.author);
91
+ });
118
92
  }
119
93
 
120
94
  export interface DishOptions {
@@ -150,11 +124,7 @@ export function dishBuilder(options: DishOptions = {}): SchemaBuilder {
150
124
  export function neighborhoodBuilder(options: { city: TourismCity }): SchemaBuilder {
151
125
  const { city } = options;
152
126
  const address = cityAddressPolicy(city);
153
- return (data, ctx) => withAuthorPersonSchema(ctx, {
154
- '@type': 'Place',
155
- name: data.name,
156
- description: data.description,
157
- image: ctx.resolveImageUrl(data.image, data.slug),
127
+ return (data, ctx) => placeNode(ctx, data, 'Place', 'neighborhood', {
158
128
  address: postalAddress(address, data),
159
129
  geo: geoCoordinates(data.coordinates || city.geo),
160
130
  containedInPlace: {
@@ -162,9 +132,51 @@ export function neighborhoodBuilder(options: { city: TourismCity }): SchemaBuild
162
132
  name: city.locality,
163
133
  address: { '@type': 'PostalAddress', addressRegion: city.region, addressCountry: city.country },
164
134
  },
165
- mainEntityOfPage: { '@id': ctx.pageUrl },
166
- url: ctx.route('neighborhood', data.slug),
167
- }, data.author);
135
+ });
136
+ }
137
+
138
+ export interface TouristTripOptions {
139
+ touristType?: string;
140
+ offerDescription?: string;
141
+ currency?: string;
142
+ }
143
+
144
+ /** A free self-guided TouristTrip at route `walk`, its stops as the itinerary (moved from core, SLA-2918). */
145
+ export function touristTripBuilder(options: TouristTripOptions = {}): SchemaBuilder {
146
+ const { touristType = 'Cultural', offerDescription = 'Self-guided walking tour — free', currency = 'EUR' } = options;
147
+ return (data, ctx) => placeNode(ctx, data, 'TouristTrip', 'walk', {
148
+ touristType: data.theme || touristType,
149
+ offers: offer(0, currency, { description: offerDescription }),
150
+ itinerary: {
151
+ '@type': 'ItemList',
152
+ numberOfItems: data.stops?.length || 0,
153
+ itemListElement: (data.stops || []).map((stop: any, i: number) => ({
154
+ '@type': 'ListItem',
155
+ position: i + 1,
156
+ item: {
157
+ '@type': 'TouristAttraction',
158
+ name: stop.name,
159
+ description: stop.description,
160
+ geo: geoCoordinates(stop.coordinates),
161
+ ...(stop.slug && stop.type !== 'landmark' ? { url: ctx.abs(`/${stop.type}/${stop.slug}`) } : {}),
162
+ },
163
+ })),
164
+ },
165
+ });
166
+ }
167
+
168
+ /** The entity builders every city guide shares, all addressed in `city`. */
169
+ export function tourismCityBuilders(city: TourismCity): SchemaBuilders {
170
+ return {
171
+ monument: monumentBuilder({ city }),
172
+ museum: museumBuilder({ city }),
173
+ restaurant: restaurantBuilder({ city }),
174
+ bar: barBuilder({ city }),
175
+ dish: dishBuilder(),
176
+ neighborhood: neighborhoodBuilder({ city }),
177
+ hotel: hotelBuilder({ address: cityAddressPolicy(city) }),
178
+ touristTrip: touristTripBuilder(),
179
+ };
168
180
  }
169
181
 
170
182
  /** Guide item `type` (a plural collection name) → schema type (SLA-2468). */
@@ -198,7 +210,7 @@ export function guideItemListBuilder(options: { city: TourismCity; itemTypes?: R
198
210
  image: ctx.resolveImageUrl(item.image, item.slug),
199
211
  };
200
212
  const addressNode = (item.type !== 'dishes' && item.type !== 'neighborhoods' && item.address)
201
- ? postalAddress(policy, item, { street: item.address, postalCode: item.address?.match(/(\d{5})/)?.[1] })
213
+ ? postalAddress(policy, item, { street: item.address, postalCode: postalCodeOf(item) })
202
214
  : undefined;
203
215
  const geoNode = geoCoordinates(item.coordinates);
204
216
  if (schemaType === 'Event') {
@@ -1,5 +1,7 @@
1
1
  import { geoCoordinates } from '@sarimarcus/content-sites-core/schema';
2
- import type { AddressPolicy, TouristDestinationFields } from '@sarimarcus/content-sites-core/schema';
2
+ import type {
3
+ AddressPolicy, EventItemListOptions, JsonLdNode, TouristDestinationFields,
4
+ } from '@sarimarcus/content-sites-core/schema';
3
5
 
4
6
  /** The city a tourism site covers: every entity's PostalAddress and the default pin come from here. */
5
7
  export interface TourismCity {
@@ -40,3 +42,30 @@ export function cityDestinationFields(
40
42
  touristType: copy.touristType ?? 'Cultural',
41
43
  };
42
44
  }
45
+
46
+ /** A named Organization node, with its URL when given. */
47
+ export function organization(name: string, url?: string): JsonLdNode {
48
+ return { '@type': 'Organization', name, ...(url && { url }) };
49
+ }
50
+
51
+ export interface CityEventOptions {
52
+ /** The council: organizer of an event that names none, and of every listed event. */
53
+ council: { name: string; url: string };
54
+ /** The site's performer rule, given the council node; `undefined` emits none. */
55
+ performer(data: Record<string, any>, council: JsonLdNode): JsonLdNode | undefined;
56
+ /** Add `geo` from `coordinates` to each event's Place. */
57
+ geo?: boolean;
58
+ }
59
+
60
+ /** The event policy of a city guide, for both `eventBuilder` and `eventItemListBuilder`: events take place in the city. */
61
+ export function cityEventPolicy(city: TourismCity, options: CityEventOptions): EventItemListOptions {
62
+ const council = () => organization(options.council.name, options.council.url);
63
+ return {
64
+ address: cityAddressPolicy(city),
65
+ defaultLocationName: city.locality,
66
+ ...(options.geo && { geo: true }),
67
+ performer: (d) => options.performer(d, council()),
68
+ organizer: (d) => (d.organizer ? organization(d.organizer.name, d.organizer.url) : council()),
69
+ itemOrganizer: council,
70
+ };
71
+ }
@@ -1,8 +1,8 @@
1
1
  // Public surface of @sarimarcus/content-sites-tourism/schema: city-entity JSON-LD builders on core `schema`.
2
- export { cityAddressPolicy, cityDestinationFields } from './city.ts';
3
- export type { TourismCity } from './city.ts';
2
+ export { cityAddressPolicy, cityDestinationFields, cityEventPolicy, organization } from './city.ts';
3
+ export type { TourismCity, CityEventOptions } from './city.ts';
4
4
  export {
5
5
  monumentBuilder, museumBuilder, restaurantBuilder, barBuilder, dishBuilder, neighborhoodBuilder,
6
- guideItemListBuilder, GUIDE_ITEM_TYPES,
6
+ guideItemListBuilder, GUIDE_ITEM_TYPES, touristTripBuilder, tourismCityBuilders,
7
7
  } from './builders.ts';
8
- export type { MonumentOptions, RestaurantOptions, BarOptions, DishOptions } from './builders.ts';
8
+ export type { MonumentOptions, RestaurantOptions, BarOptions, DishOptions, TouristTripOptions } from './builders.ts';